Go Down

Topic: Transfer lookup table via USB for use by multiple Arduinos (Read 839 times) previous topic - next topic


Hi all. First post *waves* Sorry for the long post - I figure it's easier if I go into detail straight up.

I'm working on a project that I'm struggling with and was hoping someone who knows more than I do would be able to give me a bit of insight. I'm fairly new to Arduino and it's possible I'm biting off more than I can chew but I'm hoping if I can break it down into small enough parts it'll work. I've given myself about 6 months to work the first couple of stages out so there's plenty of time to learn.

So what I'm trying to create is a sensor simulator for a number of different sensors. These sensors will monitor either analog voltages or frequencies etc and based on values from the lookup table, output different voltages etc. As an example, one of these has a DC 0-5V input from which it should output up to three different analog voltages out (think a mirrored potentiometer but more complicated.) So for each sensor there should be a lookup table, eg for x input voltage, output 1 should have y volts output, output 2 should have z volts output etc. Rather than having one Arduino doing everything I want to spread it out between a number of Arduino units as some of the sensors output a complex waveform at a frequency where the processing speed of the Arduino becomes an issue.

The catch is that the sensor "profiles" need to be changeable and selectable via PC. The idea then is that a master lookup table (I'm thinking .csv) containing the selected profiles for all the sensors is transferred via USB to the master Arduino unit with USB input and stored either on it or (preferably) on an SD card or other external memory (SD would be better as it's non-volatile). Once this is complete, each of the secondary Arduino units copies a section of the master lookup table (I'm thinking via I2C) to their own internal memory for their own lookup table, at which time the master Arduino becomes obsolete (or gets re-purposed, whatever - it's not important) as does the data on the SD card - at this time, all the secondary Arduino units are working independently of each other. I figure this is an easier solution as there's no confusion with multiple access to the memory.

Although for now I'm only planning one-way communication via the USB (transfer the lookup table and that's it) I would like to avoid having activity on the USB once it has done the initial transfer of the lookup table (ie no streaming from the PC) as further down the line I'd like to do data display on the PC.

Which brings me to my questions. Firstly, does this idea seem feasible? I'm worried that I'm overlooking some fundamental issue that's going to bite me on the butt and render the whole project next to impossible.

Secondly (and the reason why I asked in this section of the forum) one of the main things I'm having difficulty finding out is what the best method is for transferring the lookup table to (either the master Arduino or external memory eg SD card). I haven't really been able to find any examples that suit what I'm trying to do. Obviously there needs to be a PC side, and either an Arduino side or otherwise some way to write directly via USB to an SD card. I'm not really sure what to do here. I've seen examples using Python (a language admittedly I don't know much about) but they seem to be streaming the lookup data from the PC rather than having it stored on-board.

Thoughts? Suggestions? Any help greatly appreciated.


Could you write the files to the SD Card on your PC and then transfer it to an Arduino?

You could certainly write a PC program that can send data to an Arduino from a file on the PC. if the Arduino is normally connected to the PC this would probably be the simplest thing. I use Python and this Python - Arduino demo may be of interest. But you can do the ame thing in any PC programming language.

I'm afraid I don't understand your description of the project.

How much data (how many bytes) is there in one of your tables? An Uno only has 2k of SRAM so if the table is large and all of it needs to be available to the Arduino an SD Card may be the only option.

Two or three hours spent thinking and reading documentation solves most programming problems.


Thanks for your reply Robin. Unfortunately no, it's not really practical to transfer the SD card between the PC and Arduino. To give a bit more context, this is to be used for simulating vehicle sensors. The idea is that for each session, the user selects a profile for each sensor (eg one for the crank position sensor, one for the throttle sensor etc) on the PC, each profile being a look-up table. Once this has been done, the PC sends the selected tables via USB to the Arduino/SD card. I'm trying to do it this way so that when the user is choosing which profiles, they can do it from a simple VB program, whereas if I was to do it on the Arduino it would mean a display and a multi-tier menu which sounds a lot more complicated, and would also mean regularly swapping the SD card every time I write up a new sensor profile. It just seems a lot tidier keeping the selection process on the PC and then only supplying the data that's needed for that session.

As far as space goes, unfortunately I think 2k may be an issue. The largest independent profile should only be 720B so once the tables are stored on their respective Arduino units it should be fine, but the total combined size (the above-mentioned crank position sensor profile as well as the throttle profile and a couple of others besides) when it comes over from the PC will probably be in the region of 3-4KB. That could be temporarily stored on a Arduino Mega or one of the other higher-storage Arduino's but if it's not too complicated to do, an SD card would be better as it's not volatile, meaning if the unit's switched off and on the profiles don't need to be reloaded from the PC, just from the SD card.

It looks like I'm going to need to learn a bit of Python... everything I've found suggests that it's the easiest way to do the transfer. I'll have to sit down and have a good look at that example... I wasn't sure whether that was transferring the data in a streaming manner or storing it for later use (which is what I'm after).

Thanks again for your reply. Any feedback appreciated.


You can do anything with VB that can be done with Python - however I am no longer familiar with Windows programming. The general concept in my Python demo should work fine with VB.

Using a PC program to send data to the Arduino which it then stores in a file on an SD Card is perfectly feasible and sounds like a good idea for what you describe.

Two or three hours spent thinking and reading documentation solves most programming problems.


Awesome, thanks heaps Robin :) My VB ain't that good anyway so I'm thinking it might be better for me to base the transfer program off Python, so at least there's a few decent examples around to base it off.

Of course now I just need to learn a bit of Python :D

Go Up