Programming multiple ATMega's/arduino's at once

Hi there! I searched around but didn't come up with anything, hope this hasn't been covered before. I am developing a pcb for a custom application that uses five ATMega 328's. They all do basically the same thing (it's a control board for 5 separate systems). It just so happens that I have used the TX and RX pins as user inputs which are common between all 5 ATMegas, so these pins are connected to each other between the processors. The reset pins are also all tied together. I am planning on building a shield that would connect to the five ATMega's TX, RX, and RESET pins (as well as power and ground) to an arduino board, and using the USB interface to program all 5 of them simultaneously. I will be bootloading the chips prior to installing them on the board with the Arduino bootloader. Is there any issue with attempting to simultaneously program 5 chips? I don't know much about how the TX and RX pins actually interface with the USB chip. If not, I do have the MOSI/MISO/SCK pins broken out individually so I could use an ISP. I'd rather just program them all in one shot, if its possible. Thanks!

I have used the TX and RX pins as user inputs which are common between all 5 ATMegas, so these pins are connected to each other between the processors.

How does your application deal with all the Txs wired together, do you turn them to IPs when not used?

As for programming, you can't program > 1 chip in parallel with ISP, in theory I guess you could if they were perfectly synchronised but the slightest difference and the Tx signals will cause a clash.

I would say the same applies when using the bootloader.


Rob

Thanks for the reply! I had a hunch that was the answer.

I'm not sure what you're asking though. In the circuit, the TX and RX are just used as basic inputs. Internal resistors pulled high, connected to switches to ground. They're just used to let the user to enable or disable certain functions in the program.

I think I might try to include a DIP switch which allows me to select which chips are powered. So I could still use the parallel connection, just have to repeat it 5 times with only one chip powered at a time. Space is at a premium right now, but I might be able to sneak a small SMT DIP into the power line to each.

So I've managed to squeeze some DIP switches inline with the power to each chip. I just want to make sure that this will work! The TX and RX pins are still connected together, but I can have only one chip powered at a time. Would there be any ill effects of having the extra connections, even though the chips are unpowered? Fairly certain it'll be fine, but just want to make sure before I go about making another board :)

TX and RX are just used as basic inputs

OK, I saw RX and TX and assumed they were used for their normal functions.

include a DIP switch which allows me to select which chips are powered

A 2x5 header or 5 2-pin headers (with jumpers) is a lot smaller than a DIP switch, not quite as convenient but unless you're programming 50 times a day this wouldn't matter and would save a bit of space.

Just as a matter of interest why do you need 5 Arduinos? Is the control application too complex/fast for 1?


Rob

I considered headers, but I can fit the DIP switches. I need surface mount stuff (thru-hole would interfere with components on the backside of the board), and once you consider the gull-wings of the SMT headers, they're just as big footprint-wise.

I did 5 arduinos/atmegas mostly for improved control and response time. They each are executing a PID loop in which they monitor the frequency of a square wave and make adjustments (via a motor controller), so I decided it would greatly simplify things and improve performance if I dedicated a chip to each PID loop. Response time and simultaneous adjustment of all 5 systems are very important, so I figured it would be much better to dedicate a chip to each.

In hindsight, I could have gotten away with using an ATtiny on each instead of the ATMega; the mega is definitely overkill. But I am familiar with Arduino and since I'm not very experienced with microcontrollers in a non-Arduino form, figured it'd be an easier first step away from the Arduino board, into more custom-application territory. Right now I have all 5 microcontrollers, signal conditioning/processing, and motor controllers crammed on a board that's about an inch longer than a Duemilanove. I'm a mechanical engineering student, so the electrical/computer science stuff doesn't come as easily. I'm sure it would be possible to control all 5 with one Mega with little difference in performance, but I'm not the world's greatest programmer! (another reason for using the DIP switches - I might need to be reprogramming 50 times a day to get it right :))

This is for my senior design project for ME, so the control system is just a little part of the project - I have to design and build all the stuff its controlling too! So I wanted to make it as easy as possible on myself.

So each motor responds differently to the same input freq?


Rob

Its the same exact system, but repeated 5 times. So 5 motors, 5 different signals, etc. The only thing that is common between them is three user inputs. It's an automatic tuning system for a 5-string bass :) Each string has its own pickup, its own tensioning motor, and its own control system. Other than different frequencies, the code for all the systems is the same. Some PID coefficients might change a bit too since some strings require less tension (and therefore lower required duty cycle to achieve that tension) than others. The three user inputs are two from a rocker switch that forces it to tension or de-tension (for restringing) and a 'base tune' button, which forces it to try to achieve the correct open string freq.

Using a Bus Pirate (SPI) to program up to 8 AVRs, or 3 independent AVRs:

http://hintshop.ludvig.co.nz/show/buspirate-avr-programming/

