Go Down

Topic: Can I drive 16 x 7-segment (or 8 with DP) displays, with no shift register? (Read 3523 times) previous topic - next topic

fatcharlie

Apolodies if a duplicate post - searched "16 x 7-segment display" but got nothing :-)

Does an Arduino Mega, with its extra pins, allow multiplexing of 16 x 7 Segment displays without having to use a shift register?

This would be its only job (at first, anyway...)

As I see it, it would need 8 outputs for the leds in the displays, then 16 more for the common cathode/anodes for the displays.

That would mean 24 outputs - the Mega has 54 I/O pins, so it would seem enough. But every tutorial I see online has the board using shift registers to drive the displays - is it a programming issue, or is it simply that the tutorials waht to teach the use of shift registers?

So, could i use a Mega to drive 16 x 7 (or effectively 8) segment displays?

Thanks,

Roger.


Paul__B

You need two MAX7219s.

(it does not matter whether the displays are common anode or common cathode; but programming is easier with common cathode.)

Doing it any other way involves a ridiculous amount of mucking about with transistors to achieve a reasonable driving current.  Simple as that.

fatcharlie

Ah. Electronics.

Hadn't thought of the current issue. Thanks for the very useful input :-) Transistors are scary. I've only just come to terms with resistors...

The Max7219 seems to be specifically designed to drive LED displays, rather than a shift register per-se?

Thanks again,

Roger.


Grumpy_Mike

The Max7219 seems to be specifically designed to drive LED displays, rather than a shift register per-se?
Inside the MAX7219 is a shift register along with all the other stuff to do the multiplexing and decoding. So I do not understand that comment.

If electronics scares you then you are not ready to do this project yet.

Paul__B

If electronics scares you then you are not ready to do this project yet.
Well.

The MAX7219 looks like a set of shift registers to drive - like shift registers, you parallel the clock and latch, and ripple the data from one MAX7219 to the next.

I shan't go further into the detail - it is of course, all in the datasheet and if you take the hint, you will simply proceed to obtain some.  Some people have had problems with them from eBay but in general, they are an inexpensive (but slow) source.

The point really is - the MAX7219 performs the whole job of driving eight 7-segment displays.
  • It includes of course, the decimal points.
  • Eight digits per chip.  Two chips for sixteen digits.
  • It performs the current control.  One resistor (per chip) sets the current for all segments.  No other components.  (You do need two decoupling capacitors per chip.)
  • It performs the multiplexing.  You set the data and do nothing else in your code until you need to alter the data displayed.
  • For common-cathode displays, it will decode the patterns for characters 0 to 9 (and "H", "E",  "L",  "P" and "-").  For common anode displays or alternate characters, you figure out how to feed in the patterns.

PaulRB

Hi,

Transistors are not as scary as you think. Just think of them as tiny switches or relays, which allow an arduino pin to switch on and off a larger current than it could cope with alone.

You could do your circuit as you described, with 8 ordinary transistors and 8 resistors. This won't be as bright as using max7219, and will need 24 Arduino pins instead of 3, and the sketch will be more complicated, but it should work. It might be more a more interesting learning experience at your current stage of experience, giving you an appreciation of some of the things that are going on inside a chip like max7219.

Tell us more about your displays, if you already have them, and which way you want to go (max chip or transistors).

Paul

fatcharlie

Thanks Paull__B and Paul RB - helpful advice and positive suggestions.

Grumpy_Mike I can see where you get your 'handle', lol. The very fact that I want to learn means I _am_ ready for this project.

Electronics doesn't really 'scare' me as such, it was just a turn of phrase. The most scared I've ever been was in the Bay of Biscay in a small yacht, leaking badly, with water up to my shins in the cabin. That was scary.

Now, Pauls - I'll have a think about which way to go - cost is the overriding factor so I'll price up a few things.

Does either of you know anything about 'Funduino' boards - an Arduino clone available with what seems like a good started pack?

Thanks,

Roger.

PaulRB

I have several of the clone boards, including at least one "Funduino" and have had only one with a significant problem. Even with that one, it works for 99% of circuits, but won't work with nrf24l01+ radio modules for some reason, maybe I damaged it in some way, I'll probably never know!

If you have not already purchased the Mega, I would go with a smaller Arduino and get a couple of those max chips as Paul__B suggests. Its technically a better solution, thought in some ways you might not learn as much basic stuff using them, because they take care of a lot of things for you (multiplexing, current limiting etc.).

FYI, my suggestion of using only 8 transistors with 16 digits might seem odd if you look at similar circuits on the net. The reason is that I was going to suggest multiplexing by segment rather than by digit. Most multiplexing strategies tend to light one digit at a time, lighting all the required segments on that digit together, and then moving on to the next digit (and of course doing all this so fast that it appears to the eye that all digits are lit). Multiplexing by segment means lighting all (up to 16) required 'a' segments together, then all required 'b' segments, then all required 'c', then 'd', 'e' & 'f' together. Hope that makes sense.

Paul__B

That is of course the principle.  If you are going to multiplex, you want to devote as much of the time as possible to each "row" that it turned on, so if your array is 16 by 8, you want to power each set of 16 for one eighth of the time, rather than each set of 8 for one-sixteenth of the time.

fatcharlie

Hello again Pauls. Sorry for the long delay. Funds precluded the acquiring of an Arduino till now.

I've had a go at this Instructable:

http://www.instructables.com/id/Arduino-4-digit-7-segment-display/

It's taught me a lot about the way things work.

If I can afford it this month I'll probably buy the two MAX7219s and multiplex using them. I like the idea of multiplexing the segments rather than the digits - can you explain a bit more about the way you'd write the sketch for that?

