LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resetting an array within an Control & Simulation loop

Solved!
Go to solution

Afternoon all,

 

I'm fairly new to the Control & Simulation module, so I may be missing something obvious, but the attached subvi is giving me some trouble. Each time I run it, it's concatenating the new data onto the old. I want fresh data each time.

 

What am I missing, and what can I do differently to fix it?

 

Cheers!

Download All
0 Kudos
Message 1 of 6
(1,106 Views)

You want to look for loops that involve Shift Registers or Feedback.  I notice a Feedback loop in PID Core (which is initialized on the first call to an Empty Array, but if called again, will continue to append data) and in PID Modeller (the Cluster, but there isn't "appending" here, so this one is probably OK).

 

Who calls PID Core?  I'm not familiar with how a Control/Simulation Loop works, and whether or not it is called and/or exits ...

 

Bob Schor

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

Sorry, I should have been more clear - it's the output from PID Core that's giving me problems. PID Modeller calls it - and if you run it and feed it some numbers, you should be able to see that each time you hit run, it's retaining the old data in the graph. 

 

The Feedback node is likely the root of the problem - I don't THINK I can use shift registers on the control loop, which is why I've opted for the feedback node. I hoped that by initialising it to an empty array I'd force it to start from scratch each time the subVI is called, but that doesn't appear to be the case?

 


@Bob_Schor

  I'm not familiar with how a Control/Simulation Loop works, and whether or not it is called and/or exits ...

Hah, me neither...

 

 

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

So I did a little reading (but you should have done a lot more than I, as it is your problem).  It looks to me like the Control and Simulation Loop is designed to take one set of parameters and a Transfer Function and produce one output.  If you want multiple outputs, you call the Loop multiple times (with different conditions, I presume) and can accumulate the Outputs however you want (with the ability to initialize Shift Registers, which is not possible with the Feedback Loop method you used that gets Initialized on First Call).

 

But I could be very wrong about this ...

 

Bob Schor

0 Kudos
Message 4 of 6
(1,078 Views)
Solution
Accepted by topic author AGriffiths

I've found a solution, although I get the feeling it's a workaround to the true problem rather than the best practice way of fixing it. 

 

By right clicking on the VI and going through Call Setup I've set it to reload fresh into memory each time it's called. That's not a functionality I knew existed, and I'm sure it's not an efficient solution, but it seems to have done the trick!

0 Kudos
Message 5 of 6
(1,068 Views)

Great!  You should mark your "Solution" as the "Solution", which helps other Forum Users who have a similar problem "find the answer".

 

Bob Schor

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