04-22-2013 07:45 AM
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.
Solved! Go to Solution.
04-23-2013 11:20 AM - edited 04-23-2013 11:20 AM
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.