05-10-2018 11:59 AM
Hello, I´m using an ESP8266 WIFI module as a client (controlled by a PIC18F2550), and a Timed Loop, where first a TCP Write sends "x" bytes to the module and then a TCP Read receives "y" bytes from the module. It works. The problem is that for the application, I need 10ms for each iteration of the Timed loop.
The PIC sends the bytes (through the module) 1ms later than it receives from LabVIEW. And the operation (Write - Read) takes less than 2ms. But despite the timed loop is set to 10ms, each iteration takes 30ms.
Do you know why?. Is there a way to make the TCP Write and TCP Read VI's work faster?
Here is the code. Before the timed loop, a TCP listen, wait for the connection, once the module and LabVIEW are connected, it goes to the loop.
Thanks.
05-10-2018 01:01 PM
05-10-2018 02:42 PM - edited 05-10-2018 02:43 PM
Hi Hector,
Do you know why?
Because of all those bended wires? The data will flow faster through straight wires! (Just joking…)
The Rube-Goldberg constructs in your code also doesn't help to speed up the loop.
despite the timed loop is set to 10ms, each iteration takes 30ms.
It doesn't make sense to put a non-deterministic operation like TCP communication into a deterministic loop like the TWL!
Use a standard while loop and work with the timeouts of the TCP operation to read and write data as fast as possible…
05-14-2018 03:37 PM
Hi, I tried disabling the Nagle algorithm but nothing happen. Without the TCP Read, the loop goes ok, each 10ms. It seems like the problem is in the TCP Read.
05-16-2018 11:07 AM - edited 05-16-2018 11:07 AM
Nagle would only affect the write; not the read (unless your PIC uses the same algorithm). Like GerdW said, TCP is non-deterministic. Don't expect it fit your timing constraints.