Display the segment on the pic trainer, Electrical Engineering

Aim:

The aim of this practical is to work with multiplexed 7-segment displays and implement a counter and display the 7- segment on the PIC trainer.

Equipment:

  • PIC Trainer and PICkit3 in-circuit debugger
  • PIC 7-segment display board
  • MPLAB Integrated Development Environment software

 

Table

Digit

7 seg code

Hex Code

 

dp

g

f

e

d

c

b

a

0

0

1

1

1

1

1

1

0

0

0

0

0

1

1

0

0

1

0

1

1

0

1

1

0

1

0

0

1

1

1

1

0

1

1

0

0

1

1

0

0

1

1

0

1

1

0

1

0

1

1

1

1

1

0

1

0

0

0

0

0

1

1

1

0

1

1

1

1

1

1

1

0

1

1

0

0

1

1

1

0

1

1

1

0

1

1

1

0

1

1

1

1

1

0

0

0

0

1

1

1

0

0

1

0

1

0

1

0

1

1

1

0

1

1

1

1

0

0

1

0

1

1

1

0

0

0

1

 

 

0

3F

1

0x06

2

0x5B

3

0x4F

4

0x66

5

0x6D

6

0x7D

7

0x07

8

0x7F

9

0x67

A

0x77

B

0x7c

C

0x39

D

0x5E

E

0x79

F

0x71

 

Procedure:

In the beginning of the program, it is expected that the program displays one digit on the LCD with configuring of PortB , Port C and Port D and send the result to port D to be display.

The bit 1 of port C was set to active the PortC1 to display the number on the LSB digit and an appropriate value was written to port D. In order to control the 7-segment display an appropriate value was written to Port D.

The reset vector was defined and the program was directed to the START of the program to call the initialization to set the port B as an input by setting the TRISB and then make the port C and D as an output by clearing their TRISs. The program then will return in order to move the binary value (b'0111111') into the W register to be assigned to TRISB for an input.

The program then was given a subroutine name " again"to branch back and continue this cycle in order to show the digits accordingly.

After the program was started the program shows a digit number 0 on the right hand side display because the program turns on the segment a to f but not g as the table above shows.

Single digit counter:

The aim of this step was to write a subroutine hex_7seg to turn on the right hand display and shows the required number.

The program was accomplished in this step by continuing the instructions in the previous step and extending them such that after the program was branched to START and moving the binary value into the WREG as well as the value of port B and clearing the ports C and D, the value 0x00 was moved into the W register and the value was saved into the memory location name, Count.

The counter loop was written in order to call for display subroutine, but this instruction was used few times in the subroutine to give the program enough delay to display each of the digits. The display subroutine moves the contents of temporary location into the W register and calls the lookup table to get number in the range of 0 to 9. The 7 segment display was moved into the port D and then by setting the bit 1 of port C this bit of the port was activated. A delay of 10msec was called in this stage for delay and then bit 1 was deactivated to the LSB of 7 segments. The content of the counter was swapped and the value then was stored into WREG. The lookup table was again called to get the number and the 7-segment display on the LCD screen. The bit 0 of port C was activated to display the number on the LSB digit and this process with the delay of 10msec was repeated twice and returned.

 Then; the counter value was moved into the WREG and 1 was adding to it to count up and the DAW instruction was used to keep the value as BCD (binary code number). The counter then was moved into the WREG and program was branched back into the title of the subroutine.(counter_loop).

The look up table of 7 segments was written to firstly discard the upper 4 bits of the contents of the W register and then incrementing its content. The addwf PCL,F was then used to add WREG content to the program counter in order to jump relative to the value which was stored in the W register.  The numbers then was found according to the table 1 and was load and returned by using the instruction retlw. The program then was branched back for an endless loop before the end instruction.

Result: After the program was built and run, digits from the 0 to 9 were displayed on the right hand display. This cycle was continued until the program was reset.

Double digit

The previous program was modified with having counter_loop and initialization loop untouched. The display loop however was modified by activating bit 2 of the PortC by selecting this bit within the PortC. That was done in order to display the number on the least significant digit. That bit then was cleared to deactivate the least significant bit 7-segment of the PortC. Between setting and clearing of bit 2 of PortC delay of 10m second was called to display the digits on the LCD screen with some delay in between.

The look up table for 7 segment display was also modified with adding letters from A up to F for extending the counter to double digit form.

Result:

After the program was built and run, the counting began on the LCD from digit 0 up to 99. Similarly to the previous step, the right hand display count from 0 up to 9 and the left hand display (most significant bit) was increased by 1 when the first cycle of (0-9) was displayed. After the program reaches to digit 99, the program repeats the loop to begin the counting again.

The PortC, 1 was set to activate the number on the least significant bit digit while the PortC ,2 was set to activate and display the  number on the most significant bit digit. The program can be stop by resetting it since the stop push button was not activated.

The counter was incremented for 100 ms by call display 5 times. The result of this step was appeared on the LED in the hex and the BCD format 0 to 99.

Up-down counter

In this step of the practical, the aim is to use the green push button on the main board (PB1) to start the counter from zero up to 9 when the start button is pressed. In order to accomplish this, the previous program was modified by adding an extra subroutine for the push button.

In the button_for _start subroutine, after the display subroutine was called the btfsc  PORTB,4 instruction was used in order to activate the start button and the program then will be branched to go back to the title of this subroutine until the required push button was pressed. In order to activate the stop button a bit 3 of the Port was used (btfsc PORTB,3).

Result:

After the program was build and run, similar result to the previous step was obtained after the green push button (PB1) was pressed and the counting cycle began.

Conclusion:

In the conclusion, it was learned from this practical how to display a digit in one or two digit on the LED by configuring the ports B and C and sent them to the Port D to be displayed. The counter also was displayed on the LED in both hex and BCD format and the start and stop button were also implemented.

Posted Date: 3/5/2013 7:08:32 AM | Location : United States







Related Discussions:- Display the segment on the pic trainer, Assignment Help, Ask Question on Display the segment on the pic trainer, Get Answer, Expert's Help, Display the segment on the pic trainer Discussions

Write discussion on Display the segment on the pic trainer
Your posts are moderated
Related Questions
shockely equation?

The five stages of DLX pipeline is:- ? Operand location ? Number of explicit operands per instruction ? Operand storage in the CPU ? Operations ? Type and size of o

Sectoral Overview and Enabling Framework Previously, you have studied about several Acts and Policies relevant to the power sector, their aims, main features and implications

How do i calculate critical resistance?

Find Dispersion Relation for Free Electron Question: Find the dispersion relation for a free electron, and, thus, observe the relation between its rest mass and effective ma

Calculate the gain and phase response of an FIR digital filter Calculate the gain and phase response of an FIR digital filter as in below Figure with A 0 = 1, A 1 = 2, A 2 =

Types of Power Diode According  to their  reverse recovery characteristics of power diodes it can be  classified as follows: a.       General purpose  diodes b.      Fas

Q. Obtain the Thévenin and Norton equivalent circuits for the portion of the circuit to the left of terminals a-b in Figure, and find the current in the 200- resistance.

Q. Sketch the timing diagram for a 4-bit ripple counter which uses T flip-flops.

why conductance is not zero at end pont? reply as soon as possible.