Display the segment on the pic trainer, Electrical Engineering

Assignment Help:

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.


Related Discussions:- Display the segment on the pic trainer

D/a converter, weighted resistor and r2r ladder d/a converter

weighted resistor and r2r ladder d/a converter

What do you mean by common collector configuration, Q. What do you mean by ...

Q. What do you mean by Common collector configuration? Common collector configuration:In this circuit the collector is common to both the input and the output.Such a configurat

Build an intersection traffic light using the led, Build an intersection tr...

Build an intersection traffic light using the LED's as in the diagram below Day Use the LED's on the trainer (port 11) Main Street and Side Street alternate. Mai

Repeatability , Reproducibility and repeatability are measures of closeness...

Reproducibility and repeatability are measures of closeness with which a given input may be measured over again. The two terms cause confusion. Therefore, a distinction is made bet

Lki load register pair immediate instruction , LKI  Load Register pair  ...

LKI  Load Register pair  Immediate  Instruction This instruction is used to copy or  load  16 bit  data specified  in the  instruction  directly into  the register pair. The i

A circuit having of a resistor connected in series, A circuit having of a r...

A circuit having of a resistor connected in series with a 0.5µF capacitor and has a time constant of 12 ms. Verify: (a)  The value of the resistor (b)  The capacitor voltage

Find the smallest value of v, Q. An n-channel JFET is given to have V P = ...

Q. An n-channel JFET is given to have V P = 3V and I DSS = 6 mA. (a) Find the smallest value of v DS when v GS =-2 V if the operation is to be in the active region. (b) D

Explain from the drain characteristics, Q. Explain from the drain character...

Q. Explain from the drain characteristics that a JFET has  infinite resistance? When V GS = 0v when a positive voltage Vds has been applied across the channel and the gate

Decrease in the dollar return on u.s. deposits, Q. Is a depreciation of the...

Q. Is a depreciation of the dollar/euro exchange rate correlated with a decrease in the dollar return on U.S. deposits? Answer: No, suppose that the Interest Parity is maintai

Dc motor, write the working and construction of dc motor.

write the working and construction of dc motor.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd