piggybacked arduinos

I just had a brainwave. Everybody always complains about the 40mA limit on I/O pins, so could one plop a second chip on top of the original and have twice the current / pin? Presumably the timing would be the same and everything, perhaps uploading code might screw it up. Has anyone done this, and if not, why not?

kevin

In theory, it works.
For real, I am sure it will not stay in sync.

Yeah. I've been coming up with ways of getting around sync issues (program each separately, have a serial connection keeping them in sync, etc), but eventually it comes to the point where it's much easier to just have pop in some transistors where necessary.

and if not, why not?

Because it's not a very good idea for several reasons. One of which is
because it's simpler and safer to just use switching transistors if the voltage or current is too high for a standard AVR output pin. Making it 80ma would still not protect the two devices if one doesn't use series current limiting resistors with their LEDs, and you will have two bad avr chips on your hands. Also a transistor that can handle 100ma costs maybe a dime, a AVR 328 chip cost $6, so your choice 60 transistors or one avr chip?

Lefty

Also a transistor that can handle 100ma costs maybe a dime, a AVR 328 chip cost $6, so your choice 60 transistors or one avr chip?

Not only that, but (I haven't dug into the datasheet to confirm this, tho) doesn't the outputs use some from of BJT (and not FET)? From what I understand, paralleling BJTs doesn't really work well...

On a different note - if you wanted to keep two or more ATMegas in sync, you would use an external clock circuit, then reprogram the fuses on the ATMegas to utilize the external clock input. Provided you kept your paths from the clock to the processors close to the same length, in theory they should be completely in sync (plus/minus some small percentage, I'm sure).

in theory they should be completely in sync

Unless they make decisions based on anything fuzzy like an analogue input, in which case all bets would be off.

If one reads 1000 from the ADC and the other reads 1001 and the code says

if (adc > 1000)
  digitalWrite (5, HIGH);
else
  digitalWrite (5, LOW);

Oops :slight_smile:


Rob

I believe that reset timing (including oscillator startup time) is based on internal RC timing that is not particularly calibrated, and the brownout detect (to move a chip out of reset) is nor particularly accurate either. I wouldn't expect two parallel AVRs to start at exactly the same time (though it might be reasonably easy to synchronize that part.)

Wouldn't it be a waste?

I'm not even going to comment on the technical side of that. But getting a 6$ microcontroller to supposedly use 40 mA in one pin is just... well... not economically wise.

Plus, I don't understand where this idea about the 40mA per pin comes from. I know you're gonna tell me to look in the manual.... Well, have you?

The manual states 40 mA as an Absolute Maximum Rating and even goes out to say this:

"Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent dam- age to the device. This is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability."

Which, in practical terms means that if you design anything to use repeatedly 40 mA on a pin you're gonna make Atmel very happy by selling more chips to you.
If you read carefully, you'll find this:

"Although each I/O port can sink more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed: ATmega48/88/168: 1] The sum of all IOL, for ports C0 - C5, ADC7, ADC6 should not exceed 100 mA. 2] The sum of all IOL, for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100 mA. 3] The sum of all IOL, for ports D0 - D4, RESET should not exceed 100 mA. 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."

So why not just buy a transistor, or a transistor array?

So why not just buy a transistor, or a transistor array?

Well, for one thing, the IO pins have push/pull outputs that can sink or source current, or be high impedance. To duplicate this with external circuitry requires at least a "half H-bridge" per pin, and gets complicated pretty quickly.

Hmm. I didn't want to use this for something, I was just curious what would happen.

Oops Smiley

;D

I'm going to stick by what I have said in the past. The AVR chip is the BRAINS not the MUSCLES. You want MUSCLES, add peripherals... Like transistors or driver IC's.

Why does everyone seem to have this idea that this simple little micro-controller can or should do everything without adding hardware... yet have a good understanding that more hardware is needed when comparing and IPOD driving an earpiece and a 100W at home stereo driving massive speakers just baffles me.

Unless they make decisions based on anything fuzzy like an analogue input, in which case all bets would be off.

I meant "in sync" in that for each clock pulse, each ATMega would "advance" by one cycle; I didn't mean to imply anything like the code or any variables would be in sync.

:slight_smile:

I'm going to stick by what I have said in the past. The AVR chip is the BRAINS not the MUSCLES. You want MUSCLES, add peripherals... Like transistors or driver IC's.

I agree. Part of the problem is that Atmel (and others) have put such high performance output pin drivers, that pale what most standard digital IC use to offer, and because they can drive things directly like leds etc, it's understandable the inexperienced types might have an expectation that they can drive near anything with those pins.

But a real problem is that the Atmel chips offer absolutely no protection against ignorance. The fact that the AVR chips, using the Arduino platform, have made it so very easy for people with no prior electronics experience to jump in and start building stuff, is a double sided sword, easy to obtain and use, and easy to physically damage components. It's not like they have to get a gun permit before buying an arduino board. :wink:

It's not a realistic expectation that users first educate themselves in electronics fundamentals before starting to play with their arduinos using external components. The best we can do is to continue to help newcomers when they ask for help, or to explain to them if they seek help after damaging stuff why their stuff went up in smoke. Recommending a tutorial to start is helpful for some, but I suspect that many newcomers don't have the patience to start that way.

We are destined to always have to give the 'don't use leds without resistors' speech I'm afraid. ;D

God members should ask for a pay raise because of the rising popularity of Arduinos. :wink:

Lefty

It's not a realistic expectation that users first educate themselves in electronics fundamentals before starting to play with their arduinos using external components. The best we can do is to continue to help newcomers when they ask for help, or to explain to them if they seek help after damaging stuff why their stuff went up in smoke. Recommending a tutorial to start is helpful for some, but I suspect that many newcomers don't have the patience to start that way.

We are destined to always have to give the 'don't use leds without resistors' speech I'm afraid

Unfortunately, you're probably correct; part of the reason why there's this "no fear" attitude from newcomers is the fact that the penalty for failure is so low - a "$6 chip" is lost (or at worst, a sub-$100 board is lost - including the Mega here).

Imagine if these individuals had the same attitude about other items - say a car or a gun:

"It's not a realistic expectation that drivers first educate themselves in driving and basic automobile maintenance before starting to drive their vehicles around town"

or

"It's not a realistic expectation that gun owners first educate themselves in gun safety and shooting fundamentals before starting to practice with their weapons at the range and elsewhere"

Then again - considering what you see on America's highways, as well as the number of gun "mishaps" (including fatalities caused by such) - perhaps that attitude is prevalent in today's culture.

/that makes me feel better...

:frowning:

I wish Arduino would change their documentation e.g.:

If you've got experience with electronics, you may notice that the LED doesn't have a resistor in series with it. This is because the amount of current coming out of the output pin of the Arduino is low enough that it won't damage the LED. This simplifies the circuit for beginners to delete the resistor. In general practice, though, it's a good idea to add a resistor in series with the LED.

Is not good.

roar. While I'm no god member, I do understand that it isn't the best solution by a long shot. I was wondering if anyone had tried it out.

I agree though, when I first got into arduino I didn't have the idea that pins shouldn't be pushed too hard firmly implanted in my head. I understood ohm's law etc and how electricity worked, but it didn't transfer to what will smoke a chip and what wouldn't.