View Single Post
  #3   Report Post  
Posted to rec.crafts.metalworking
Pete Keillor[_2_] Pete Keillor[_2_] is offline
external usenet poster
 
Posts: 327
Default PID calculations

On Tue, 23 Sep 2014 13:41:18 +0800, Stoob wrote:

On 23-Sep-14 10:23 AM, RogerN wrote:
I've seen calculations for PID in a microcontroller but I'm thinking
something is missing.. or perhaps I'm misunderstanding something.

So if Derivative = current_error - previous_error then it's just effective
for one cycle. It seems like it should be the change over a period of time,
not necessarily one pass through the loop.

One way would be to have an array of error[xx] and take the difference in
change over a period of time involving several of times through the loop.

Also, I've seen some PID that the I adjustment is in units of time.

This might not be a big deal if there is a real high resolution, but if you
have a temperature control that is heating for a 5 degree error, chances are
the derivative term isn't going to have much effect if it's calculated every
millisecond. If it's calculated over a longer period, for example how much
change in the last 10 minutes, it would be more meaningful.

I know a way to do this but I'm just looking for better ideas, perhaps more
efficient memory usage.

RogerN



You need to ping Tim Wescott who sometimes posts here - he's the guru.

Derivative is concerned with the error's rate of change, which given a
time base your calculation does. Its primary use is to reduce
overshoot in systems with a lot of lag, like an oven temperature
control.

It's also the last thing to fool with if you're tuning the controller.
For any fast acting loop, like flow or mass control, turn that damned
derivative off. And if you see an oven approach setpoint then dip
before it gets there, then oscillate gradually toward setpoint, cut it
in half.

As a matter of fact, the best thing that ever happened to me for
temperature loops, extruder barrels, that kind of thing, were
auto-tuning controllers. I used discreet auto-tuning controllers,
either Eurotherm or Omega, for barrel zones, just sent them setpoints.
Auto tuning algorithms for use in the RSLogix type control software
was coming out about the time I retired, but didn't work that well
yet.

Fast, low lag loops were easy to tune. A little p, lots of i, and
adjust either by factor of 2. Small changes are a waste of time. When
you drive it to oscillation, cut that parameter in half. Or if you
really don't want to oscillate the loop (really large motors, etc.),
sneak up on it a little slower.

Pete Keillor