fixed step solver vs. system time constant

All,

I'm trying to implement a PID control scheme for a plant that has an extremely slow time constant (1.25 seconds). I'm running the simulation using Simulink's "fixed step" solver with a "fixed step size" of 1ms to mimic the 1 kHz processing speed of the digital controller.

The strange thing is that I cannot get the system to stabilize by tuning the PID gains at a step size of 1ms...however, when I slow down the controller loop time by increasing the fixed step size to 8ms, I can easiy maintain system stability with PID control. Am I doing something wrong...the faster step size should make controlling the system easier?? Any help/suggestions is appreciated.

Thanks in advance,

-weg

Reply to
weg22
Loading thread data ...

Unless the tuning constants are proportional to the update time (with 8ms update tuning multiplying all time constants by 8, compared to 1ms update time), the only factor I can think of that might have this effect is rounding errors from too few bits representing the PID process (especially the integral term).

Reply to
John Popelish

Ditto. If you're doing the simulation all in double-precision floating point it's hard to imagine that this would happen, but if you're doing the simulation with 16-bit integers you're probably losing 10 bits just to the itty bitty integrator gain.

Reply to
Tim Wescott

You're saying that the tuning constants SHOULD BE PROPORTIONAL to the update rate in order to get the same effect, right? That's how I have it...so in other words if:

1ms deltaT, error rate=3D1/ms =3D> error=3D1...[Kp=3D8; Ki=3D0; Kd=3D0;]...= then output will be 8. 8ms deltaT, error rate=3D1/ms =3D> error=3D8...[Kp=3D1; Ki=3D0; Kd=3D0;]...= then output will be 8.

therefore, it must be a rounding error. How do I specify double precision in Simulink?

Reply to
weg22

Sorry, no. Only the time dependent constants are corrected for sample interval. The proportional term is time independent, so it is unchanged as you change sample time.

-- Regards,

John Popelish

Reply to
jpopelish

No, The sample interval T does not affect the proportional gain significantly when sampling at these rates but you can see that Ki*T could very small and get rounded down to 0.

CO(n)=3DCO(n-1)+Ki*T*error(n)+Kp*(error(n)-error(n-1);

The sample interval T also affects derivative gain term but usually this term tends to saturate or overflow.

Peter Nachtwey

Reply to
pnachtwey

double precision is the default

In any case, you probably shouldn't be using a fixed step solver. Use a variable step solver to better represent an analog plant. Then use a discrete controller with zero order holds.

When you use your discrete controller the simulink blocks show their sample time dependence as the variable T.

Reply to
Daniel Helmick

If that is so I can't see why there would be a problem.

What about the PID that runs at fixed intervals?

Peter Nachtwey

Reply to
pnachtwey

I am missing your question. You quote where I suggest using a discrete controller in combination with zero order holds. Then you ask about using a discrete PID???

Reply to
Daniel Helmick

It makes sense to calculate the system response and the PID synchronously using fixed intervals. If you update the system response with variable step solver the system response will not be updated at the same time as the PID. What values to you use then for the PID? Most variable step ODE solvers that use variable steps use cubic interpolation to find the points in between. This can't be done when a PID is also affecting response of the system. One could combine the PID and the system and solve for the closed loop system together but then things like input resolution, output resolution and output saturation are ignored. Not good.

Peter Nachtwey

Reply to
pnachtwey

d=3D0;]...then

d=3D0;]...then

I don't know the specifics, but you can find out for yourself on Simulink's webpage I am sure.

Variable step solvers are better for analog plants because higher order dynamics are represented to your desired level of accuracy. If there is any aliasing or other effects, it would likely show up.

A discrete controller is better because you are actually implementing a discrete controller.

When I run a SIMULINK model that contains both an analog plant and discrete controller with a variable step solver, both are generally represented sufficiently with no additional user input. Your question of which ODE solver is in use will be in the simulink help files. The default solver is ode45 (Dormand-Prince).

All signals are solved for at the sample times. Also, the system response updates several times in between the sample times. (Actually, the discrete controller also updates throughout each sample time, but it is the same value throughout each sample time.)

Reply to
Daniel Helmick

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.