LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing References in RT cRIO project

I'm doing my first cRIO development, haven't taken any RT or RIO courses, but did look through the training material and have searched through examples and what not. Feel like I got a pretty good grasp of things and even figured out how to use arrays on the FPGA side of things. 

 

My question is more of a style question, I guess, but does it matter what I do on the right side of my loops? I mean, style-wise, I know closing references, killing queues, and flushing memory is just plain good code. But in an RT or RIO environment, specifically, a unit that's going to be placed in the field transfering data back to a host with no RIO-specific UI, the loop is never going to stop, unless it gets powered down, and then it really doesn't matter what's on the right side of the loop as it won't make it there. 

 

Am I wrong here? Should proper style prevail, just for good coding habits, or does it just act as useless clutter considering the fact that it will never be called?

 

-Ian

0 Kudos
Message 1 of 5
(3,594 Views)

Hi Ian,

 

When working with RT targets, good coding habits such as closing references, queues, and clearing memory provide safe exit strategies when you exit the RT application. This is partly the reason we urge programmers to use a Stop control instead of "aborting" to exit an application because it may leave references in memory which can lead to leaks in the future. In the end, these operations, which are usually placed on the right side of these loops, have a bigger impact on your application when you have nested while/for loops operating on computer memory. Performance problems frequently occur when programmers don't close out references to these data structures. I hope this answers your questions. If not, please let me know.

 

 

Aldo A
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(3,566 Views)

Ian,

 

Stick with the good coding habits.  Remember that you want your code to run clean in development mode as well. 

0 Kudos
Message 3 of 5
(3,556 Views)
Its only my assumption, but there's probably no way to enforce a power downn sequence without relying on some sort of input from the user is there? The RIO doesn't hold enough power when the plug is yanked to get a few cycles out of it, does it?
0 Kudos
Message 4 of 5
(3,552 Views)

Hi Ian,

 

Although some of our cRIOs have an internal battery, if you yank out the external power supply, you will not be able to get extra cycles out of it. The internal battery serves the internal clock of the cRIO.

 

 

Aldo A
Applications Engineer
National Instruments
0 Kudos
Message 5 of 5
(3,537 Views)