07-22-2015 06:09 AM
Dear community members,
I've been working on a CompactRIO project for about 2 months now. I've started with zero experience with LabVIEW and thanks to the large amount of tutorials and these forums I've been able to get everything I needed to work so far, so thank you for that! Unfortunately though, I'm running into issues with CPU usage on the cRIO system at the moment.
My current system reads out 9 values from various sources (temperatures mainly) at a rate of 100S/s. These values are moved into a RT FIFO Shared Variable and logged using the Producer-Consumer principle. The system can aquires this data just fine without logging while using roughly 36% CPU. When I turn logging on, the usage goes up and stays at 99%. I figured I was writing too often, so I increased the buffer size and started logging at 50Hz instead. CPU was still 99%. Then I moved to logging at 10Hz, CPU still at 99%. However, when I look into the TDMS files I find that I am not missing any samples.
When I search the internet for relateable issues I find people logging arrays 100 times the size of mine at rates running into the kHz region before they run into trouble. I feel like I am missing something obvious here but I can't find it. I've attached the code. I've added some notes in the code as well which relate to my troubleshooting attempts. My apologies for it being a bit of a jungle perhaps - the problem should be inside the first case structure inside the big main while loop.
TL;DR: Only logging 9 channels at 100S/s in TDMS, CPU at 99% whatever I do. What am I doing wrong?
P.S.: The Shared Variable 'disc data' is Array of Double, RT FIFO Multi-Element with Number of Arrays: 200 and Numer of Elements: 9.
Solved! Go to Solution.
07-22-2015 06:58 AM
Ruben92 wrote:
My current system reads out 9 values from various sources (temperatures mainly) at a rate of 100S/s. These values are moved into a RT FIFO Shared Variable and logged using the Producer-Consumer principle. The system can aquires this data just fine without logging while using roughly 36% CPU. When I turn logging on, the usage goes up and stays at 99%. I figured I was writing too often, so I increased the buffer size and started logging at 50Hz instead. CPU was still 99%. Then I moved to logging at 10Hz, CPU still at 99%. However, when I look into the TDMS files I find that I am not missing any samples.
How did you change the logging rate? Besides, since you have the FIFO turned on, it is so that you will not miss any data. So you are logging as fast as you can trying to get all of the data. I do not think you actually want this. From what I can tell, you just want to log the current values. Therefore, I would turn the FIFO OFF on the shared variable and add some sort of wait in the logging loop.
07-22-2015 11:50 AM
The logging rate should be controlled by the timeout value in the Shared Variable read block. If I diable the FIFO I will most likely miss a few values since I can't oversample some of my thermocouples. Either way, does that mean this is simply the best the cRIO can do?
07-22-2015 01:35 PM
@Ruben92 wrote:
The logging rate should be controlled by the timeout value in the Shared Variable read block.
Not true. The timeout is just how long to wait for data to enter the FIFO if it is empty. So if there is data in the FIFO when that node is called, it will immediately return the next item in the FIFO. You are not throttling the loop at all.
@Ruben92 wrote:
If I diable the FIFO I will most likely miss a few values since I can't oversample some of my thermocouples.
That makes no sense at all if you set the logging rate. If you want to log the current data every 50ms, then you will not log all of the data. If you absolutely care about every single value, then just use a normal queue. It is easier to understand and works more efficiently. There are also tricks to read the queue until it is empty and then log the bulk of data at once. This will help your performance some.
07-23-2015 02:52 AM - edited 07-23-2015 02:54 AM
@crossrulz wrote:
@Ruben92 wrote:
The logging rate should be controlled by the timeout value in the Shared Variable read block.
Not true. The timeout is just how long to wait for data to enter the FIFO if it is empty. So if there is data in the FIFO when that node is called, it will immediately return the next item in the FIFO. You are not throttling the loop at all.
@Ruben92 wrote:
If I diable the FIFO I will most likely miss a few values since I can't oversample some of my thermocouples.
That makes no sense at all if you set the logging rate. If you want to log the current data every 50ms, then you will not log all of the data. If you absolutely care about every single value, then just use a normal queue. It is easier to understand and works more efficiently. There are also tricks to read the queue until it is empty and then log the bulk of data at once. This will help your performance some.
Unless he means sending the data to the consumer loop at full rate and accumulating the data until writing every X ms. This decouples the disk activity fromt he primary data source a little, perhaps resulting in better performance if teh disk is truly the limiting factor.
But as an aside: Are you opening and closing the file each write? That will slow things down considerably. You should be able to stream faster than that. What file format are you writing to?
Disclaimer: I an't open the code, I only have LV 2012 so my comments may be way off track
07-23-2015 04:55 AM