I am trying to use Teensy 3.2 for a timing-sensitive application and I face a lag of ~5ms.
Briefly, I do the following:
* A python program, running on an Ubuntu 14.04 laptop (part of a complicated process) sends occasionally one byte with the following command:
. I have also tried to do
after each write command but it does not help.
* Teensy is running a Firmware uploaded by Teensyduino that just compares the byte it received with 49 and in that case triggers one PIN to be 1 for 5 microseconds.
* In the ideal case, the latency between the (actual) time when Python sends the byte and the moment that the pin becomes 1 would be <1ms however here it is ~5ms.
It is worth noting that I get similar latency with the following alternatives:
a. Arduino doing the same
b. Using a serial ExpressCard on the laptop and using the Transmit Data pin as a TTL out (no microcontroller involved).
To note also that I tried it also after setting the serial port to low_latency with
All this, tells me this might be some specific about Ubuntu, since I saw online some comparisons of Teensy latency that for Windows is <1 ms but for Linux ~4-5ms. Unfortunately I cannot test this on Windows because the more complicated process that runs the python code only works in Linux.
Any ideas about either reducing the latency of serial communication in Ubuntu or any other alternative way of getting this TTL out of the PC in a timely manner are highly appreciated.
Thank you in advance.
Nikolas
Briefly, I do the following:
* A python program, running on an Ubuntu 14.04 laptop (part of a complicated process) sends occasionally one byte with the following command:
HTML:
teensy.write(b'1')
HTML:
teensy.flush()
* Teensy is running a Firmware uploaded by Teensyduino that just compares the byte it received with 49 and in that case triggers one PIN to be 1 for 5 microseconds.
* In the ideal case, the latency between the (actual) time when Python sends the byte and the moment that the pin becomes 1 would be <1ms however here it is ~5ms.
It is worth noting that I get similar latency with the following alternatives:
a. Arduino doing the same
b. Using a serial ExpressCard on the laptop and using the Transmit Data pin as a TTL out (no microcontroller involved).
To note also that I tried it also after setting the serial port to low_latency with
Code:
setserial PORT low_latency
All this, tells me this might be some specific about Ubuntu, since I saw online some comparisons of Teensy latency that for Windows is <1 ms but for Linux ~4-5ms. Unfortunately I cannot test this on Windows because the more complicated process that runs the python code only works in Linux.
Any ideas about either reducing the latency of serial communication in Ubuntu or any other alternative way of getting this TTL out of the PC in a timely manner are highly appreciated.
Thank you in advance.
Nikolas