08-24-2023 03:45 PM
Hello!
I am in the progress of switching some programs over from cDAQs to cRIO-9040s. The main goal of this switch is to allow programs to run around my lab without the need for many laptops or computers to run the programs. Most of the programs in my lab are used to cycle test valves. These programs typically read pressure transducers and thermocouples and write to solenoid valves. I am currently programming using LabVIEW 2022. I am using the embedded UI and connecting the cRIO to a monitor to run my programs.
The general architecture is producer-consumer. The programs are set up so that an event structure watches the front panel and adds an item to the queue when a user interacts. This item is then processed by a case structure. I don't believe I am allowed to attach my entire code here per my company's policies, but I have included an image of the block diagram.
When I began running my first program on the cRIO, it would freeze anywhere between a couple of minutes and a couple of hours after starting the program. When the cRIO would freeze, I could not click on anything on the UI, including any buttons on the front panel and the cRIOs own file explorer. The cRIO would also appear as disconnected on NI-MAX. Every time a freeze like this happens, I have to power cycle the entire system to allow for any interaction on the UI.
Recently, I went through the whole code and prioritized the loops, took unnecessary items off of the front panel, replaced local variable with shift registers, and made sure there were no arrays or anything like that collecting an absurd amount of data. The last time the cRIO ran, it did not freeze for 3 weeks, but sure enough, it happened again. Are there any suggestions for how to tell why this is happening or any potential solutions to this problem? I am willing to try anything at this point!
Best,
Sarah
08-28-2023 03:22 AM
Hi Sarah,
it's very hard to tell why your program freezes. Such errors are very hard to track down, especially just with a screenshot. Just some advice for debugging: Try the "Performance and Memory" tool ("Tools/Profile/Performance and Memory...") to find VIs which are using an exceptional high amount of memory, and you can use the "Desktop Execution Trace Toolkit" to find reference leaks.
One thing I noticed on your code: you are using a lot of Timed Loops. That is not necessary in your cases and may lead to problems. In your producer loop, the consumer, the DAQmx loop and the "Data Writing loop" the timed loops make no sense because all these loops are timed by other parts of the code. The producer loop by the Event Structure, the consumer loop by the Queue and the DAQmx loop by the DAQmx Read VIs.
One last advice regarding your code style: if you pack all these wires, which go through the shift registers, into one cluster, the BD becomes more readable.
I hope this helps to improve your code.