Go Down

Topic: Arduino Mega with double 7 segment display (Read 7392 times) previous topic - next topic

Rovers

Hello everybody!
I am Daniele, a completely new user of Arduino and programming in general. Probably I haven't choose the easyest project to work on as a starting point but I like new challenges and learning with experience.

I have got an Arduino Mega 2560 and I am trying to connect it to a double 7 digit display in order to display some values that from a determined website. Obviously before entering the "go on the internet and print me this value" part on the code I would be please if I could at least make the arduino display any predetermined double digit value on the display. So far through tutorial I have only managed to work on 1 digit at the time to display values from 0 to 9, now its time to step it up. I am attaching a list of specs and my connections.
Basicly I am considering each segment as a separate LED and connecting it through a 220Ω resistor to an arduino Pin. I am aware there is probably a way simplier approach through the use of other transistor or chips but since my knowledge of eletronics and coding is absolutely zero I though about trying to use less components as possible.

Can someone give me some guidelines on where I should start the coding for this?
I imagine I will need to define what segment to turn on in order to display each number but besides that I am pretty lost, expecially once I pass number 9.

Thanks a lot to whoever can help me out!


PaulRB

#2
Feb 23, 2016, 12:07 am Last Edit: Feb 23, 2016, 12:29 am by PaulRB
http://www.hobbytronics.co.uk/arduino-4digit-7segment
That is a bad example in my opinion. It uses no series resistors and claims that by using pwm they are not needed. It is also badly written code.

Daniele, i can help you with some code tomorrow evening, if you still need it.

Paul

ieee488

That is a bad example in my opinion. It uses no series resistors and claims that by using pwm they are not needed. It is also badly written code.

Daniele, i can help you with some code tomorrow evening, if you still need it.

Paul
There's probably a better one out there.

The point is to do some research by Googling.


Rovers

That is a bad example in my opinion. It uses no series resistors and claims that by using pwm they are not needed. It is also badly written code.

Daniele, i can help you with some code tomorrow evening, if you still need it.

Paul
That would be amazing Paul, in the meantime I am also trying a different layout in which all same segments of each digit are connected to each other and then to the arduino. Basicly trying to replicate this layout (check attachment). Let me know which one do you think would be the easiest to code!

There's probably a better one out there.

The point is to do some research by Googling.


I tried googling but I have been struggling with finding a clear example with a double digit display, most of them are single or 4 digit and only act as counters or clocks.


CrossRoads

That method will work. If you cycling thru all 14 segments one at a time, then you just need 2 current limit resistors on the 2 common cathode pins.
The code checks for a1 on, cathode 1 on, etc thru a7 on, cathode 1 on, then b2 on , cathode 2 on etc thru b7. 
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.

Rovers

So, just to clarify to whoever is going to help me, these are the 2 design I am working with. Which one do you recon will be easier to code? Please bare in mind that for the final project I will have to effectivly double everything as I need to connect a second DOUBLE digit display.

Thank you very much guys!

PaulRB

#7
Feb 23, 2016, 01:36 pm Last Edit: Feb 23, 2016, 01:56 pm by PaulRB
"Data sheet":

You have not actually told us which type of display you have. The above diagram shows two versions: common cathode and common anode. Your designs below indicate you have common anode. Is that correct?

Design 1:

(You made a mistake there. You need to connect the common pins to 5V, not Ground)

Design 2:


PaulRB

So, just to clarify to whoever is going to help me, these are the 2 design I am working with. Which one do you recon will be easier to code? Please bare in mind that for the final project I will have to effectivly double everything as I need to connect a second DOUBLE digit display.
Your first design is easier to code because it does not involve multiplexing. The downside is that it uses almost twice as many Arduino pins.

