• Welcome to the new Internet Infidels Discussion Board, formerly Talk Freethought.

Controlling systems with time delay?

Jarhyn

Wizard
Joined
Mar 29, 2010
Messages
14,517
Gender
Androgyne; they/them
Basic Beliefs
Natural Philosophy, Game Theoretic Ethicist
So, I have a system I'm working on and having trouble finding any other instances of people approaching the problem

Essentially, I have a thermistor, a "thing that is being heated", and a heater.

The setup is that the thermistor, the "plant" is not the thing I am really principally interested in.

The issue is that when I hit it with a PID control loop, it controls very well to target the thermistor, but this causes a problem because the "thing that is being heated" is closer to and more responsive to changes in the duty cycle of the heater than the thermistor.

The result is that the thing I'm trying to heat up has a nontrivial moment in which it's temperature is more than DOUBLE the target temperature, as revealed by a linear response of the thing (it has a heat-dependent signal, but we cannot sample this that way while the system is running 'nornally', it can only be sampled this way in test)

As a result, we have a system that is going to be ignorant of when it is overheating.

I know that I could probably resolve this with some sort of model, but what I have read on Smith Predictors does not seem to apply.

In normal operations I only have the one sensor, which can absolutely tell me when things are "stable", but which does not respond at the same rate as the target system, and cannot be used to feed back the throttle.

Is there something LIKE a Smith Predictor, for when the model has this kind of known error offset?

Essentially, the normal PID control looks like a well tuned loop that jumps and hits the temperature, but when measuring the target surface where the heat actually matters, there is an instantaneous spike in temperature right at the start of PID control to the new value in which duty cycle is obviously way too high.
 
Solution
So, I eventually got the piece of shit doing what it needed to by setting the proportional part to a tiny fraction, until a nominal 10 degree increase no longer caused spiking in the background signal.

Then small corrections to I and D in one less order of magnitude to improve stability and guarantee capture.

Apparently the coworker who claimed it couldn't be done just with a PID tune was full of shit.

