hello,
I am using multiple sensors installed on several arduinos to log data on an SD-card.
the sensors i am using are an ultrasonic sensor, an accelerometer sensor, an OBD-II, and finally a GPS module.
the ultrasonic US-100 is sampling at approximately 90 Hz and is digitally connected on an arduino uno
the accelerometer ADXL-345 is sampling at approximately 390 Hz and is connected to a separate arduino uno via i2c connection
the OBD-II UART sparkfun along with the arduino GPS shield are sampling at 1 Hz and are connected serially to the same arduino mega
all above arduino boards are connected in turn serially to an arduino mega as master-slave, after which i intend to log the received data onto an SD card connected via SPI unto that master arduino mega.
any idea how might i be able to log the data acquired as fast as possible without any issues directly onto the SD memory card?
I've also been playing around with a data acquisition system and have been tackling the same issues.
There are two main limitations that I have come across:
Serial transmission is pretty slow. Try to minimise the amount of stuff you send over serial, use the fastest stable clock rate, and where possible use faster communications standards, i.e. move to the right you can and if speed is a factor: USART >> I2C >> SPI.
RAM is limited so you will have to transmit data sufficiently frequently so that you don't run out of buffer.
In my own case, I found that on an Arduino Uno I could theoretically sample three analogue and five digital channels at 500Hz if all I was doing was reading ADCs and saving to a memory buffer. On an Arduino Due I could do the same thing at 5kHz. If I started then transmitting that data over USART to a computer then the sample rate RAPIDLY flattened out:
If you follow the blue line you can see that as I ask the Arduino to sample faster and faster the average sample rate actually achieved flattens out. When I tell the board to sample at its maximum 500Hz it actually only achieves an average rate of about 75Hz. In reality what it is doing i sampling in very short bursts then spending about four times longer ignoring the sensors and sending data via serial. In other words, you may have about 1 second @ 500Hz then 4 seconds of nothing, then 1 second @ 500Hz and so on.
Your data format may differ slightly, and may be a bit more efficient as I'm required to store a fair bit of meta data such as timestamps, digital flags, board IDs, etc. You could also look at where using a faster board such as a Due could improve bottlenecks (your "master Mega" seems to be doing a lot of serial comms) or if you could consolidate some of the sensors onto less Arduino's and somehow reduce serial traffic this way. I'm guessing the main issue is going to be the accelerometer!
Obviously the logging rate is dependent on a lot of things. i.e. what do you do with the data? do you take a number of samples and average for one reading? what sort of meta data do you capture? how much RAM do you use for storage?, etc. etc. My example was simply to show that the limiting factor was the serial comms, not the capture rate, which your numbers support.
@16fatlib:
I think that few newbies know your forum reputation... I know you are generally modest but you could probably quelch a lots of dialog by introducing yourself as the author of SD library XD
Assuming you are not just toying with your prey. Yo tha man, dude.