Control multiple 7 Segs from 28X1

pilko

Senior Member
Hi everyone,
Been experimenting controlling several 7 seg displays by switching low the common cathode.It works OK but I am afraid to switch the common when displaying more than three segments. I'm thinking I need to use a transistor.
Comments appreciated.

Code:
start:

pins=%01100000 'Display a "1"

high portc 6   
low portc 5    'Switch segment 1 common,low
pause 5


pins=%00001110 'Display a "7"

high portc 5   
low portc 6    'Switch segment 2 common,low
pause 5

goto start
 

pha555

Senior Member
At;

http://www.phanderson.com/picaxe/picaxe.html

I have a discussion of using a MAX7219 which can accommodate up to eight 7-seg LEDs. (Common cathode). One nice feature is that the MAX7219 uses one resistor to set the LED current.

There is also a discussion of using a 74HC595 8-bit shift register. These can be cascaded.

I recently added a Phillips IR2D07 16-bit constant current shift register and have students writing some sample code. This can handle two 7-seg LEDs. (CA).

Peter Anderson
 

BCJKiwi

Senior Member
Sorry but I'm a little confused - don't worry it's easy to achieve!.
Presumably PortC 5 relates to the common cathode on 7seg module #1 (say zeros)
and PortC 6 relates to the common cathode on 7seg module #2 (say tens)
and, since the pins= line is presumably common-ed to the segments in each 7seg module, how can more than one be on at a time? (unless they all show the same number).
So the comment 'Switch segment 1 common, low presumably means the activate that whole 7seg display module.

In any case, the total current of the lit segments needs to be less that the MAX of 20mA that the cathode pin can handle.

The total current capacity of the 28X1 also needs to be considered.
There are separate current limits by pin, by port and by the whole chip to consider.

To achieve useful brightness over multiple 7seg modules, then additional chips will be required so it may well be easier to use any of the many 7seg or led driver chips out there.

Have used MCP23017 (16 port) and Philips SAA1064 24pin dip (4 7seg modules) to good effect.
 
Last edited:

westaust55

Moderator
How many digits are you looking to use ? :confused:

Using the MCP23017 as mentiond by BCJKiwi, well in fact two of them, I have multiplexed (not charlieplexed) a total of 192 LED’s in 8 groups of 24. So it is all very do-able but you need to run at at least 8MHz and possibly 16 MHz to avoid flicker.
Only needs 2 wires from a X part PICAXE for the i2c comms
I am using transistors between the MCP23017 and the LED's

I have also just last week assembled a set of three 74HC595 shift registers in cascade with them driving three 7-seg displays so as to be able to display a value from 0.00, 0.01, 0.02, etc thru to 999. with the decimal point for each digit also active.
Uses just 3 wires (have it running on an 08M) You can have as many digits this way as you want. No flicker but may time a while to transfer data
(my past tests showed bit-bashed SPI was around half the speed of i2c comms)
 
Last edited:

pilko

Senior Member
BCJKiwi -- The system does alow a different number on each display since synchronizing is done with the common cathode switching.
I agree with you on the need to limit the current on the common pins, probably by switching them with transistors.
 

MartinM57

Moderator
- you need a resistor on each 'pin' output that limits the individual segment current (EDIT: you don't have to, but you need to absolutely guarantee that you multiplex between digits very quickly and very reliably - slow down too much or have a program bug that stops the multiplexing will blow the displays and/or the PICAXE)
- you may not need a transistor on each cathode - say your resistor limits the current to 10mA - worst case is 80mA, which the 28X1 will do OK
- beware that anytime your code goes off and does something else (read a temp, read a switch etc) the multiplexing will stop...so you might want to consider driving the multiplexing from a timed interrupt rather than with pauses - or using external driver chips (MAX7219 etc)
- make sure you turn off the last cathode before changing 'pins; or else you will get ghosting across digits (the code in post#1 suffers from this)
 
Last edited:

westaust55

Moderator
BCJKiwi -- The system does alow a different number on each display since synchronizing is done with the common cathode switching.
I agree with you on the need to limit the current on the common pins, probably by switching them with transistors.
- you need a resistor on each 'pin' output that limits the individual segment current
- you may not need a transistor on each cathode - say your resistor limits the current to 10mA - worst case is 80mA, which the 28X1 will do OK
28X1 cannot do 80mA on a single pin to switch the common side of a 7-seg display. That is the rating for an entire port.
Each pin is limited to ~20mA. Entire chip is limited to ~90-95mA Absolute Max.
 

MartinM57

Moderator
Hmm...remembered the max chip capabilities, but not the max pin capabilities. You are correct. So transistors will be needed...

Anyway, having dallied with PICAXE multiplexing a long time ago (with transistors), for anything other than the most simplest system with a small number of displays, the only way to go is external decoder/drivers that you only update when there is actually a change required on the display. And as well known here MAX7219 is my favourite chip...single resistor current setting, programmable brightness, up to 8 displays per chip - and then cascadable if you want more, characters other than 0-9 etc etc
 

hippy

Ex-Staff (retired)
Hmm...remembered the max chip capabilities, but not the max pin capabilities. You are correct. So transistors will be needed.
Not if the sunk current is limited to below the pin maximum.

If each segment uses N mA, the total sourced from any pin to anode is N mA, the total sourced from the port is 7 x N mA, the total sunk by a single cathode pin 7 x N mA; providing that 7 x N mA is less than pin maximum you will be okay.

If each pin can sink 21mA that means N can be less than or equal to 3mA and 3mA can be enough to illuminate a single segment brightly enough. Even when multiplexed and only on for an eighth of the time ( 8 x 7-Seg ).

If segments require more than 3mA, transistors will be required. That's the recommended practice.

In actual practice, more than 3mA can be delivered providing the 'average current' stays within limits. For example, if 3mA ( 21mA total ) can be sunk continuously, more than that can be sunk if only sinking for half the time. This may however strain the port or pin, is not recommended practice, and one has to accept all risks involved in doing this including potential damage and reduced lifetime.

If one doesn't multiplex a digit at a time but a segment at a time more current can go through the segment and be sunk by each pin staying within its limit. You can increase current through the segment so brighter, but it's then on for less time so swings and roundabouts.

Bottom-line is, if you don't want to faff-about, risk damage, risk ending up with an unsatisfactory ( not bright-enough ) display; use transistors. It's only an extra ULN chip needed. And to avoid inevitable flicker / blanking when display data is updated, use a dedicated display multiplexor chip.
 

BCJKiwi

Senior Member
@ Pilko, if you are switching one module at a time via the common cathodes then they are not on at the same time although they may appear to be via POV - is that what is meant?
 

pilko

Senior Member
BCJKiwi--I realize they are not on at the same time (they just appear to be)
They do however show different numbers,--in the example, "17" is displayed.
 
Top