Go Down

Topic: Arduino MEGA current draw predicament (Read 2616 times) previous topic - next topic

physics-dude

Hi all,
I'm building this larg-ish scale digital clock using a series of six inch incandescent tube lamps positioned in the form of several seven segment displays. Clear-case relays will be controlling the 120v lights (dimmed of course), and some Toshiba TLP621 opto-isolators will be controlling the relays. Finally, an Arduino Mega will be in charge of the opto-isolators.
There will be a seconds unit on this clock, and with that being said, 43 I/Os will be used. However, while only for a few seconds, a maximum of 32 pins will be powered high at any given time.

My concern is whether or not the Arduino will be able to power that amount of opto-isolators (32). Each opto requires 5-10mA, and from what I found, the MEGA can only supply a collective current of up to 200mA.

Another thing I have to mention was that my original plan included the use of 20mA LEDs wired in parallel with the LED side of each of the the 43 opto-isolators (220 ohm resistor included with each LED). I have since omitted these since it would most certainly exceed the current draw of the Arduino. I still have some other indicator ideas for the other side of the optos, but that would require me to order more parts.  Let me know of your opinion about this indicator idea.

Anyway, I simply ask whether or not the Arduino will be happy when powering all those opto-isolators. It's also worth noting that, a 220 ohm resistor will be in series with each one.




Boffin1

I would use 6   TPIC6B595  latch/drivers, you only need 3 pins of the Arduino , and it will give you 48 high power 500mA sink outputs to switch your relays ( it has the 50 volt voltage clamp diodes built in )
The relays will give you the isolation you  need.

I use this arangement for LED displays with up to 20    7 seg numbers.
With my mobile phone I can call people and talk to them -  how smart can you get ?

physics-dude

Quote
I would use 6 TPIC6B595 latch/drivers...


I was looking at those, but there were two problems I thought I may have with them.

First of all, I can't seem to find any decent tutorials for these 595s. They are fairly new to me and I would have to figure out how to convert a numerical value to a specific pattern of I/O to drive each of the relays. I also already have the code figured out for my original idea that didn't require these 595s.

Another issue I just thought of was that I'm using a ChronoDot for the time keeping, and it uses those same clock and latch pins that these 595s would otherwise seem to use and I'm not sure if they would like to share with the ChronoDot.




LMI_at_work

Relays can isolate mains from your device, but you need good quality or special relays to do it safely. Some relays are safe now but not after a month or a year(s).

There are driver chips for your problems. Like ULN2003 and so on, or 2N7000 is driver fet for making it easier for the CPU.

terryking228

Hi, look at some existing relay boards that you could definitely drive from a MEGA:

Like these: http://goo.gl/3mXu0 

Look at the schematic for one here: http://goo.gl/Nnt9g 

These only need 2 to 3 ma per pin for the Arduino to "sink".  They include an LED per channel so you can test easily. 

NOTE: These are "Active low" controls, for good reasons. See the ArduinoInfo WIKI: http://arduinoinfo.info (Relay info here: http://arduino-info.wikispaces.com/ArduinoPower#4-8)

Information on Arduino Pin Issues here: http://arduino-info.wikispaces.com/ArduinoPinCurrent

The seconds display will change 86400 times a day. If this is going to run 24-7 for a long time, you may want to use Solid State Relays for the seconds digits (or at least the 1-second digit). Example here (but you could use smaller ones): http://goo.gl/QhgNO

Can you point to the lamps you will be using? Where can you get them?? Sounds cool... 

Let us know who you are doing, feel free to ask more questions...


DISCLAIMER: Mentioned stuff from my own shop...
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

CrossRoads

Mega can handle 800mA - 200mA per VCC or Gnd pin.

DC Current per I/O Pin ................................................ 40.0mA
DC Current VCC and GND Pins................................. 200.0mA

There are limits within any one port:

3. Although each I/O port can sink 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 IOL, for ports J0-J7, A0-A7, G2 should not exceed 200mA.
2.)The sum of all IOL, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA.
3.)The sum of all IOL, for ports G3-G4, B0-B7, H0-B7 should not exceed 200mA.
4.)The sum of all IOL, for ports E0-E7, G5 should not exceed 100mA.
5.)The sum of all IOL, for ports F0-F7, K0-K7 should not exceed 100mA.
If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater
than the listed test condition.

4. 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.

So if you have all 8 pins in a port sinking/sourcing 10mA, 80mA total you'd be fine.
Splitting your 320mA across four 200mA capable ports, you'd be fine.
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.

CrossRoads

I'd also consider replacing the bulbs with ultrabright LEDs instead. Using 15,000mcd whte LEDs drawing only 20mA each, arranged as strings of 3 or 6 or 9 per digit and driven from 12V with ULN2803 as the buffer, would be quite bright also and use less energy.
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.

physics-dude

#7
Aug 23, 2012, 04:49 pm Last Edit: Aug 23, 2012, 05:22 pm by physics-dude Reason: 1

