Data collection over ethernet using mbed

08 May 2011

Hi all,

I am interested in connecting a PC to the mbed over its Ethernet pins to collect data from an array of sensors interfaced to the mbed.

The way I want it to work is this:

1. The PC will request what sensors are to read by sending a control packet/packets to the mbed (and any associated parameters, like sample rate, number of points required, etc). 2. The mbed will decode the packet(s) and effect the request, for example "sample n ADC data points". 3. The mbed will populate an array of these points and return it to the host PC. 4. The host PC will pull the values and display them in real time (to a terminal program, etc).

Questions: 1. Is the mbed capable of doing this at all? 2. What is the maximum data rate I can realistically expect from this type of setup?

Where do I start with the mbed coding?! My mbed knowledge is fairly superficial & I have no experience with TCP/IP or Ethernet to speak of. Can anyone suggest a good place to start on this? For example, how to write a very simple test program where an LED is connected to the mbed, which in turn is connected to a PC with a patch/crossover cable. The LED is lit/extinguished when a command is sent to the mbed over Ethernet (using some PC-resident packet builder/reader program?).

As a later advancement of this concept, I would like to use some kind of GUI to display, chart and/or analyse the data nicely, but for now, the above is more than enough for me!

This type of connection is very exciting for a great many projects and I dearly hope I can get something working with the help of the mbed community.

Kind regards,

Jamieboy

08 May 2011

Hi Jamie

There are several ways of doing this depending on how demanding your application is.

One of the easiest to set up quickly is to use remote procedure calls. You can directly control outputs and read from pins, or you could make use of the RPCFunctions within the RPC interface library to use the approach of sending a packet of commands and receive an array of data points. All you have to do is download the HTTP server onto your mbed to get started, you don't need to write any code to be able to use RPC commands to read pin values or set LEDs.

To speed up making a GUI there are several libraries such as for Java and JavaScript which handle the interfacing with mbed from the computer as well, often through a web browser. There is also libraries for python, LabVIEW and MATLAB. Using this approach you could actually go as far as setting up a GUI very quickly for example by using the processing library.

There are also example programs of how to use the TCP Sockets to transfer data such as here Echo Server. This is a simple echo server, but you could therefore use the data transferred in any way you wanted, including as the text input for RPC.

Michael