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?
Solved! Go to Solution.
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 ...
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?
I'm not familiar with how a Control/Simulation Loop works, and whether or not it is called and/or exits ...
Hah, me neither...
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 ...
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!
Great! You should mark your "Solution" as the "Solution", which helps other Forum Users who have a similar problem "find the answer".