LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine architecture, shift registers, subVI memory handling

The behavior you're seeing with the array being copied to/from the subVI is an unfortunate limitation of LabVIEW. What version of LabVIEW are you using? If you're using LabVIEW 2010 you can specify your subVI to be 'inline" meaning it actually doesn't act like a subVI call... it is as if the subVI's code is placed in the callers code. This is significantly better performance and avoids the copy. Another thing to look at is if you have any VIs being used in multiple different locations or in different loops, you will probably want to set these VI's as reentrant so it can be used by multiple callers at the same time.

 

DVRs are OK but they might not be a good idea for an RT application unless carefully used as that data set you are referencing between multiple loops is a shared resource. So if one loop is dereferencing the data... the the other loop tries to dereference the data... it has to wait for the first to finish. On RT, the best thing is really to have each loop have its own copy of the data in order to avoid shared resource issues. Then, data that is important to get between loops... use an RT FIFO. So loop A can push some data into an RT FIFO for loop B to read. RT FIFOs are not shared resources and are very high performance. I've attached an example cRIO project that uses CAN and RT FIFOs in multiple loops. Note that the code attached uses a functional global VI to stop all the loops when requested, but since that is a shared resource between loops (RT no-no) I have it set to subroutine priority and the right click option "skip if busy" set.

 

For your question on the in place element structure... this thing is awesome. I use it all the time to force labview to not make memory copies in time critical sections of my RT code. When you enter the in place element structure... items that are being unbundled or indexed are operated on by pointer not by value. If you just want to do a get... you can just usually do an unbundle but a get/operate/set is best for inplace element strucutre. If you just want a get though, do this:

inplace.png

Note that the subVI call should be inlined for best performance.

Stephen B
0 Kudos
Message 11 of 11
(557 Views)