Go Down

Topic: 5-digit 7-segment LED display on Arduino (Read 11923 times) previous topic - next topic

daolpu

Is it possible to control straight away 5-digit 7-segment LED display with Arduino. Its PIN-out is in atttachment. I have no idea how should I get it to work. I haven't bought it yet, but I must get 5 digit display to show me piece's lenght in tenth of millimeters.
Display is being used in Arduino Mega2560

Paul__B

Easiest way is to use a MAX7219.

Even easier is to buy the module assembled

JChristensen

But yes it is possible. It will require 13 pins (5 to drive the digits, 8 to drive the segments and DP), code to do the multiplexing and external transistors for the digit drivers (the MCU pins can drive the segments directly but probably cannot supply enough current to drive the digits). Oh and 8 external resistors on the segment driver pins.

Nick_Pyner

#3
Oct 15, 2013, 03:33 pm Last Edit: Oct 16, 2013, 01:22 am by Nick_Pyner Reason: 1
Ignore reply #2 above and check here instead

http://playground.arduino.cc/Main/MAX72XXHardware#WiringPrintout

A single 7221 will drive an eight-digit display using power plus three data pins on the Arduino, one resistor and a couple of caps.

You will need the LED Control library.

Note that this is only practical for common cathode displays, so I hope you haven't bought a common anode device, but I'm sure there is something similar for them too.   I have my 20mm 4x7 powered from Arduino but you may need to provide a separate supply if you have big super-bright LEDs. Know the specs, read the power section.



CrossRoads

Looks like a common cathode display to me.
So three options:
Write your own multiplex code as Jack suggests.
Method 1: one cathode low and one anode high at a time, cycye thru all 40 LEDs. Can get by with just 1 resistor for each common cathode.
Method 2: all anodes high/low as needed while one cathode is low. Need a resistor per anode instead. Cycle thru all 5 digits. Will result in brighter display.

Option 3: Use MAX7221/7219, it controls the  multiplexing. Can use a library (the one referenced bit-bangs out the data), or write your own code. Write to 4-5 registers in void setup after turning on SPI, uses '328Ps SPI hardware, way faster.
Then in void loop, write to a register to change a digit.

I usually have an array that holds the 5 digits (in this case) that are manipulated by whatever your code is doing . When a digit is changed, I run the code that updates the display, such as:

Code: [Select]

digitalWrite (ssPin, LOW);
for (x=0; x<5; x=x+1){
SPI.transfer (fontArray[displayData[x]]);
}
digitalWrite (ssPin, LOW);

fontArray[] will hold the fonts for the characters to be displayed
fontArray[] = {
B00111111, // 0
B00000110, // 1
etc  with a 1 bit = an On segment
with Bit 7-6-5-4-3-2-1-0 representing DP-G-F-E-D-C-B-A
and the segment locations defined as
    A
F       B
    G
E      C
    D      DP

and displayData[] holds the 5 digits you are using for time, etc.
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.

JChristensen


daolpu

Thanks for answers. I will buy MAX7221/MAX7219 driver for display.

Paul__B


Thanks for answers. I will buy MAX7221/MAX7219 driver for display.


Way to go!

Nick_Pyner


I will buy MAX7221/MAX7219 driver for display.


Very wise.
I had a bit of a struggle with the software. You might find this useful
http://forum.arduino.cc//index.php?topic=172192.msg1279382#msg1279382
I think I built this up digit-by-digit, so it shouldn't be hard to add a fifth. I get the impression there isn't much interest in multi 7-seg displays, but I wanted something that I could read without glasses while under the shower..

daolpu

I chose MAX7221 driver for display. However I am not sure does I need capacitors for it? And does anybody know how big resistor I need?

JChristensen

I'd get myself a copy of the datasheet.  Some excerpts for your edification:

Quote
Supply Bypassing and Wiring
To minimize power-supply ripple due to the peak digit
driver currents, connect a 10?F electrolytic and a 0.1?F
ceramic capacitor between V+ and GND as close to
the device as possible. The MAX7219/MAX7221 should
be placed in close proximity to the LED display, and
connections should be kept as short as possible to
minimize the effects of wiring inductance and electromagnetic
interference. Also, both GND pins must be
connected to ground.


Quote
Selecting RSET Resistor and
Using External Drivers
The current per segment is approximately 100 times
the current in ISET. To select RSET, see Table 11. The
MAX7219/MAX7221's maximum recommended segment
current is 40mA. For segment current levels
above these levels, external digit drivers will be needed.
In this application, the MAX7219/MAX7221 serve
only as controllers for other high-current drivers or transistors.
Therefore, to conserve power, use RSET = 47k?
when using external current sources as segment drivers




Nick_Pyner


I am not sure does I need capacitors for it? And does anybody know how big resistor I need?


Read my post above. The forward current details should be on the LED data sheet. I used a 33k that was to hand.

daolpu

Thanks. I still have problem to know how big resistor I need because seller only knows input voltage, which is 5V-8V. Is there any common current for red leds?

CrossRoads

Buy several than - 20K, 22K, 24K, 27K, 30, 33k, 37K, 39K
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.

Nick_Pyner


because seller only knows input voltage,. Is there any common current for red leds?


It might be time to trawl eBay for a seller who is more forthcoming about the product. There is no shortage of them.

I understand one red LED is much the same as another, and the power characteristics vary according to colour. I also understand that this stuff is neither critical nor hard to get across. I just used a 33k as it was to hand, more than needed, and resulted in a display that was more than adequate.

Go Up