10-02-2014 06:40 AM - edited 10-02-2014 06:45 AM
I am wondering if there is someone that could give me a hand with a simulation I am trying to run. I am trying to simulate the behaviour of a system modeled in state space form and make a controller using diferent techniques but I am having problems and cannot progress too far... It seems like the simulation loop enters on some kind of infinite loop and it cannot stop but I do not know waht else to do.... I left attach the block diagram of one of the simulation VIs I have in order that someone might look at it.
This is a model of an Inverted Pendulum System and a cart modeled in state space form and trying to see the behaviour of a pole placement controller due to a impulse imput. Initially I would want to check a non linear model I have but it was acting weird too so I replaced it with the linearized model towards the unstable equilibrium point but the VI get stuck too so I felt motivated to post it here.
(I tried to attach the snippet using the code capture tool generatin the image below, so you can download it and execute the code, but this is my first time using that tool, so I hope it will work well... I created the snippet .png and attached here using inser image... that is correct? )
Solved! Go to Solution.
10-02-2014 07:43 AM - edited 10-02-2014 07:46 AM
The snippet hasn't worked (at least for me) - so I can only comment based on the screenshot. Did you create the png using 'Edit'>'Create VI Snippet from Selection'?
It seems that you're trying to quit the loop using the elapsed time vi. This vi uses the system time, not the time of the simulation. I think your best bet for setting a time limit on the simulation loop is wiring up the 'Final Time' on the loop input node as below.
I've also added a direct control to halt the loop at any time, and indicator to display what the simulation time currently is. If you want to have a control which sets the maximum simulation loop within the simulation loop you can just use the Halt Simulation and Simuation time VIs.
10-02-2014 08:28 AM - edited 10-02-2014 08:29 AM
I used Halt function and Elapsed time because prior of doing that I was using a Final Time constant at the simulation input node and I wasn´t able to stop the loop so I thought that way was a better choice. This is the original VI that I wasnt able to stop: (I am creating it this time with the Labview native tool)
Thank you very much for the help and support.
10-02-2014 01:45 PM
In the Simulation node, shift registers could have different behavior that would explain the problem you are running into. So, if you want to 'break' the feedback node (which in general, you should not need to do that), then use the 'memory' block. This will try to behave as you'd expect.
By the way, you can look at the shipping example for linear simulation:
C:\Program Files (x86)\National Instruments\LabVIEW 2014\examples\Control and Simulation\Case Studies\Mechatronics\Inverted Pendulum\Linear Inverted Pendulum Simulation.vi
Or nonlinear simulation:
C:\Program Files (x86)\National Instruments\LabVIEW 2014\examples\Control and Simulation\Case Studies\Mechatronics\Cart-Pole\CDEx Cart-Pole Control and Simulation.vi
as a reference for your example. Notice you even reuse the animation for your application.
10-03-2014 04:42 AM
Thanks very much Barp, I´m going to check how to use the memory blocks you told me and those examples too. I have some spare time this afternoon so I could post here my conclusions.
The main purpose of the "shift registers" I added to the VI, was to set an initial value for some of the feedback variables of the control algorithm, in order to keep the dataflow paradigm.
Let me work on your advices and I´ll post here the results.
Best regards.
10-06-2014 11:27 AM
It seems to work using the memory blocks instead the shift registers.
10-08-2014 10:59 AM
yes, as I said: the variable step time solvers do use the memory block better do compute the next step time instead of the shift registers. So, within SIM, it is always better to use Memory block for your simulation.
I am glad it is working for you now...