Go Down

Topic: 4-digit display made from minimal parts (Read 2715 times) previous topic - next topic

Feb 03, 2012, 07:49 am Last Edit: Apr 29, 2012, 11:08 pm by Nick Gammon Reason: 1
After the recent discussions about doing LED displays with a minimal number of pins (and parts) I experimented with this:



By arranging the shift registers adjacent to the LED it was possible to keep wiring to a minimum. So you only need 3 wires (MOSI, SS, SCK) from the Arduino to the board (plus 5V and Gnd).

The actual displaying is done by a timer interrupt routine, so you can be doing other things in your sketch while the display is updated automatically. The whole thing is quite cheap, the registers are under a $1 each, and the LED was about $3.

Schematic:



More details including example program code here:

http://www.gammon.com.au/forum/?id=11524

It would be possible to add another LED with another two shift registers (I've put a dot on the board where pin 1 would go) so as to extend the number of digits to 8.

(edit) As discussed further down this thread, current limiting resistors would be advisable for the health of the LEDs and ICs. (April 2012).
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Graynomad

So you got it done, did you use a resistor safety net until the code worked or go for broke?

How about a video, there's something quite therapeutic about watching LEDs count :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

#2
Feb 04, 2012, 12:21 am Last Edit: Nov 26, 2013, 12:41 am by Nick Gammon Reason: 1
I decided not to use resistors in the end, "live recklessly", I thought. :)

If it looked too bright I was going to unplug it quickly. A quick check with the logic analyzer seemed to show that the SPI data was being clocked out at about the right rate. In fact, it was far too slow, with the segments lighting up briefly and then with a lengthy pause between them.

I did some tweaking "by eye" to get the segments to look "not too bright" but not flicker either.

This is what it looks like:

http://vimeo.com/80323374

There is a slight flicker, you can eliminate that by increasing the interrupt fire rate. ie. change:

Code: [Select]
 OCR2A  = 124;            // count up to 125  (zero relative!!!!)

to something like:

Code: [Select]
 OCR2A  = 59;            // count up to 60  (zero relative!!!!)
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

scswift

So how does this work?  Not using resistors for the LEDs I mean.  What's limiting the current that the Arduino is putting out? 

Well the theory is that you are delivering higher current than it should get, for less time. So the average is OK. The Lots Of Leds shield, for example, doesn't have resistors.

Measurement appears to indicate that a particular segment is on for 4 mS and off for 17 mS (depending on what you are displaying of course) so that is 4/23 "on" duty cycle, or 17%.

There is a limit to how much the chip can deliver (say, 40 mA) so we are on average supplying 17% of 40 mA, namely 6.8 mA.

I can't find a definitive proof of this, maybe the electronics engineers here might like to comment?

I think the problem place is really the "sink" pins, because they would have a duty cycle of 25% (as they rotate from digit to digit). However I built in a "blanking" period of 8 cycles (8 mS) when all the pins are held low, and thus won't conduct anything. So they, too, should get a rest.

If you greatly increase the blanking time, eg.

Code: [Select]
const byte TIME_BETWEEN_DIGITS = 100;  // blanking period between digits in loop iterations

... and then make the timer fire faster to remove flicker:

Code: [Select]
  OCR2A  = 9;            // count up to 10  (zero relative!!!!)

... then the LEDs are noticeably dimmer (but still readable) and there is no noticeable flicker (although I do notice a slight flicker every 10th of a second which is when interrupts are turned off to update the counter).
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

scswift

Quote

There is a limit to how much the chip can deliver (say, 40 mA) so we are on average supplying 17% of 40 mA, namely 6.8 mA.

I can't find a definitive proof of this, maybe the electronics engineers here might like to comment?



See, that's what I want to know.  As far as I'm aware, the 74HC595 has an absolute maximum rating of 35mA per output pin.  But that doesn't mean it will stop when it hits 35mA.  That just means if you try to draw more than that you'll fry it.  I think the actual amount of current it will output would be limited only by whatever resistance there is in the chips, wire, and battery, and that would be fairly small.

Have you tried connecting a multimeter up to see how much current it says is flowing through any particular pin or led?  Maybe measure the sink side that is at a 25% duty cycle to get the most accurate measurement?