@evo

Bus Pirate (SPI) to program up to 8 AVRs

Close, but no banana.

From the Original Post on this thread:

@TomServo:

The reset pins are also all tied together.

I love my Bus Pirate, but with Bus Pirate (or anything else that can program multiple AVRs), the AVR reset pins can not be all connected together. Period.

Regards,

Dave

Footnote: Furthermore...

With the multiple-AVR connections in your reference link, the AVRs are not programmed all at the same time. They are programmed one at at a time, using different AUX pin settings for each device.

Indeed. Interesting for sure, but without a serious rework of the circuit design to isolate all the reset pins and link all the MOSI/MISO/SCK, not possible. Right now I have exactly the inverse of what I need for that - MOSI/MISO/SCK are isolated (and need to be - the MOSI/MISO pins are used as outputs to the motor drivers) and the resets are tied together (so the board only needs 1 reset button, not 5).

Adding 5 little dip switches should do the trick. Much better than having to add headers for MOSI/MISO/SCK on all the processors and having to move the connectors to program each one. This way I can get at the TX and RX for all of them from the existing ribbon connector, and just flip the dip switches around to select which one I want to program. Not the most elegant solution, but it is a nice combo of easy and functional!

Thanks everyone for your help! Time to make some circuit boards. I'll post up my results, eventually!

Figured I should update this with my results :) Got one of the circuits finished up, I'm going to run some tests to make sure everything is working as designed before I go ahead with the remaining four. Here is my bootloading rig: USBtinyISP. The brown/red/orange part of the tether is the SCK/MOSI/MISO connection. The lonely white wire is the Reset. The yellow and black are power and ground.

The programming rig: Using a Duemilanove with the ATMega removed as the USB interface. The jumpers in the IC holder just route power and ground to the header for digital pins 2 and 3, so I could use 1 connector.

And here is just a couple of pics of one of five completed circuits :D The top side, which holds a pair of filters, a dual op-amp and supporting circuitry, and the ATMega/crystal/caps. You can also see the DIP switch I used to turn on/off the ATMegas just above the SCK/MOSI/MISO header.

The bottom of the board, which has the timing circuitry for setting the filter's cutoff freq, and the h-bridges for motor output. Also an initial signal amplification stage using that teensy SOT23-5 op amp at the top :) (which is crooked >:( )

All those SMDs on a home-etched board. Well done. I've not soldered SMDs before so it gives me hope that my upcoming SMD projects will be doable.


Rob

Surface mount isn't difficult at all. Solder paste is highly recommended though. http://www.zeph.com/zephpaste.htm That's what I use. If you don't want to buy paste, just tin the traces with a little solder and apply a little flux, place the component and touch the leads for a second with your iron. For resistors/caps, 0603 is about the smallest I would go. I've done 0402, but its really difficult. If you can manage 0805 or larger, do that. 1206 and bigger is downright easy. Caps are more difficult than resistors, since they usually have a square cross section, where resistors are flatter(shorter than they are wide); the caps have a tendency to roll when you're trying to hold them in place. This is only really an issue if you're using an iron. If you're baking the whole board, not really any difference then. For IC's, SOIC/SOP packages are pretty easy. Those are the two filters at the top of my board and the timer chip. The 32-TQFP of the ATMega has only slightly smaller leads and spacing than the SOIC, so its pretty easy too. The TSSOP packages are a bit tricky, since the leads are quite narrow and tightly spaced. The dual op-amp in the middle of the board is a TSSOP. The small traces and tight spacing make printing the board more difficult as well. They are pretty wide and low, so its easier to position and hold them in place though. SOT23 packages also have pretty small leads and spacing, plus the components are taller with respect to their width, so its more difficult to hold them in place. That said, I haven't met an IC package I couldn't solder, yet. There are some that have the leads/ground pad entirely under the chip, so you'd have to do the paste & bake method for those, but I have been able to avoid those packages so far. The bigger TQFP packages have much smaller leads and tighter spacing, but I haven't tried any of those yet... They can be significantly smaller/tighter than the TSSOP, which puts them out of my board printing abilities.

Thanks for the info, the smallest "big" chip I'll be using is a 44-TQFP, plus other stuff like SOIC, SOT23 and 1206, plus I'm having boards made that will have solder resist so it sounds like it will be OK. I know there's a few threads about this around and nobody seems to have too hard a time.


Rob

I agree smt/smd is not that hard just take your time and use a good solder paste.

with very fine pitch it can also be done by applying solder to blank board e.g tining pads, then once it has cooled down tack the chip with the corner pins then reflow/hot air, just use standard solder wick to get rid of any excess solder

I have also done QFN and LGA they are not hard but the alignment is more difficult

best tip given to me: try to rest your wrist to help steady your hand