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

Determine the expression for strain energy, A 3.2m long bar of 16mm in diam...

A 3.2m long bar of 16mm in diameter hangs vertically and has a collar attached at the lower end calculate the max. stress induced when a weight of 80 kg falls fromaheight of 32mm o

Working of harmonic distortion analyzer, Q. Explain with the help of a bloc...

Q. Explain with the help of a block diagram the working of harmonic distortion analyzer. OR Write short note on Harmonic distortion analyzer. Sol. Several methods h

Calculate the ef?ciency of the induction generator, A three-phase, four-pol...

A three-phase, four-pole, 220-V, 60-Hz induction machine with a per-phase resistance of 0.5  is operating at rated voltage as a generator at a slip of -0.04, delivering 12 A of li

Counters, i need a counter of following o/p truth table 00000000 10000000 1...

i need a counter of following o/p truth table 00000000 10000000 11000000 11100000 11110000 11111000 11111100 11111110 11111111 00000000 10000000 . . . so please suggest me some IC

Find the modulated signal in each case, Let the message signal m(t) = α cos...

Let the message signal m(t) = α cos (2πf m t) be used to either frequency-modulate or phase- modulate the carrier Ac cos(2πf c t). Find the modulated signal in each case.

Determine the two possible ssb am signals, Let the modulating signal m(t) b...

Let the modulating signal m(t) be a sinusoid of the form m(t) = cos 2πf m t, f m c , and let the carrier signal be cos(2πf c t + φc). (a) Determine the conventional AM signal,

Determine the force, Consider an electromagnet, as shown in Figure, which i...

Consider an electromagnet, as shown in Figure, which is used to support a solid piece of steel and is excited by a coil of N = 1000 turns carrying a current i = 1.5 A. The cross-se

Pdc, disadvantages of shunt&series clippers

disadvantages of shunt&series clippers

Solid state devices, what are the significance of solid state devices in el...

what are the significance of solid state devices in electrical engineering

Explain the working of a darlington pair, Q. Explain the working of a darli...

Q. Explain the working of a darlington pair? This is two transistors connected together so that the current amplified by the first is amplified further by the second transistor

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