One thing with the Instructable above is that there's a noticeable delay between pressing the enter key and the new digits appearing on the LCDs. Is that normal? I'd be using the card to show values for Heading, Speed, Altitude etc. on my B737 simulator. When i turn the relevant knob, these values can change very rapidly - if I used something similar to the example above, a long delay would kinda negate the point.

I hope to use the fantastic program Link2fs_Multi_FS9_V2, available free from

http://www.jimspage.co.nz/intro.htm

His examples show no delay even though using the same Serial.begin command.

All advice gratefully received.

Thanks,

Roger.

CrossRoads

$3.09 for MAX7219 from taydaelectronics.com. Order 10uF cap, 0.1uF cap, and 10K resistor for each one at the same time.
I just bought 20 chips myself.
The chip do all the multiplexing for you as described earlier - you just send it two bytes, the register # and the data to be displayed. Then your code is free to receive other messages via serial, read buttons, etc. and update the data that needs to sent to the max7219s for display.
I use SPI.transfer to do it:
Code: [Select]

digitalWrite (csPin, LOW);
SPI.transfer (registerNumber); // 01 to 08 for digit 1 to 8
SPI.transfer (dataToDisplay);
digitalWrite (csPin, HIGH);

Using SPI.transfer at default 4 MHz speed works just fine.
I used 4 of them with 4 8x8 LED matrices (vs 32 digits) with a chipselect for each max7219 to make the coding a little more straightforward. Others use a slower max7219 library that fakes the SPI.transfer in software.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

PaulRB

Hi again Roger,

I've had a go at this Instructable:

http://www.instructables.com/id/Arduino-4-digit-7-segment-display/

It's taught me a lot about the way things work.

Oh no, not that one again. Lets hope you haven't damaged your new Arduino already. That instructable may have also taught you how things get damaged, and... not to trust instructables!

If I can afford it this month I'll probably buy the two MAX7219s and multiplex using them. I like the idea of multiplexing the segments rather than the digits - can you explain a bit more about the way you'd write the sketch for that?
If you are using max7219s, you will be multiplexing by digits, or rather, the max chips will be doing it for you. The multiplexing by segments was just a suggestion for if you were going to multiplex using only the Arduino's outputs (plus a few transistors to avoid overloading them - just like that instructable doesn't)

One thing with the Instructable above is that there's a noticeable delay between pressing the enter key and the new digits appearing on the LCDs. Is that normal?
Don't worry about it, the displays will update far faster than the eye can see, if you write your sketch properly (we can help you with that). Are you getting LEDs and LCDs confused or was that just a typo?

I hope to use the fantastic program Link2fs_Multi_FS9_V2, available free from

http://www.jimspage.co.nz/intro.htm

His examples show no delay even though using the same Serial.begin command.

He's obviously a good software developer to have built that app and integrated it with the flight simulator. But he may have a thing or two to learn about Arduino hardware: he suggests using multiple Arduinos, where only one would be needed.

fatcharlie

Hi Paul, Crossroads,

Once again thanks for the help.

Ah. The Instructable. I hope I haven't damaged the board - I only set up two digits to test my understanding of the logic. How would I tell if it's damaged?

I've ordered the max7219s and capacitors. I already have the resistors.

Yes it was a typo (or, rather, a 'brain-o') and I did mean LEDs!

So far, I understand how a shift register works, at a basic level. If my understanding is correct, you serial the data in to the register, then once you have it there you trigger the output, which activates the output in parallel to the pins you specify.

For multiplexing 7-segment displays, each time you latch, a different common cathode/anode is activated so as to light one digit at a time. This happens so quickly that it seems as if they are all lit simultaneously.

In order to drive multiples of 8 digits, the shift registers are linked in series - the 'data out' pin of one register being connected to the 'data in' pin of the next.

I assume at some stage this 'daisychain' of registers would create too much delay - as an extreme examle, if you wanted to drive 800 displays from one Arduino, you'd need 100 max7219s. Surely the sheer amount of data would cause delay? A silly example I know, but just checking!

Once the parts have arrived, I can start experimenting with a breadboard. In the meantime, some guidance on how to write a sketch would be much appreciated.

Many thanks,

Roger.




PaulRB

To test your Arduino for damage, you could run the "Blink" example sketch for each of the pins you used during the instructable, using a 200~300R series resistor and an ordinary led. Try it with the led/resistor connected to 5V and GND. If that all works, any damage is probably minor. Its the pins that were connected to the digit common lines on the display that are more likey to have been damaged, because they got badly overloaded, being forced to provide current for 7 or 8 leds at once with no series resistors to limit the current. That instructable should be deleted!

Also test your display, using the 5V and GND outputs from the Arduino and that 200~300R resistor. Test each segment will light with equal brightness.

Regarding your questions about how many shift registers/max7219 you can connect in a chain before speed becomes a problem. You are correct, but the number is quite large. The clock speed these chips can accept is probably 10 to 30 MHz or more. That's 10 to 30 million bits per second. The Arduino's maximum output, using its special SPI pins, is 8MHz. Other factors like propagation delays and fan-out limits will reduce this, but the point is that in practice, hobby users like ourselves will probably never get near those limits.

For instruction on how to use the max7219 chips and write sketches with them, have a look on the Arduino playground. I think they all use an Arduino library called LedControl. You can quite easilly control max chips without that library, but I suppose its helpful for beginners.

Notice that you don't need to use series resistors when using the max7219. This is because the chip's outputs have what is known as "constant current drivers" which limit the current to safe levels. That's not true of most chip output pins, like Arduino pins and 74hc595 shift register pins. Usually you need those series resistors.

fatcharlie

Thanks, will do. (check the board that is)

Go Up