Using Arduino Mega 2560 as sipmle USB IO-Board

Hi Guys,

I'm glad to be here in this forum, but totally new to Arduino (but used to Atmel microcontrollers) and I'm not sure if this is the right forum for my question...

Im looking for an USB IO-Board that can be run from the PC using my own programs (Windows/Linux). The Pins needed are IO, PWM, SPI and ADC, so the Arduino Mega 2560 seems to fit quite fine here. My question is, could the Arduino Mega 2560 be used as simple (stupid) IO-Board working realtime with my software from the connected PC or could it only be programmed itself?

Maybe someone has done a project like this. Or maybe you could suggest some different hardware that I could use.

Many thanks for your help!!

Meson

meson: My question is, could the Arduino Mega 2560 be used as simple (stupid) IO-Board working realtime with my software from the connected PC or could it only be programmed itself?

Yes, it is possible and many (including myself) have done it before.

The key is writing the Arduino code with Serial.println() and Serial.read() commands. These commands send and read data to/from the PC.

For instance: I used a Mega to record the temperature and voltage of two batteries over the course of 3 min - all the while sending the recorded data to MATLAB on a PC (via USB) for data storage and graphing.

Many thanks for your quick answer!

If I understand you right, you mean to use the arduino as an active 'measuring device' sending data to the PC for analyzing and further processing. This is what I have done as well with my own controller boards.

What I ment is to send commands from own written PC program to the Arduino, e.g. to set a PWM Pin to 40% dutycycle, read any ADC-input or directly access the SPI-interface from the PC software. The Arduino should only act as 'interface' between my PC software and the IO-Ports and should not do any IO-port access on its own. Do you think this would be possible? And which Speed would it be like for data access from the IO-ports to the PC software via USB?

Many thanks!!

Meson

The Processing software already does all you want to do, and allows to implement a PC GUI. So it's all possible.

If you want to implement everything yourself, you have to specify a communication protocol, for sending commands to the Arduino, and how values are returned. You only have to open the Arduino COM port in you PC program, then use that stream for data exchange.

meson: What I ment is to send commands from own written PC program to the Arduino, e.g. to set a PWM Pin to 40% dutycycle, read any ADC-input or directly access the SPI-interface from the PC software. The Arduino should only act as 'interface' between my PC software and the IO-Ports and should not do any IO-port access on its own. Do you think this would be possible? And which Speed would it be like for data access from the IO-ports to the PC software via USB?

Yes, you can use either a terminal emulator (or the Arduino IDE serial monitor) to send serial data to the Arduino. Baud can be as high as 115200 or so.

meson: The Arduino should only act as 'interface' between my PC software and the IO-Ports and should not do any IO-port access on its own

I don't understand that, and it seems to be a key part of your requirement.

I don't know if this helps ...

A PC can send messages to an Arduino and the program on the Arduino can interpret the message and do different things - such as use analogWrite() to set a PWM value on a pin, or use digitalRead() to get the status of a pin. Having collected data from pins the Arduino program can send messages back to the PC containing the data that it has collected.

You cannot access the Arduino pins from a PC program without having a suitable program on the Arduino.

You should also be aware that you cannot use an Arduino (or any other device) to create a USB equivalent of the old-style PC parallel port because of limitations in the USB system.

This Python - Arduino demo may be of interest. It illustrates simple 2-way communication between a PC and an Arduino. You could do the same think with any other PC programming language.

...R

Have you seen this?

Another method I've used is the FTDI Windows D2XX driver, MPSSE SPI DLL and a USB to MPSSE Cable communicating to the Due at 12Mbps.