I have an LTC1859 IC, which is an AD converter circuit at 16 bit and with 120kS/sec. It communicates with the Arduino using SPI.
Everything works -almost - perfectly: the data gets to the Arduino, and then to the PC. The only problem is: I am unable to get higher transmission speed than 4000 data/sec (that means cca 70 kbit/s, becouse of 16 data bit and the control bits on serial port). The evidence is that, when I drive the ADC with a 4kHz square signal, the values on the serial terminal changing very slow (a lot of the level change is missing). If I decrease the frequency to 3,5 kHz the data begin to change in the right way.
The sketch is very simple (Baud rate, config_data is set up in the setup section):
The baud rate of COM port is 230400.
I was able to realise cca. 50,000 sampling per secundum, if I did not use serial port (just counting the samples without to send them to the PC).
So I think that the communication is the bottleneck. Am I right? What should I do? Is there anybody who could make faster communication between Arduino and PC than I did? (I am shure about that, but can't find anything similar project)
You can probably push the baud rate up to 1,000,000
How many bytes of data per second are you trying to send?
What is the 1usec delay for?
You may find the throughput is better if you take several readings (up to 64 bytes) and send them all at once.
The new version 1.5.7 of the IDE seems to have much a improved USB transmission system. If you really want high speed use it with a Leonardo because the Leonardo doesn't bother with the baud rate.
The goal is to send at least 10kByte/s (5000 word), but I would be happy if all the 50000 data could be send.
At 230400 baud the data rate should be around 23k byte/sec - say 20k to allow for overhead. From my own tests these rates are easily achieved with IDE 1.5.6 and 1.0.5
I read somewhere that some delay should be used due to AD converter.
That sounds as useful as needing some sugar in your coffee
error: no matching function for call to 'HardwareSerial::write(uint16_t [10], int)
buffer is declared as an array with 10 element of uint16_t
Serial.write only woks with bytes or uint8_t
If the data from your ADC provide 16bit values (or values > 8 bits that need to be treated as INTs) you need to separate them into their high and low bytes so you have an array of 20 (rather than 10) of them.
The software at the receiving end won't know the difference PROVIDED you send the correct byte of each pair first.
One convenient way to treat an array of INTs as an array of BYTEs is through the use of a Union. A Union is a C/C++ concept in which the same piece of memory is treated as two different variables.
robtillaart:
still the bottleneck is the ADC is the ADC convertor.
Thanks, but I use different ADC than the built-in. I have a free sample ADC made by Linear Technology: LTC1859. It is a 8 channel 16 bit delta-sigma ADC, and it's conversion speed is 180,000 sample/sec.
Thank you very much for the links, because I want to use in an other project the ADC-s of the AVR.
katonacs:
Thanks, but I use different ADC than the built-in. I have a free sample ADC made by Linear Technology: LTC1859. It is a 8 channel 16 bit delta-sigma ADC, and it's conversion speed is 180,000 sample/sec.
Thank you very much for the links, because I want to use in an other project the ADC-s of the AVR.
I captured the serial data into a file on the PC with the Realterm program. During the 10 seconds of capturing 230,000 byte got into the file, so the transmission speed is 23 kB/s, and that is enough for me. So it seems I was unobservant.
I made a program that displays the serial data on a chart. It looks like this program unable to handle the data in the right speed. But this is not a problem with Arduino.