0

I am using an Arduino 2 which collects data from a set of microphones and stores it in an array of unsigned short of 40000 elements and sends them to the PC via Serial USB.

It is working but I'd like to obtain more speed without any errors.

Can you suggest me the best way to do it? Even changing communication.

Thank you

5
  • Which USB serial are you using? The ATMega port or the native USB port? Commented Feb 8, 2017 at 16:41
  • And what baud rate, and what encoding? How fast does it currently go, and how much faster do you want (well, need) to achieve? Commented Feb 8, 2017 at 16:45
  • I am using the programming port. Commented Feb 8, 2017 at 16:47
  • 115200 Baudrate, I would like to obtain the best performances for a semi-real time application. I am currently using Serial.println(value1, value2, value3, ...,value8)\n. In PC parsing of the datas I sometimes get errors because it sends two different row in the same. Thank you Commented Feb 8, 2017 at 16:48
  • 1
    So, again, how fast does it currently go, and how fast do you need it to go? At 115kbps, you could in principle, suitably encoded, send 40k 16bit values in about 5.5 seconds. How long is it taking in your implementation, and how long do you want it to take? Everyone wants the best performance (and the least effort and the lowest cost and the highest reliability). Give us a clue. Commented Feb 8, 2017 at 17:09

2 Answers 2

3

Switch to using SerialUSB instead and use the other USB port. The baud rate is meaningless then - it runs at the speed of the USB port, which is a lot faster than serial (Linux reports it as 480Mbps, though I can't see an 84MHz chip doing that...).

void setup() {
    SerialUSB.begin(115200); // The number is irrelevant but it needs something in there
}

void loop() {
    SerialUSB.println(millis());
    delay(100);
}

For greater throughput you could devise some packet-based binary protocol to optimize your data flow to use less bytes.

4
  • seems legit. How to do it? Commented Feb 8, 2017 at 17:08
  • SerialUSB.begin(115200); SerialUSB.println("Whatever"). And plug into the other socket of course. Commented Feb 8, 2017 at 17:09
  • Why the delay? Is to avoid errors or just to simulate stuff? Commented Feb 8, 2017 at 17:14
  • 3
    That is just a simple example so you can see the port working. The delay has no purpose other than to allow your eyes to register what they are seeing before it is gone. Commented Feb 8, 2017 at 17:15
1

SPI: technically no upper limit so long as both parties can keep up and the wires are good enough. Mbps easily doable.

2
  • I am already using SPI for communication between Arduino and an ADC shield. Can I use it anyway and how? Commented Feb 8, 2017 at 16:56
  • 1
    spi targeting is controlled by the _CS pin(s). Multiple spi devices can hang off the same bus - assuming your shield is properly designed. Commented Feb 8, 2017 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.