I'd also consider replacing the bulbs with ultrabright LEDs instead. Using 15,000mcd whte LEDs drawing only 20mA each, arranged as strings of 3 or 6 or 9 per digit and driven from 12V with ULN2803 as the buffer, would be quite bright also and use less energy.


This clock is more of a novelty. The incandescents and relays are a key part of the design.
Also, the input waveform for these frosted 130v 60Hz bulbs will be chopped thanks to some household light dimmer(s). This will maintain a comfortable brightness for a kind of warm look.

physics-dude

#8
Aug 23, 2012, 05:22 pm Last Edit: Aug 23, 2012, 05:25 pm by physics-dude Reason: 1

Can you point to the lamps you will be using? Where can you get them?? Sounds cool...  


The bulbs I'm using are the 130V 20W frosted T6-1/2 w/ intermediate base (E17)s.
I found mine on Ebay.




CrossRoads

I've seen LEDs in ping pong balls for similar effect.
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.

physics-dude

Quick update,
Now that I have everything in hand, I decided to not include the planed seconds unit on this clock. I might instead replace it with a small pair of LED seven segment displays. If not that, then perhaps a single LED "ticker" that blinks every second.

Just to be sure, if I put a combined 580mA worth of LEDs and opto-isolators on the I/Os of the MEGA with less then 20mA each on each I/O pin, everything should be fine, right?



CrossRoads

As long as you don't exceed the per-port current limits.
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.

Boffin1


   

Quote

I would use 6 TPIC6B595 latch/drivers...
I was looking at those, but there were two problems I thought I may have with them.
First of all, I can't seem to find any decent tutorials for these 595s. They are fairly new to me and I would have to figure out how to convert a numerical value to a specific pattern of I/O to drive each of the relays. I also already have the code figured out for my original idea that didn't require these 595s.
Another issue I just thought of was that I'm using a ChronoDot for the time keeping, and it uses those same clock and latch pins that these 595s would otherwise seem to use and I'm not sure if they would like to share with the ChronoDot.



The TPIC6B595 is the same as a 595 serial register, but has a built in LED/relay driver ( like a ULN2003 )

You can use any 3 pins to drive them, using Shiftout,  and to set up the segment pattern I define a lookup table ( before the setup ) which looks like this for the pin connections I use from the TPIC to the segment :-

Code: [Select]
#define latchPin 11  // rck  the pin you choose to go to the latch input of the TPIC
#define clockPin 10  // sck   the pin you choose to go to the clock input of the TPIC
#define dataPin 13  // ser in   the pin you choose to go to the serial  input of the TPIC

const byte digitTable [10] = { // the patterns of segments for numbers 0 to 9 
B11101110, B00101000, B10110110, B10111100, B01111000, 
B11011100, B11011110, B10101000, B11111110, B11111100};

// and then at the end of the sketch when you want to display the data you just send something like :-

digitalWrite(latchPin, LOW); 
delay ( 50 );

  shiftOut(dataPin, clockPin, MSBFIRST, digitTable [ mintens ] );  // you can also have seconds if you like,
  shiftOut(dataPin, clockPin, MSBFIRST, digitTable [ minunits ] );
  shiftOut(dataPin, clockPin, MSBFIRST, digitTable [ hourtens ] );
shiftOut(dataPin, clockPin, MSBFIRST, digitTable [ hourunits ] );

digitalWrite(latchPin, HIGH);
  delay ( 50 );


The TPIC has a latch, so you dont have to refresh the display ( and you can take a video of the display without the scrolling bands moving down )
With my mobile phone I can call people and talk to them -  how smart can you get ?

physics-dude

#13
Aug 27, 2012, 06:36 am Last Edit: Aug 27, 2012, 06:56 am by physics-dude Reason: 1
Ok, slight problem.
I just finished all the main circuitry for the build with only the incandescents left to wire up.
I've been running my example sketch throughout the build, it ran through each segment's output one at a time with no problems.
Now here's the problem I was worried about, I edited the sketch to turn on each output one at a time with an interval of about 200ms. After a very brief time with all 28 I/Os on, the 5v regulator overheats and shuts down. :(

I figured that the problem could very well be because I'm running  the poor thing off Arduino's maximum rated voltage of 12 volts. So I swapped the 12v supply for a 9v one. Results were better this time in that it did not overheat as quickly, however I shut it down after I clocked the PCB temperature underneath the regulator at a blistering 185F (85C). I don't really have any wall power supplies under 9v, nor would I like to use a second one next to  the already necessary 12v one, so I'm now wondering if there might be an alternative regulator I could use that would accept the 12v input.

On the other hand, the ATmega2560 seems to accept the LED and opto load just fine.


Edit:
I just found myself a regulated 5v power supply. I paired it up with the 5v rails on the Arduino and everything seems to be getting along just fine... For now.  :smiley-mr-green:

CrossRoads

Yes, 5V wallwarts are nice!

I have some 7.5V, 1000mA wallwarts for the times I want to use the barrel jack connector.
Not sure where I got them from tho, I don't see them at the site I expected.
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.

Go Up