LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed loop freezes when using TCP/IP

Hello

 

I am using TCP/IP for communication between ESP-01 (which is receiving data from arduino) and Labview. The ESP starts a socket service at a certain port number and the labview joins the server as a client to receive the data transmitted by the ESP. I need to run this in a 1ms timed loop (1000Hz) but the VI freezes in between. I get continuous flow of data for a few seconds with intermittent loss of information as the VI freezes. Is there anything I can do to avoid this problem as I need to transmit the data wirelessly to labview? I have attached the code below. 

0 Kudos
Message 1 of 5
(1,194 Views)

Why do you feel the need to have it loop at 1 kHz?  Even with a timed loop, there's no guarantee that it will actually run at 1 ms.  But that's besides the point.  Why have it timed at all?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 5
(1,152 Views)

I agree that it makes absolutely no sense to run this in a timed loop. The timing should be exclusively determined by the sender, while the receiver (your program) should update whenever new data arrives. A millisecond is a very long time and there could be gallons of incoming data while you only consume a few bytes every millisecond. Ultimately, buffers will overflow.

 

What kind of device/program is sending these messages? What is the typical rate? What are the typical message sizes? If the sender sends data every ms, no timing is needed (but there is probably some jitter, depending on network characteristics). For other rates you can resample or decimate the data to match the rate wired to the ptbypt filters.

 

Your filter seems mostly cosmetic to eliminate noise (smoothing a 1000kHz signal down to 10Hz). Maybe all you need is a 100point mean ptbypt or similar.

 

There are several other oddities that may hint that you only have limited LabVIEW experience, for example, why is the shift register not initialized? Why do you convert the string into a 2D array while you really only use one dimension? (hint: you can wired a 1D DBL array to the "array type" input).

 

Why TCP? Maybe UDP would be sufficient for this.

 

Message 3 of 5
(1,144 Views)

This is just a test VI to see if everything is working fine as far as communication is concerned. I need these readings in a RT system and data will be used to drive motor in a timed loop with 1k frequency. The data is 15 bytes at max and consists on angular data by IMU sensor which is connected to Arduino Nano. Arduino continuously sends this data to the Rx pin of ESP which in turn forwards the data over wifi to Labview. I have attached the video and you can see that the flow of data stops towards the end of the video. It is a 1 min video, so you can directly jump to the last part. The Boolean on the top indicates whenever the signal is available. Is there something wrong with the TCP communication or there could be some other reason for the lost data? I need this data wirelessly and need to know if I switch over to some other communication  method like Bluetooth etc., will I be able to avoid this problem?

 

I am not very experienced at using labview and happy to modify the filter as well the shift register initialization as suggested by you.

0 Kudos
Message 4 of 5
(1,109 Views)

I wonder if you read and understood our concerns.

0 Kudos
Message 5 of 5
(1,093 Views)