06-27-2022 11:26 AM
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
07-01-2022 03:20 PM
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:
07-19-2022 08:37 AM
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
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.