From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed loop or while loop on RT/Host

Hey guys,

 

I am using a myRIO and a new windows tablet with LV13 f2.

 

At the moment I use both while and timed loop parallely for data acquisition on RT, transfer from RT to Host, editing data on host and data logging on host.

 

My question now is, as these loops shall run with a different rate, should I use timed loops or while loops when I only use the "dt" pin of the timed loop or the "wait for multiples" function in the wile loop?

 

Or is timed loop only usefull if I want to add priorities and so on...?

 

kind regards

 

Slev1n

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

On RT, Timed loops are used for deterministic timing of your processes - if you need execution occur at a specific timing (with priorities) then use a timed loop. For example - if you're writing a process for a control system - you'd probably use a timed loop.

 

For data acquisition, I would acquire the data on the FPGA at a set rate and use a FIFO to transfer from FPGA to RT and then use something lossless like network streams to transfer the data from RT to the Host. This should mean that you won't lose any data points. On the host, I would use a producer/consumer to read the data from the RT target and then do my logging in a seperate loop.

 

On Windows, timed loops don't really do a lot. Use a while loop with some execution timing.

 

NI have many reference designs for FPGA/RT/Host systems, it would be a good idea to look at some for inspiration/ideas - they are usually pretty well documented:

Using the LabVIEW for CompactRIO Sample Projects

cRIO Vibration Data Logger Reference Design

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 2 of 5
(4,017 Views)

Thank you for the detailed answer,

 

I do it excactly as you explained, although I also use the consumer/producer for my LIA values on the RT for acquiring in one loop and averaging up to 50 values + sending them via Network Stream to the host in another.

Or do you think it is not necessary two seperate acquirement and editing+transfer?

The transfer loop (the downmost) is the fastest and as fast as the LIA one.

RT acquire.PNG

 

But I will change the timed loops on the host to while loops, saves space on the screen 🙂

 

kind regards

 

Slev1n

0 Kudos
Message 3 of 5
(4,000 Views)

Multiple timed loops is generally not a good idea, if you do need more then one then do one per processor core. A timed loop is assigned the very top priority by the operating system, so having multiple timed loops on a single core defeats that purpose. For anything doing network communications, asyncronous instrument communications, datalogging, or data post-processing use a regular while loop

0 Kudos
Message 4 of 5
(3,971 Views)

@MarkCG wrote:

Multiple timed loops is generally not a good idea, if you do need more then one then do one per processor core. A timed loop is assigned the very top priority by the operating system, so having multiple timed loops on a single core defeats that purpose.


I don't think that's quite true - I think you're right that timed loops have higher priority than while loops, but you can have multiple timed loops and assign their individual priority relative to each other. If it's time for a higher priority task to run, it will interrupt the lower priority one and execute.

 

Having looked into it a bit more, all timed loops have a priority above 'high' and below 'time critical'. While loops take the priority of the VI that calls it. 

There's a very good guide on how the priorities/scheduling works here. Their suggestion is to have only one 'time critical' task per CPU.

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 5 of 5
(3,952 Views)