Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

unstable data recoding frequency problems with Real time Scanning Mode

Hello,

I'm trying to use the CompactRIO 9045 module to record data and send it to my host computer with a real-time scanning module, FIFO buffer, and share variables.

The data record frequency is controlled by Labview real-time while loop with 100ms, so that means it will record data every 0.1s.

But after checking the time difference, we finally find that the record frequency is not stable. Most of the time, it is 0.1s, but sometimes, the difference will reach 0.7, even 1s.

Is it normal with real-time scanning mode? Or is there something wrong when I programmed with the buffer for transporting data from CompactRIO to the computer?
Thanks a lot if anyone can help me solve this problem or check the program. We have already checked the program, but we don't know how it happened.

 

Thank you very much and best regards

 

0 Kudos
Message 1 of 3
(1,002 Views)

Hi,

There is no fundamental reason why you can't get the data logged and to your PC with 100msec intervals. But there is a lot of subtle things that need to be correct and lots of possible causes:

  • Is your data acquisition loop running on cRIO, and is it running correctly - is it a timed loop, is CPU usage high, have you checked the finished late status ?
  • Is the data being lost during the periods when there is missing, or is it being delayed ?
  • The reading on the PC side is non-determistic - whcih is why you are using a FIFO DMA - but if you try reading too fast then you wont' get the one sample every 100msec consistently.
  • The FIFO buffer has a finite size, and you need to check how fast data is being put into (on cRIO) and generally you want to read from it in a loop that operates faster that the read rate, but which only reads when there is sufficient data present in the buffer. If the reads are equal to or slower than the write rate, then the buffer will gradually (or quickly) fill up and then it may flush (loose data).

    There are lots of potential issues, so just a question of diagnosising and understanding.
Consultant Control Engineer
www-isc-ltd.com
0 Kudos
Message 2 of 3
(986 Views)

In addition to what Andy points to above, It's worth noting that you're using shared variables to read the data in your timed loop. 

The thing about shared variables that are causing issues here is the fact that they're.. well.. shared. The timed loop works if it has control over all the resources it needs to execute or is able to take a resource away from someone else and return it when it's done. 
 
I've made the assumption that you're comparing the t0's you're using to build your waveforms, (the get time date is not the best one to use due to its accuracy, I'd recommend the "high-resolution relative seconds") and in this loop, there is a shared resource that is stopping you from execting at your desired speed. 
I don't immediately recognize the type of IO variable you're using, so can't say if that's the cause of your issue 

AndreasPalms_0-1658237311270.png

 But your other shared variables I know can cause Issues, if you absolutely need to use shared variables I'd recommend using RT FIFO variables as they create an intermediate step between the caller and the shared resource. See: Using the LabVIEW Shared Variable - NI

 
In addition, you're engaging the LabVIEW Memory manager, that will at run time try to allocate and free up memory. This is also a shared resource (application level) and has to fully finish one task before it can start another.  In your code, I can see you engaging the memory manager lots within your loop. whenever you're changing the size needed to store data, or creating new data structures, the Memory Manager is engaged, so when you're building arrays and waveforms in this case. Instead, you should try to allocate a structure of a required size, and replace elements rather than building new structures. 

See: Memory Manager - NI

Hope this helps.

Kind regards
LabVIEW Fairy

cRIO Enthusiast
Please mark solutions when appropriate.
Unofficial Forum Rules and Guidelines
0 Kudos
Message 3 of 3
(946 Views)