I guess if the leds aren't really bright then the amount of current must be being limited somehow.  The question is whether it is below the maximum ratings of the chip per output and for the whole chip.  Even a 17% duty cycle would explode the leds if the chip was drawing 500mA.


Right, well it's a bit hard to measure because the output pins are soldered directly to the tracks on the PCB.

But to try to get an idea, I broke the wire leading to the entire 74HC595 chip's Vcc pin, and measured the current on that. Presumably no output pin will source more current than the chip itself consumes. :)

On the original sketch I measured:

Code: [Select]

Peak current:      38.6 mA
Average current:   14.5 mA


With the modified sketch I mentioned (where the LEDs were dimmer because of a lower duty cycle) I got:

Code: [Select]

Peak current:      38.6 mA
Average current:    2.5 mA


So we seem to be in the reasonably safe ballpark. Even the peak current seems to be acceptable (assuming you can average it over a few pins), and that would only be at that level for a couple of milliseconds before the blanking period cut in.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

ghoti

Hi Nick,

I have been playing with a similiar subject... and I too have found this a nice neat solution, with an added bonus... the led display becomes a sort of indicator.. as long as you can see more than one digit, the code is running :-) as a result, i dont bother with heartbeat leds when I use this solution.

Quote
I decided not to use resistors in the end, "live recklessly", I thought. smiley

I am using common anode leds so i went with resistors, but with common cathode why not? :-)

Thank you for sharing this post - nicely done.

Thanks!

The exact same circuit should work for common anode if you change:

Code: [Select]

// send to shift registers
  digitalWrite (LATCH, LOW);
  SPI.transfer (highByte (output));
  SPI.transfer (lowByte (output));
  digitalWrite (LATCH, HIGH);


to:


Code: [Select]

// send to shift registers
  digitalWrite (LATCH, LOW);
  SPI.transfer (highByte (output) ^ 0xFF);
  SPI.transfer (lowByte (output) ^ 0xFF);
  digitalWrite (LATCH, HIGH);


That inverts the sense of all the voltages and therefore should work "the other way around". Untested though.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

ghoti

Surely for common anode, resistors are a bit more important?
I only ask as my understanding is, that the current will see path of least resistance and may accelerate degredation of the segments, or uneven illumination as each digit only has one source.

with common cathode, you dont have this problem as each segment is sourced individually.


Huh? I'll let my electronics experts friends respond to that, but as far as I am aware, it's just like turning an LED around. Providing you also turn the current around "the other way" it should be the same.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

gcm2

Thank you for this  :D

I'm basically follwwing your wiring diagram on a breadboard for my first 7Seg LED project. Here's my display: http://www.mouser.com/ProductDetail/Avago-Technologies/HDSP-B47G/?qs=pQfy5%252bKCabKXVtjwmOMFxg%3d%3d

I have it wired up (not exactly like your diagram) and segments displaying OK (at least I can see them working - of course all 4 digits show the same thing right now), although I haven't figured out the common cathode pins yet.

I have a newbie question which I have not seen asked - how do you manage to show the individual digits without using transistors? Bear with me - I've been reading all I can for a week in this subject, and everything else I see uses a transistor hooked up the each of the common cath pins to display each digit in multiplexing.

Thank you!

The shift register can source and sink a bit of current (something like 20 mA) and by multiplexing it is only doing a segment at a time (or thereabouts).

So basically rather than using a transistor to boost the current output, and then a resistor to limit it again (because the LEDs don't need that much) the simpler system is just to briefly send a bit of current to each LED.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

gcm2

Thanks sir! Here is my (drum roll) implementation of your circuity on a breadboard! Thanks for your inspiration and help! I used your coding with some minor modifications. This is my first 7Seg LED, and first usage of shift registers. BTW - I did have 220 ohm resistors hooked up in series from the shift registers to each segment in the display to begin with, but I removed all of them to try out your method.



Grumpy_Mike

Quote
Well the theory is that you are delivering higher current than it should get, for less time. So the average is OK.

Nick, no, no no.
It is the peak current that is important not the average current when considering component ratings. Have you not read my page:-
http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

Quote
The Lots Of Leds shield, for example, doesn't have resistors.

So that makes it OK then? Or does it make it yet another circuit designed to destroy components?

Go Up