high speed A/D and serial communication

In my application, I am using an arduino mega to poll 15 analog pins. I need to communicate this data to the PC at a rate faster than 2 milli sec. The analog data is from touch sensors which will be used to detect collisions/touch of a high speed robot that can take commands at 2ms. What is the best way to do this? Can the A/D be polled that fast? How can I achieve speeds faster than 115200 baud?

Also how should the communication protocol be between Arduino and PC. My initial attempts at sending data continuously (30 bytes in each send) from Arduino to PC resulted in packets being dropped. Handshaking protocols such as PC sending a cmd byte followed by arduino sending 30bytes might be more robust but will obviously slow down the communication speed.

Any help is appreciated.

  1. Use interrupts, not polling. However, this only solves (for various values of "solve") the problem on the Arduino end...

  2. Use something other than serial to get the data back to the PC.

Number 2 is the key - maybe serial could work (is there a way to set it and the PC side up for non-standard higher-speed serial speeds?), but you might be better off using something else. Maybe I2C/SPI (if you are close enough to the PC motherboard) would be faster? There generally are such buses available somewhere on the PC motherboard, and ways of reading it (usually used for fan speed and temperature sensing on the motherboard).

You might try using an ethernet shield/interface, or you might try to use straight USB. I know on the FTDI chipset there is a special "direct mode" supported in Windows (but not on other platforms from what I have seen). If you have enough free I/O lines (or can set up an external port expander system on a serial bus?) - you could hook up a serial-to-parallel system (well, if you have a parallel port on your PC - which most new ones don't nowadays).

Ultimately, if your application is too much for the Mega (calculations or such that need speed for real-time needs), you might need to move to another, faster platform (maybe to the PC itself!). This won't be easy or cheap, unfortunately...

Hope this helps!

:slight_smile:

So in < 2ms you need to:

  • acquire 15 analog signals
  • perform calculations on those values (i.e. decide what to do)
  • send back commands to the robot

I’m not an expert, but it seems to me you’d need a pci data acquisition board more than an arduino :slight_smile:

for one thing, I have had great success dropping the analog stuff,
at least the amplitudes.

It is touch, right ? see if you can
simply collect a "touched/nontouched" state, using the
internal pullup and shorting to ground when touched.
15 samples will take 2 bytes to transmit, and you can
sample them at up to a Mhz,
assuming you read them ports in 16 cycles.

You might want to use an alternative that is Arduino "compatible" such as the teensy. It has a USB interface that can output data a lot faster than you will use. To make up for the limitation of only having 10 analog inputs, you could use an ADC like the MCP3208 to add on 8 more analog inputs. The playground has a page for the MCP3208.

I am in the middle of setting up a solution with the teensy but at first I was considering using the ethernet shield as a fast output from the Arduino. It was just easier to use the teensy with the samples given for the USB.