LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

High Performance Timed Loop on NI RT Target

I am executing a timed loop with essentially no code in it and the timed loop is running off of a 1MHz clock on myRIO 1900 NI Linux RT. Timed loop period is set to 1uS; however, the fastest iteration duration is measured to be capped at 10uS. I was wondering if there is actually a cap on the iteration time of the timed loop on RT or my approach on measuring the execution time of the timed loop is wrong. 

 

0 Kudos
Message 1 of 13
(4,853 Views)

Hi pegahm,

 

I was wondering if there is actually a cap on the iteration time of the timed loop

Sure: CPU speed!

 

When you want to achieve loop iteration rates of >2kHz (with little jitter) you need to employ the FPGA of your myRIO…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(4,816 Views)

Hi GerdW,

 

But I have been able to achieve almost 100kHz on this RT (close to 10uS loop execution time) on the same target. My application is complex and could not be implemented on FPGA solely. 

The CPU of myRIO is 667MHz and I am wondering why does it take almost 6000 clock cycles to execute such simple code in my timed loop.

Do I need a more power RT target if I want to achieve 1uS on RT?

Also, I was wondering if there is a documentation from NI that would provide my detail information on what is happening in the background?

 

Best,

Pegah

0 Kudos
Message 3 of 13
(4,780 Views)

@pegahm wrote:

The CPU of myRIO is 667MHz and I am wondering why does it take almost 6000 clock cycles to execute such simple code in my timed loop.


In your example code, you are running into issues with memory allocation slowing things down (the autoindex output tunnel of a while loop causes memory to be allocated each iteration).  Try preallocating the array and use Replace Array Subset with a shift register and see if your times improve.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 13
(4,767 Views)

I did remove the indexing but that didnt help either. I have attached the most recent work.

0 Kudos
Message 5 of 13
(4,750 Views)

The other thing I would add would be to set the CPU affinity.  This avoids cache having to be moved around between cores in the CPU.  I am not expecting that to help much.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 13
(4,745 Views)

Yes, I have tried this before but that didnt help much as you predicted.

0 Kudos
Message 7 of 13
(4,722 Views)
Perhaps the reason for the "slow" execution is that you run this code interactively. Have you tried to build an exe? And in that case, evaluate the performance of the timed loop not directly after startup of the rtexe.

Regards, Jens
Kudos are welcome...
0 Kudos
Message 8 of 13
(4,718 Views)

Hi Jens,

 

Yes,  I have tried that as well. Running the code as RT Application and log the execution times on a file. However, I got the same values for my execution time.

 

My only guess at this point is that there might be overhead added due to the Timed Loop itself. 

 

Best, 
Pegah

0 Kudos
Message 9 of 13
(4,690 Views)

pegahm,

 

If you take a look at the document below, you will see that the cRIO-90xx can't run a Timed Loop at 1MHz, and a myRIO is less powerful.

 

Timing Sources Available for LabVIEW Timed Loop by Platform

 

If you need to run something that quickly, I would suggest doing just that part on the FPGA of the myRIO and then the rest of your code on the Real-Time OS. The FPGA will also allow you to do Single Cycle Timed Loops.

 

Single-Cycle Timed Loop FAQ for the LabVIEW FPGA Module

 

Regards,

Alyssa H.

National Instruments

0 Kudos
Message 10 of 13
(4,672 Views)