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

Frequency response of amplifiers, Q. Frequency response of amplifiers? ...

Q. Frequency response of amplifiers? All amplifiers exhibit variations of performance as the signal frequency is changed. The frequency response of an amplifier may be defined

Determine the location and the value of the point charge, Q The electric ?e...

Q The electric ?eld intensity due to a point charge in free space is given to be (-¯ ax -¯ ay +¯ az)/√ 12V/mat (0,0,1) and 6 ¯ az at (2,2,0) Determine the location and the value

Calculate the bandwidth of the new signal, A signal comprises a bandwidth o...

A signal comprises a bandwidth of 1kHz centred around 1kHz.  A sine wave along with a frequency of 1250Hz is added to the signal. The bandwidth of the new signal is: 2250Hz

Determine the electromagnetic force on the plunger, Q. Consider the electro...

Q. Consider the electromagnetic plunger shown in Figure. The λ-i relationship for the normal working range is experimentally found to be λ = Ki 2/3 /(x+t), where K is a constant. D

Revision of basics, Revision  of Basics Although  it is  assumed in th...

Revision  of Basics Although  it is  assumed in this book  that the  reader has  enough  knowledge of  various number systems ( binary, octal and hexadecimal and their relation

Explain contact resistance, Explain Contact resistance. Contact resista...

Explain Contact resistance. Contact resistance: It is measured as the voltage drop from tail to tail of the mated contacts along with specified current flowing through the cont

Calculate the stator input current, Q. Calculate the stator input current? ...

Q. Calculate the stator input current? The parameters of the equivalent circuit shown in Figure for a three-phase, wye-connected, 220-V, 10-hp, 60-Hz, six-pole induction motor

Loss reduction and efficiency of electrical energy, Loss Reduction and Effi...

Loss Reduction and Efficiency Improvement of Electrical Energy 1. There are inherent losses in Transmission and Distribution of electrical energy from Generating station

Amplifier, Amplifier Usually, an amplifier or simply amp, is any devic...

Amplifier Usually, an amplifier or simply amp, is any device which changes, generally increases, the amplitude of a signal. The connection of the input to the output of an amp

State kirchoff''s current law, State Kirchoff's Current Law Kirchoff's...

State Kirchoff's Current Law Kirchoff's Current Law (KCL) describes at any junction in an electric circuit the total current flowing towards that junction is equivalent to th

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