LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using simulations for online control?

Hi
 
When using Labview 8.2.1 what is the best way of implementing model based control, can the simulation environment, which has some nice transferfunction features be synchronized in a timed loop, to do online control in a real time system. I couldn't find an input in the simulation loop triggering the simulation with the timed loop rate. An example would be nice. Also is it at all possible to change integration algorithms, or should I make the desired adjustments myself.
 
Best Regards
 
soeren  
0 Kudos
Message 1 of 19
(4,039 Views)

Hi soeren

1) If you double click the simulation loop and choose the 'Timing Parameters' tab, you have to check the 'Synchronize loop to timing source' box.

Then if you expand the inputs on the left hand side loop you will see the 'Source Name' appearing. This is where you can wire in an external timing source.

2) Create a timing source and wire it to the inputs of the timed and the simulated loop that you want to sync. The timing source can be the 1KHz clock Windows use

or the 1MHz clock that can be found in the latest NI Real time controllers.

3) Determine the rate at which the loops will run. The simulation rate has to be expressed in seconds and the timed loop rate will be in ticks ( for a 1KHz source the tick will be 1 msec). The photos attached depict two loops that are synchronized to run every 10msec. Please note that you need to choose a Fixed step solver from the simulation loop configuration box.

With regard to the integration block, it's behavior will depend on the ODE ( Ordinary Differential Equation) solver you choose. Therefore, you can play around with the simulation loop parameters to find out which method gives you the most meaningful results.

I hope that helped,

 

Kostas

Download All
Message 2 of 19
(4,019 Views)

Hi

Thanks for the answers, I'm using Labview 8.2, so my configuration parameters are not exactly as you depict them, but pretty close. Instead of the "Synchronize........etc." I can check a box called Software timing and I'll check if this works. I would like to place the simulation loop inside the timed loop because I have a case stucture with different control strategies, do you think this would cause any problems?

Thanks again

soeren

0 Kudos
Message 3 of 19
(3,998 Views)

Hi,

 

why don't you try placing the case structure in the simulation loop instead?

 

Thanks,

KostasB

Applications Engineer NI UK & IE

0 Kudos
Message 4 of 19
(3,986 Views)

Hi

The reason why I wan't the simulation loop to be inside a case, is that, I in the other cases I'm using the PID from the "Control module", which does not need to be inside the simulation loop. I could probably implement my model based controls by using other instances from the "Control module", but there are some advantages which can be gained by directly typing in transfer function which can be done in the simulation loop.

I have tried some of the solutions which you suggested, and now the simulation loop is placed inside my control case structure, but I still have a few issues.

I'm have the simulation loop inside a case which is inside a timed loop, the simulation and the timed loop at running at the same frequency 10 Hz, on the same 1 kHz clock. I have the simulation time starting at 0s and finishing at Inf s. The problem is that whenever I switch to the simulation case, all the other stuff happening ouside the simulation stops. I think i'll try messing around with the priority of the simulation loop.    

0 Kudos
Message 5 of 19
(3,979 Views)
Trying to solve these issues with syncronizing a simulation inside a timed loop, for online control, resulted in this example, which nicely illustrates my problem. I have put some indicators on the loop index of both loops, with the possiblity of changing some of the relevant parameters. The issue is that when the Simulation loop is connected, everything else in the timed loop is ignored. Does this mean that it is not possible to use this simulation environment in an applikation for real time control, but only for simulations?
 
Hope someone has inputs.
0 Kudos
Message 6 of 19
(3,960 Views)

You can use the simulation environment for real time control. In your program you placed a simulation loop with infinite end time that will never end as there is no stop button. You

need to click the abort button to exit the program. Have a look at the attached VI and let me now if it helped.

Thanks,

KostasB

Applications Engineering NI UK

0 Kudos
Message 7 of 19
(3,956 Views)
Hi
 
Thanks for the input. I really need the case structure to be inside the timed loop, because I actually have a case containing 4 different control algorithms, which I need to switch between and all my DAQ (from my cRIO) is in the timed loop. I tried your approach, but moved the case back into the timed loop. And the time loop index counter starts counting if the halt simulation button is wired to some logics stoppind the simulation loop after a single time step (a single time step because the two loops need to be in sync).
 
I have attached my suggestion, think external clock, had some issues, it made the timed loop finish late, så I switched to software timing, and it looks like it works. The down-side is that when ending a simulation, all integrators are reset, så I will need to add a shift register each time I introduce a transfer function or practically anything. I don't know if memory block can be used for this, but I expect them to be reset also. This is a bit annoying, because I will need a loft of shift registers. I try to implement this strategy in my cRIO vi, and hope that I can still keep relatively high sampling frequencies. If you have some comments or improvements to the vi I would appreciate it. One of the nice things (and the only reason for me using it) is the nice transfer functions etc. If it doen't work, I guess I will have to program them manually, or use the PID lag-lead filter for first order systems, and then improvise a transport delay if I need it.
0 Kudos
Message 8 of 19
(3,952 Views)

Hi, I've fooling around with some features of the Simulation module using the strategy shown in my previous post. I've tested a transfer function and a transport delay, and they won't work using that strategy, because they both are reset whenever the simulation is halted. Is there no work around this? If the simulation is not halted it will not update the other instances in the timed loop, where one would put DAQ etc.

I've attached a vi that should show the problem with the reset transfer fuctions.

 

0 Kudos
Message 9 of 19
(3,932 Views)

Hi,

the integrators have a 'reset' option. Double click the integrator and on the reset option you can choose 'none'.  If you want to run simulation loops sequentially you

could use a timed loop structure and pass data throughout the structures. When you place multiple instances of integrators each one will keep its own values.

Thanks,

KostasB

0 Kudos
Message 10 of 19
(3,923 Views)