From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State-space in subVI creating cycle

I am trying to implement a state-space model with feedback. The model has no direct feed-through component, so it works fine, at first. However, when I try to move some blocks to a subVI, all of a sudden it detects a cycle, and won't run.

Below, you can see that the single state-space on its own works fine, but the subVI containing an identical block doesn't:

loop.PNG

Contents of ss.vi:

ss.PNG

Is there no way to avoid this? (other than just keeping everything in one VI, obviously).

0 Kudos
Message 1 of 6
(1,091 Views)

I've not used control and simulation loops before, nor state-space models, but typically in LabVIEW if you want to do this you either use a feedback node or shift registers.  Can you try one of those?

0 Kudos
Message 2 of 6
(1,042 Views)

Hi Kyle,

 

Yes, adding a feedback node removes the error, but it also changes the behavior of the VI. The controller that I'm implementing is designed to be run without a delay in the feedback loop.

As far as I'm aware, the Control & Simulation loop does not support shift registers, but I believe the same problem would arise, anyway.

0 Kudos
Message 3 of 6
(1,018 Views)

Put a loop inside of your vi. Add a shift register to that loop. Do not initialize the shift register and it should act like you want. You could then add the ability to reinitialize the vi and make it more complicated. Make the loop execute one time then exit

Tim
GHSP
0 Kudos
Message 4 of 6
(991 Views)

Hi Tim,

 

Something like this?

for.PNG

I wasn't aware that shift registers worked like that. I thought it stored the value from the previous loop iteration. I'll have to investigate further.

 

Thanks.

0 Kudos
Message 5 of 6
(973 Views)

I would put the loop inside of your vi. but that is the right thought. Here are some examples of what I am talking about. You can see how we progress from simple to more advanced as I move through the examples. You choose the version you want then you add the terminals to the vi and save it. From there you place this vi where you need to use it.

 

Action Engine Examples.png

Tim
GHSP
0 Kudos
Message 6 of 6
(958 Views)