Your second design uses fewer pins but will make the code more complex because multiplexing will be needed. Also, the display will be significantly dimmer, because the multiplexing ratio will be 1:8 (i.e. each segment will be on for only one eighth of the time. You can compensate a little for this by reducing the value of the series resistors, but you must not go so low that the Arduino pins have to source more than 40mA (30mA would be better in the long term).

For 4 digits, your first design will require 32 arduino outputs, but the code will still be simpler. Your second design will only require 12 outputs.

There are other options too. Chips and modules are available which will perform the multiplexing for you, and/or reduce the number of Arduino outputs needed. These include 74hc595, tpic6*595, max7219, saa1064...

Rovers

#9
Feb 23, 2016, 02:10 pm Last Edit: Feb 23, 2016, 02:40 pm by Rovers
Thanks for the reply Paul, everything is starting to make sense. At this point I think I might go with the first design since it will be easier to code. I am not worried about the number of pins since the Arduino mega has plenty of them. I just double checked and my display is the LB-602MK2 so it is COMMON CATHODE according to this datasheet. http://rohmfs.rohm.com/en/products/databook/datasheet/opto/led_display/numeric/lb-602ak2.pdf

I tried to correct the first design for a common cathode display, does this look right?

I considered the multiplexing option because I read somewhere that powering a total of 4 digit display would drain to much power from the arduino, are you saying I should actually be fine with multiplexing?

Thanks again!

CrossRoads

Oh, so you're up to 4 digits now? Then a MAX7219 to control them would be easier to code for. It takes care of the multiplexing, you just put data into 1 for 4 registers with simple commands, such as SPI.transfer(), or shiftOut():
Code: [Select]

digitalWrite (csPin, LOW);
SPI.transfer (addressRegister); // 1 to 8 for digit select
SPI.transfer (dataToDisplay); // built in font decode handles 0-9, -, blank, H,E,L,P, or send your own
digitalWrite (csPin, HIGH);

$3 at www.taydaelectronics.com, add 0.1uF cap and 10uF cap, 10K current limit resistor.
MAX7219 drives high on the common segment pins, and one common cathode low at a time, to turn a digit on.
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.

CrossRoads

Your Rev3 design will work as well, be sure to observe the current limit per pin (20mA) and per port:
Code: [Select]

Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady
state conditions (non-transient), the following must be observed:
ATmega640/1280/2560:
1)The sum of all IOH, for ports J0-J7, G2, A0-A7 should not exceed 200mA.
2)The sum of all IOH, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA.
3)The sum of all IOH, for ports G3-G4, B0-B7, H0-H7 should not exceed 200mA.
4)The sum of all IOH, for ports E0-E7, G5 should not exceed 100mA.
5)The sum of all IOH, for ports F0-F7, K0-K7 should not exceed 100mA.
If IOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.
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

#12
Feb 23, 2016, 09:45 pm Last Edit: Feb 23, 2016, 10:07 pm by PaulRB
As Crosroads says, the design is ok but as you suspect, there is potential to use quite a lot of current. But this can easilly be adjusted down using the right value series resistors. 5mA per segment might be enough. The forward voltage of your green segments is 2.1V, so series resistors should be around (5 - 2.1) / 0.005 = 500R so 510R is the closest common value.

Do you still need some help with code?



Rovers

#13
Feb 23, 2016, 11:56 pm Last Edit: Feb 24, 2016, 02:24 am by Rovers
The forward voltage of your green segments is 2.1V, so series resistors should be around (5 - 2.1) / 0.005 = 500R so 510R is the closest common value.

Do you still need some help with code?

Isn't (5 - 2.1) / 0.005 = 580? Should I use 510Ω or 580Ω resistor? I have 220 and 330, is it entire blasphemy putting them in series to get 550Ω? I am just wondering since I had to order them from the internet as I couldn't find a place around here to buy them for a decent price.

Yes, help with the code would be much appreaciate!
Thanks

PaulRB

#14
Feb 24, 2016, 07:38 am Last Edit: Feb 24, 2016, 07:39 am by PaulRB
Sorry, yes, i must have been tired, its 580R. Yes, you can use 330+220R, or just use 330 R for now. 330R will mean (5-2.1)/330=8.7mA per segment and 281mA overall for 4 digits (including decimal points). This will be ok for the Mega as long as you spread the load around as per Crossroads' extract from the data sheet. You can experiment with series resistors from around 100R and 1K to see how bright you want the display, but with lower values, watch those currents!

So for now it will just be 2 digits? Connect it up and post the pin numbers you have used for segments "a" to "g" for each digit. I will try to give you a bit of starter code this evening (assuming my internet connection does not go down for half the evening like it did yesterday!).

Go Up