(Also, holy shit PID tuning is more loosely goosey "just try what works" in a particular search domain than it is strict math... "Try positive high, try negative high; try low until low enough. Tune I to level (same search pattern as P, but searching small first, apparently in same domain of positivity as P). Tune D to stability, same...
I have not seen Smith predictors before and I designed control systems. Looks like a very early look at disgial control systems. In modern usage the z transform the link takes a continuous time S domain system and converts it to a discrte time(digital) system. Z is a unit time delay analogous to a continuous time integrator.

Oppenheimer's book Digital Signal Processing still is a good intro to Z trasforms as is Hamming's old book Digital Filters.


The most universal common control technique for analog and digital including temperature is PID, proportional-integral-derivatve.

proportional - algebraic difference between set point and output, instantaneous error
derivative - time rate of change of the error
integral - time integral of the error

The term is the algebraic sum of proportional + derivative + integral. Poles and zeros. Integrall is a lag or delay. The lag can be the termal mass of the controlled element like water. Lag s slow down, derivatve is a lok ahead go faster. The proer comination of the proprtional and integral term along with the proportional gain defines stability. In the trditional analog PID controllers there are dials for propetional gain, and the ind thermal and derivative terms. One set them by trail and error.

In modern digital controllers there can be autotuning functions.

Simple proportional control can work fine. PID allows tailoring and optimization of time response, accuracy, and overshoot, but can lead to stability problems..oscillation and ringing. PID theoretically reduces error to zero over time.


You will need to look up the basic feedback equation and PID. Or get a control systems book. Understanding Bode plots and how it indicates stability is basic.


It is nearly impossible to describe in words. Describing a feedback system with words leads to an impossible circular train of thought.

There are books and applcation ntes on setting PID parmeters.

A thermistor and a heater combo is as common as grains of sand, so to speak. Without some theory you are shooting in the dark.
 
I have not seen Smith predictors before and I designed control systems. Looks like a very early look at disgial control systems. In modern usage the z transform the link takes a continuous time S domain system and converts it to a discrte time(digital) system. Z is a unit time delay analogous to a continuous time integrator.

Oppenheimer's book Digital Signal Processing still is a good intro to Z trasforms as is Hamming's old book Digital Filters.


The most universal common control technique for analog and digital including temperature is PID, proportional-integral-derivatve.

proportional - algebraic difference between set point and output, instantaneous error
derivative - time rate of change of the error
integral - time integral of the error

The term is the algebraic sum of proportional + derivative + integral. Poles and zeros. Integrall is a lag or delay. The lag can be the termal mass of the controlled element like water. Lag s slow down, derivatve is a lok ahead go faster. The proer comination of the proprtional and integral term along with the proportional gain defines stability. In the trditional analog PID controllers there are dials for propetional gain, and the ind thermal and derivative terms. One set them by trail and error.

In modern digital controllers there can be autotuning functions.

Simple proportional control can work fine. PID allows tailoring and optimization of time response, accuracy, and overshoot, but can lead to stability problems..oscillation and ringing. PID theoretically reduces error to zero over time.


You will need to look up the basic feedback equation and PID. Or get a control systems book. Understanding Bode plots and how it indicates stability is basic.


It is nearly impossible to describe in words. Describing a feedback system with words leads to an impossible circular train of thought.

There are books and applcation ntes on setting PID parmeters.

A thermistor and a heater combo is as common as grains of sand, so to speak. Without some theory you are shooting in the dark.
More, I already know about PID tuning. It's more that the PID system...

There's no way to tune it best I can tell to make it not throw the full duty cycle behind the coil.

The issue is that the heat doesn't reach the thermistor as fast as it reaches the chip that needs to be held at a steady state, so the PID controller says "oh, no reaction? Must need more..." And the whole thing ends up running the temperature on the chip to double the desired output.

As far as Smith Predictors, my thought was to use a modified PID with a Smith Predictor, as per a couple papers I saw on the subject, but the idea there is simply controlling it with respect to the plant, and I have TWO plants, a real and a measured plant, and they respond at different rates and time offsets.
 
The lag you described would usually be compensated by the derivative term. There is always a finite lag in any control system. The derivative term is a 'look ahead' that initially increases the controller response. Canceling or commentating a lag with a lead or derivative term is called pole-zero comensation.

Somebody I knew used a heater to heat a bird cage. He put the sensorr in the cage but ignored the lag through the air from the heater to the sensorr, and the system limit cycled. Moved the heater closer and it worked fine.

Like I said I never heard of Smith predictors and never saw it any text. You are probably going down a rabbit hole.

You have three terms to play with in PID and for most routine applications that should be sufficient.

I designed a PID system to control a laser diode temperature using a micro controller. Wrote the code.

Draw a sketch of the system using standard control system blocks that include the forwad and feedback paths and the PID terms. Write out the PID equation, plug in the values, and then simulate it. That is what I would do.

If you are trying to work it out uising words without the theory good luck with that.

Offhand Id say you are missing something or you do not now enough theory. Are you using a commercial off the shelf controller? If so the manufacturer may have a support function.

If it is work related I'd suggest finding a licensed professional engineer with process control experience in your area. I spent several years at an engineering company in part bailing out people who got in over their head trying to save money.
 
So, I have a system I'm working on and having trouble finding any other instances of people approaching the problem

Essentially, I have a thermistor, a "thing that is being heated", and a heater.

The setup is that the thermistor, the "plant" is not the thing I am really principally interested in.

The issue is that when I hit it with a PID control loop, it controls very well to target the thermistor, but this causes a problem because the "thing that is being heated" is closer to and more responsive to changes in the duty cycle of the heater than the thermistor.

The result is that the thing I'm trying to heat up has a nontrivial moment in which it's temperature is more than DOUBLE the target temperature, as revealed by a linear response of the thing (it has a heat-dependent signal, but we cannot sample this that way while the system is running 'nornally', it can only be sampled this way in test)

As a result, we have a system that is going to be ignorant of when it is overheating.

I know that I could probably resolve this with some sort of model, but what I have read on Smith Predictors does not seem to apply.

In normal operations I only have the one sensor, which can absolutely tell me when things are "stable", but which does not respond at the same rate as the target system, and cannot be used to feed back the throttle.

Is there something LIKE a Smith Predictor, for when the model has this kind of known error offset?

Essentially, the normal PID control looks like a well tuned loop that jumps and hits the temperature, but when measuring the target surface where the heat actually matters, there is an instantaneous spike in temperature right at the start of PID control to the new value in which duty cycle is obviously way too high.
Can you not just introduce a mandatory and arbitrary delay? When actual temperature is much less than target, this will cause the heater to run at fixed intervals, and when actual is close to target, to run as required.

Something like:
Code:
Do
    If MeasuredTemp<MinTargetTemp Then
        StartHeater
        StartTimer
        If MeasuredTemp>=TargetTemp Then
            StopHeater
            If Timer > X Then
                Do Until Timer > Y
                Loop
            Fi
            ResetTimer
        Fi
    Fi
Loop

Selecting a value for X that is a small fraction (maybe 10%?) of the minimum time expected for the system to reach TargetTemp from a cold start, and a value for Y which is X + the maximum time required for the thermistor to catch up to reality and give an accurate reading, you should get a slower, and stepwise, initial heat-up, then a much smaller overshoot problem as the system temperature approaches the target.

It’s a very crude approach, but as long as you can tolerate a bit of noise, it should work. Set TargetTemp to somewhere in the middle of the range of acceptable operating temperatures, and MinTargetTemp to the lowest acceptable operating value.
 
So, I eventually got the piece of shit doing what it needed to by setting the proportional part to a tiny fraction, until a nominal 10 degree increase no longer caused spiking in the background signal.

Then small corrections to I and D in one less order of magnitude to improve stability and guarantee capture.

Apparently the coworker who claimed it couldn't be done just with a PID tune was full of shit.

(Also, holy shit PID tuning is more loosely goosey "just try what works" in a particular search domain than it is strict math... "Try positive high, try negative high; try low until low enough. Tune I to level (same search pattern as P, but searching small first, apparently in same domain of positivity as P). Tune D to stability, same as I.")
 
Solution
Analog PID controllers had three knobs to set the PID constants.

For routine PID appicatiibns like temperature controls someone ignorant of control systems set the three variables by experiment. The problem with appications like a temperature controller is deriving a model. If you have model for the load or plant if you wnat, then finding the compensation values are straightforward.

For a one off application it is a lot faster and simpler to just do it emprically.

A simple test to see if yiu are close to instability is to perturb the output and look at the time response. When I was working on a PID for a laser diode temp controller I dipped it in cold water.
 
Analog PID controllers had three knobs to set the PID constants.

For routine PID appicatiibns like temperature controls someone ignorant of control systems set the three variables by experiment. The problem with appications like a temperature controller is deriving a model. If you have model for the load or plant if you wnat, then finding the compensation values are straightforward.

For a one off application it is a lot faster and simpler to just do it emprically.

A simple test to see if yiu are close to instability is to perturb the output and look at the time response. When I was working on a PID for a laser diode temp controller I dipped it in cold water.
So, on the subject, two things have been done since that worked. One, the system output was scaled down.

Much of the overshoot was being causes because too much power was available.

I found some values around which I can manage the scalar value, and a scalar adjustment per degree of temperature that will give the heater enough power to reach the temperature.

Next, I am adding a low-pass filter on the output. Maybe I have to tweak the derivative term a bit but that's fine by me.

Even so, at this point the sensor has yet another annoying effect that has been exposed by fixing the PID loop: when the heater runs, as a function of requested heater duty, there are instantaneous EM effects on the sensor in addition to the delayed thermal effects.

Next week I get to track down and isolate what the sources of variation are on that front, from blowing hot air against the chip, to driving the heater with an external current source, to direct duty cycle modulation, to running the heater circuit through a resistor to see if and when the signal changes absent changes in real heat.

Also tweaking my low pass filter.

Yeah, low-pass is easy.

Until you need to do it in fixed width decimals, because that's what all the coefficients are typed as...
 
When driving an inductor with a rectangular wave inductive spikes can create electromagnetic interference. You would need a scope to see it. Usually a snubbed is placed across the coil to absorb the spikes. Non inductive resistors are preferable to coils when being driven by pwm. The inductance potentially affects the feedback loop.

There should be an analog low pass filter in series with the sensor feedback signal that crosses 0 db well before the switching frequncy.

The general feedback w equation is

output/input = [ (1/Afwd) + Afb]

Afwd is t forward gain including tge pwm and load
Afb is the feedbak gain

For a simple non invert OP amp circuit with a voltage divider feedback

output/input = 1/ [(1/Aol) + (r2/(R1 + R2)]

Aol is the op amp open loop, proportional, gain.

The general idea is to make the forward gain high enough such that the system performance is dominated by the feedback term.

For an Aol of 100,000 and equal feedback resistors foe an input of 1 the output equals 1.9 . Increasing proportional gain leads to stability problems. Proportional gain determines steady state accuracy and regulation. Higher proportional gain reduces change in load temperature as ambient changes.

During a transient the derivative term temporarily increases the amount of power to the load proportional to the rate of change of the load. It speeds up the transient response, but at the expense of causing salability problems.

The integral term is a runing average that resppnds to long term trends and therteicaly reduces the reror to zero. A delay, whichc can also lead to stability problems.

Also where you connect the return wire for the sensor matters. You want to keep the rteruns for the heater and the sensor separated. Put a capacitor acoss the sensor bias voltage at the sensor.

Driving an inductance with a constant current source can be problematic if you inpt the current.
 
I had a lab exactly like that when I was a student.
You write a code and then run on actual system with heater. Sufficient to say most students failed. Later I realized that the algorithm which would most likely have worked would have been the following:
1. turn heater on for a short time
2. see what happens and estimate parameters of the body - time delay, "inertia", heat capacity, heat loss.
3. run heater for real but at slightly shorter time/power that is required.
4. see what happens.
and so on.
 
Back
Top Bottom