I'm trying to control some pneumatic cylinders with arduino. I want to do the calculations on pc and then send the command to arduino to control the air flow to pneumatic cylinders. It's very important that arduino receive these commands super fast (in real time if it's possible) so that I can control air flow in millisecond precision.

What is the fastest way to communicate to arduino (Read and write). I tested serial communication and it's very slow in compare to real-time. Is there any specific settings for serial communications that i need to do to increase it's speed? Should I use LAN connection? Or maybe I should use for example Arduino YUN with an OS?

1 Answer 1


Going over USB will add about a millisecond of jitter to your data in both the sensing and command directions. Using a part with direct USB rather than then needing to go through a serial link from USB chip to processor could help limit what is added on top of that, but it will still be there. If you could get a USB high speed solution that would reduce this as the polling interval is shorter, but there are few such solutions for simple microcontrollers. Ultimately, USB is meant to move a lot of data in a reasonable amount of time - it is not designed to move small messages promptly.

True realtime systems put the processing and the actuation in tightly connected local circuitry. With the increasing isolation of PC processors from external I/O by multiple layers of intermediate architecture on the chip and motherboard, you see very little realtime use of PCs today. An embedded board with a decent processor and good direct I/O (Beaglebone, maybe the Linux side of a Yun or comparable) would be better, but be aware that multi-tasking operating systems like Linux or Windows are fundamentally in conflict with real-time performance - it takes very complex hacks to make that work, for example running a realtime scheduler directly on the hardware and having it run an ordinary operating system as a low priority task.

The architecturally cleanest solutions would be to find a way to fit your calculations on a fast single processor - in the realm of Arduino-style solutions perhaps one of the latest in the Teensy series. Beyond that you are really out of the realm where this could be considered an Arduino question - trying for example to run a realtime scheduler on the Linux half of a Yun is really not related to "Arduino" at all.

One thing that is not clear however is if your system needs to react in real time, or merely to sequence with precise timing. Mere sequencing is a far easier problem, as you can send the data a bit in advance of need and hold it in a buffer, so that communication latency doesn't delay operations. A 3d printer could be an example of this - the really complex calculations are done on a PC, then commands are drip-fed a bit in advance of need to a simpler executive traditionally running on a repackaged Arduino Mega, and that moves the motors with sub-millisecond pulse precision. Given that there are no realtime inputs to the calculations, their results can also be stored on an SD card for use months later with no PC connection at all. If your need does reduce to such pure non-reactive sequencing then things are a lot simpler; if it doesn't, then the rest of the explanation here applies.

  • You forgot to mention the Raspberry Pi. That is a computer running a (almost) normal version of linux with I/O.
    – Jot
    Commented Sep 22, 2017 at 18:58
  • 1
    @Jot I did not "forget", I quite specifically excluded the Raspberry Pi from this conceptual overview because it is architecturally ugly, with the undocumented proprietary coprocessor complicating things. You also seem to be overlooking the difference between "Linux with I/O" and "Linux extended for realtime scheduling with low-latency I/O" - that may be possible on the pi with enough effort, but it's not your typical userspace write to /sys/class/gpio Commented Sep 22, 2017 at 18:59
  • You are right. Maybe EBAG can add more details to his question about a possible sequence and about the calculations.
    – Jot
    Commented Sep 22, 2017 at 19:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.