Maker Pro
Maker Pro

Need help to understand circuit!!

paddy

Sep 11, 2012
81
Joined
Sep 11, 2012
Messages
81
Hi,

Greetings of the day!!!

I have got a display board which has 3 common anode 7 segment displays, 7 individual LED's and 4 switches.

Segments are driven by using port 0 of P89V51RD2 micro controller (through 74HCT574 latch IC). The common terminals (COM1 to COM4 as indicated in schematic) are also driven by using port 0 of P89V51RD2 micro controller (through another 74HCT574 latch IC and the output of latch IC if given to ULN2003). COM1, COM2, COM3 and COM4 is nothing but the output pins of ULN2003.

Pin no 14 on connector CN1 (common point where anode's of all diodes are connected) is connected to port 1.4 (pin no 5 of micro controller).

With this schematic I can't figure out how the micro controller is reading the state of switch and how it is differentiate that which switch has been pressed??

Please advice.

Regards,
Paddy
 

Attachments

  • 4-1 Switch control.jpg
    4-1 Switch control.jpg
    49.1 KB · Views: 142

kpatz

Feb 24, 2014
334
Joined
Feb 24, 2014
Messages
334
Based on what I'm seeing in the schematic, they're common cathode displays, not common anode. But for the purposes of answering your question that doesn't matter much.

The micro is multiplexing the display by sequentially turning "on" each of the common cathodes via COM1-4 and displaying the appropriate digit via the DEGA-SEGDP (not sure why A is DEGA and not SEGA, but I digress).

The COM lines are pulled to ground when they are active. While it's doing this, it also "reads" port 1.4 to see if the button corresponding to the COM line that is currently active is pressed. If the button is pressed and the button's COM line is active, port 1.4 is pulled low (presumably there's a pull-up resistor on that line somewhere, maybe built-in to the micro). An unpressed button, or a pressed button on a currently inactive COM line won't pull the input low, so it will be high due to the pull-up.

So, it goes through this cycle:

1. COM1 on, display digit on DS1, and see if S1 is pressed.
2. COM2 on, display digit on DS2, and see if S2 is pressed.
3. COM3 on, display digit on DS3, and see if S3 is pressed.
4. COM4 on, display LEDs L1-8, and see if S4 is pressed.

It's just a way of multiplexing both the buttons and the LEDs together, so only one additional I/O is needed to read all 4 buttons.
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Great answer kpatz!

Yes, the pullups are inside the micro. The P89V51RD2 from NXP is an 80C51 device, so it uses "quasi-bidirectional" I/O for all its digital I/O ports except Port 0.

Each quasi-bidirectional port has only a single register in the SFR space; for each bit, writing a 0 makes the MCU pull the pin down firmly, and writing a 1 makes it pull high weakly. Reading the register yields the actual pin states.

So you write a 1 to every bit that you want to use as an input; the device pulls the pin high weakly (in which case you read a 1), but an external signal can pull it down (in which case you read a 0).

This system does away with the DDR (data direction register) and reduces each port to a single register address. You have to be careful when performing logical operations on it though, because a port that's in input mode and being pulled down externally will read as 0, and if the 0 is written back, the device will hold the pin low and it will get stuck!
 

kpatz

Feb 24, 2014
334
Joined
Feb 24, 2014
Messages
334
Good info there KrisBlueNZ. I'm mainly familiar with PICs and not the 8051-types. But looking at the circuit *something* needed to pull that line high, thus my assumption of either an internal or external pull-up.
 
Top