Hello everyone, I would like to use the arduino as a sampler for a MAX4466 at 5khz and transfer that data to a PC in real time so I can use a program like matlab to process the info. Now, I have been reading the forum and it seems that the serial transmission from the arduino to pc would end up being too slow for the sampling rate I want. Is there any way to achieve a real time sample-logging to pc using Arduino? If not, what alternatives do you guys suggest?
Thanks.
Take a look at this Remote High Speed Data Logging Project
It uses WiFi for the connection and goes through an analysis of the speed bottle necks.
Its polite to provide a link when you list a part like this
so we know what youre talking about.
So = it looks as if you wish to sample a sound pressure wave.
I'd suggest you have a look at my site here which will help you make decisions about such factors as sampling rate and measurement accuracy
Thanks for the reply, Im new so I will link any relevant part in the future. On the other hand, I read the link you provided and I found it useful for my project. Do you have any suggestion to avoid the
data bottleneck the serial transmission to PC involves?, Im considering using an SD card as a buffer and send the data at maximun speed via serial.
For high speed SD writes see this project
High Frequency, Long Duration Datalogging . There is also an Uno/Mega version
I have not tested SD reads, but would expect them to faster than the serial can keep up with.
Use one of the newer high speed boards and set the highest baud rate it will support and send the data in binary rather then text. You will need to match/convert the Endian between the Arduino and PC
The High Frequency, Long Duration Datalogging code will tell you what the Endian of your Arduino is.
If you use the right MCU, there should be no problem with using the serial port to transmit 5000 10 (or higher) bit samples per second to a PC. The Teensy devices work at the full speed of the USB bus, for example.
You realize that for a sample rate of 5 kHz, you must have a low pass filter between the microphone and the Arduino limiting the audio frequencies to 2.5 kHz maximum, or you will have terrible problems with aliasing.
You want to use a board with Native USB.
There's many references on line about high speed date transfer with the Arduino Due, some specifially related to Mathlab.
The Teensy family of boards from PJRC is worth a look. They can use the Arduino IDE, there is good technical support online, and are low cost. The Teensy 3.2 is less than $20 US and has many capabilities.
https://www.pjrc.com/store/teensy32.html
Welcome to the forum.
Strictly speaking there is no real-time when you use a PC. Windows and most Linux variants are not real time operating systems.
However, assuming you want to convert the data with the ADC, let’s say 10 or 12-bit. An unsigned value for 12-bit can go from 0 to 4096. So, you would need maximum of 4 characters (ASCII decimals) to send one value plus one or two characters for new line (CR+LF). That is 6 bytes per sample. At 5kHz that is 30kByte/s. You can easily do that with an Arduino with native USB over virtual COM using Serial.print.
If MATLAB can handle HEX values you can save on byte/character per sample by using Serial.print ( value, HEX );
If your MATLAB can handle binary data, you can send every value as 2 bytes with no separator whatsoever. That will reduce your data rate to 10kBytes/s at 5kHz sample rate. You will need to shift your bits around to allow you to separate the low byte from the high byte but that is easy.
e.g.,
Low byte: bit[7] = 0 and bits [6:0] will be the lower 7 bits.
High byte: bit[7] = 1 and bits [4:0] will be the upper 5 bits of the 12-bit value.
Not all boards with 'native USB' serial are faster. SparkFun's RedboardTurbo's SerialUSB is noticeably slower then its Hardware Uart via TTL to USB converter.
Have you considered just using the pc sopund card to input the signal? There are lots of sites describing how to do this. EG
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.