Real-Time Measurement and Control

Showing results for 
Search instead for 
Did you mean: 

cRIO VISA Write/Read not executing due to priority?

Go to solution


I have a cRIO-9047 that is recording some data from a serial device and a few c-series modules (ARINC, digital I/O, analog voltage). Since I dont have control over the rates of the data in most cases (serial = 60Hz, ARINC =32Hz and 64Hz), im over sampling in parallel while loops and recording tag data in a timed loop (producer samples the data, consumer writes the data to file)


I noticed that after expanding the code to include more parallel loops for addtional I/O and functionality and adding a time-critical while loop for sampling tag data from the other parallel while loops that the initial VISA serial Write (before the VISA serial read loop that to tells the serial device to start transmitting data) was hanging up and not executing(no errors). This would prevent the code from entering the VISA serial read loop that was reading the data from the serial port. 


Did some testing and found out the following.


1.(not a permanent fix) highlight execution, which allowed the initial write function to execute and then proceed into the VISA serial read loop. The VISA serial read loop would then only execute while highlighting execution turned on/off for each loop iteration. any time highlight execution was turned off, both VISA serial read/write would hang with no errors. 


2. (permanent fix) Set the VI's that contained the VISA serial read/write to "high priority". This allowed the functions to execute, but I fear that I may be starving another loop of resources if the issue is resource based. CPU loads showed to be less than 20% with transient spikes in the 50% range. 


3.(permanent fix) Optimized my code a bit in other parallel while loop to reduce CPU load, I did this by requesting a specific number of elements from the DMFA FIFO rather than polling if data was available and by splitting my logging loop into a producer consumer architecture so that File I/O was no longer in a timed while loop. This allowed me to put the VISA serial read/write VI's back to "normal priority" without hanging. CPU loads show to be consistently less than 20%


The issue seems to be CPU load and priority based, but I don't have definitive data to say that is true. I don't trust distributed system manager to update the CPU loads fast enough to use those as benchmarks. When I set the VI's with the VISA functions as high priority, the problem went away. When I optimized my code, the problem went away. But I know I was not maxing out the CPU's of the cRIO-9047, so what's the deal? 

0 Kudos
Message 1 of 2
Accepted by topic author srs14

I think I found the issue.


It appears that it was a thread/execution system/priority issue happening in the background. I believe the VISA functions were never running due to being on a single execution system with all my other VI's ( I assume the VISA functions were lower in priority). I had 8 parallel while loops and by default, all my VI's were set to execute on the "standard" executions system in the VI properties. After assigning all my VI's in the parallel loops to specific execution systems, the issue appears to have gone away. 

0 Kudos
Message 2 of 2