LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I change the value of the sampling period during my simulation?

Solved!
Go to solution

I am using the PID setpoint profile vi to specify the values for the sampling period for the discrete order hold block. At t=0, I would like the value to be 0.5, and then change to 1.0 when t=5. Currently, only the value 0.5 is going to the discrete order hold block. I think this is because the block takes this value and then uses it for the entire simulation, not checking back to see if the value has changed. Is there a way to tell the block to check this value every time step and then adjust its sampling period if needed?

 

See attached code for reference.

0 Kudos
Message 1 of 2
(1,980 Views)
Solution
Accepted by topic author westerman111

What is your overall goal for the sample period? Are you going to change the value multiple times? Or only from 0.5 to 1? 

 

The PID Setpoint Profile should let you specify a profile of values to send to the Hold. It will ramp the values between though. For example if you only specify t=0 set point = 0.5 and t=5 set point = 1 then you'll see that it will ramp the set point from 0.5 to 1.0 over the first 5 time steps. If you want the sample period to remain 0.5 until t=5 is reached you will probably want three elements in the array. t=0 set point = 0.5, t=4.99 set point = 0.5, t=5 set point = 1.0.

 

If you're just completing one step, (from 0.5 to 1.0) you could use the Timestep Index from the Simulation Parameters to determine the Sample Period. Attached is a screen shot of what I mean.  

Applications Engineer
National Instruments
CLD Certified
0 Kudos
Message 2 of 2
(1,953 Views)