LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect values and timing drift when logging REST data to Excel in LabVIEW

Solved!
Go to solution

I have a LabVIEW VI that opens a REST client and, inside a While Loop, sends multiple HTTP POST requests to read data from sensors. The responses are converted to numeric values, displayed on charts/indicators, and logged to an XLSX file using Set Dynamic Data Attributes and Write To Measurement File, with the loop rate controlled by a Wait (ms). For timestamps I use Get Date/Time In Seconds that links to each of the Set Dynamic Attributes. The charts and displays appear to update correctly, but there are problems with the Excel logging. When the update rate is set higher than 1 sample/s, the saved magnitudes are wrong and are only correct at exact 1-second points (1 s, 2 s, 3 s, etc.); the values in between are incorrect. When the update rate is set to 1 sample/s, the values are initially correct, but after ~30 minutes the effective time interval starts drifting above 1 s. This looks like a buffering, timing, or logging issue rather than a sensor problem. I’ve attached the VI and would appreciate advice on how the VI should be restructured so that the values and timestamps written to Excel are correct and stable over long runs and at higher update rates. 

 

I am also attaching the vi where I tried to implement the buffer using the Feedback Node and Case Structure. However there is a problem as the Case Structure is never executed as the buffer at the start is 0. 

Download All
0 Kudos
Message 1 of 6
(221 Views)

In short, the most probably cause is that data is building up and too many actions in the same loop is causing slow down over time due to data size.

And, by the looks of your implementation, you're a beginner and an important tip is to build structured and modular code and not a ginormous VI (typically the content of block diagram shouldn't take scrolling on a FHD display) and your code requires a lot of scrolling even on a 2k display.

santo_13_0-1767627300569.png

 

A way to make your code readable and debug friendly is to implement this as producer-consumer, where the REST calls are in the producer, data processing and logging happens in the consumer loop.

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution
0 Kudos
Message 2 of 6
(198 Views)

I've created Producer-Consumer loops but it does not trigger the acquisition. I moved the  Write To Measurement File vi into the consumer loop and I added Queue functions.

 

The app starts and display data just fine, but the dialog to chose the file that I want to save into  does not appear. 

0 Kudos
Message 3 of 6
(149 Views)
Solution
Accepted by topic author stan_k_112

I found what the problem was.

 

The Error Out from the producer Enqueue Element was fed into the Write To Measurement File's Error In, that is inside the consumer loop. Removing this wire solved the problem with the loop not starting.  

0 Kudos
Message 4 of 6
(104 Views)

Hi Stan,

 


@stan_k_112 wrote:

I found what the problem was.


So you learned about "THINK DATAFLOW!", the very basic principle in LabVIEW? 🙂

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(81 Views)

@stan_k_112 wrote:

I found what the problem was.

 

The Error Out from the producer Enqueue Element was fed into the Write To Measurement File's Error In, that is inside the consumer loop. Removing this wire solved the problem with the loop not starting.  


Sounds fishy to me. It sounds like you created a race condition that you are winning... so far.

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 6 of 6
(58 Views)