Arduino Mega^2

This is my first post after working with arduinos for almost 2 years. Arduino had taught me a lot and I am very thankful to the team that developed it.

I am in the process of making an I/O board with at least 100 usable I/O pins. It is easier to choose a hardware such as AVR32 but then, I would not be able to use the Arduino development platform.

For that matter, I am looking into making a single board design that consists of two ATmega1280 or two ATxmega (74 pin series).

Given the situation that ATxmega is in (lack of availability), I am sure the ATmega1280 would be my only option.

The idea is simple, put two ATmega1280 in one board, wire up the two microcontroller via I2C as described here so the two microcontroller can communicate if desired.

Next step is to figure out how to interface both microcontroller to an FTDI chip, so that a single RS232 interface is shared between the controllers, only for programming purposes.

While running, the two controller can use I2C to communicate. Several digital I/O lines (with selectable pull up / pull down operation )could also be connected for interrupt operation between the two microcontrollers.

I would really appreciate any inputs from everyone about the design and hope that I could contribute to the community this time.

rembau

If you only need to add additional I/O pins, you can do it with i2c port expanders like this one: http://www.nkcelectronics.com/i2c-gpio-expande2.html

You can add 8x8 = 64 ports to a single i2c port + native MEGA ports, you have more than 100

If you are going to custom roll your own boards for this purpose, I'd add the following notes:

ISP connector each chip independently, so that each one can be programmed seperately.

Spend the time upfront developing your firmware from chip 2. Standardize the packets to receive an I2C command and execute it.

Program it once through the ISP, then forget it.

You'll be able to control all of it's IO from chip#1, and chip#1 can talk directly to the FTDI.

If you really have your heart set on using the IDE with both chips, simply add a jumper block so you flip 2 jumpers to select which chip talks over the serial port to the FTDI.

I have looked into your suggestion and read the tutorial from Keith. The only problem I see with the solution is that those GPIO port expanders only support single operation, Input or Output. I was also worried in terms of the speed of all the GPIO from all I2C expanders since the IO operation for my application is pretty tight. (no laggy2)

Forgive me for being sloppy, I have also forgotten to mention that the number of external interrupts in a single ATmega1280 is not sufficient for the purpose of my project. I would appreciate it you could point out a different way to address this issue.

Thanks for your suggestion. ;D

If you are going to custom roll your own boards for this purpose, I'd add the following notes:

ISP connector each chip independently, so that each one can be programmed seperately.

Spend the time upfront developing your firmware from chip 2. Standardize the packets to receive an I2C command and execute it.

Program it once through the ISP, then forget it.

You'll be able to control all of it's IO from chip#1, and chip#1 can talk directly to the FTDI.

If you really have your heart set on using the IDE with both chips, simply add a jumper block so you flip 2 jumpers to select which chip talks over the serial port to the FTDI.

Thanks for your suggestion.

I think I do have my heart set on using the IDE with both chips, since this way I would be able customize the second chip in the future for other purposes than just simple I/O operation. ie. adding peripherals etc..

I am wondering if there is there any known power supply issue if I decide to power both ATmegas using the shared USB connection.

Looking at the schematic of the original Arduino Mega design shows that the SCL and SDA line are both connected to a 10k resistor right before being connected to the +5V power supply. Why so?

I guess I still have a lot to learn. :-/

Looking at the schematic of the original Arduino Mega design shows that the SCL and SDA line are both connected to a 10k resistor right before being connected to the +5V power supply. Why so?

They are called pull up resistors and are used to supply voltage to the signals. I2C lines only pull down they don't drive up. In this way many I2C devices can be connected to the same line and any one can pull the line down. This sort of arrangement is known as a "wired OR" configuration.

so that a single RS232 interface is shared between the controllers, only for programming purposes.

Can't do this and the boot loader needs to talk both ways and there is a conflict depending on what each AVR chip wants to do.

If you don't understand all that at least you have the phrases to google.

If I2C is too slow, there are SPI interfaced I/O expanders. It could get a bit ridiculous if you need an IO expander in order to have enough CS lines, though.

Many IO expanders have an interrupt output that can be used to indicate that its input has changed.

-j

The only thing you should need for switching the FTDI from one CPU to another is… a switch ;D

I did a similar thing as a 168 Quad, see post #11 on this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238600379

IIRC, some of the I2C port expanders support interrupts. You can also try OR'ing all the interrupt lines you care about together and then have the interrupt handler poll them to determine which triggered the interrupt and act accordingly. Make sense?