Electronics - Control Loops
Created; 05/02/2015, Changed; 25/01/2019, 24/02/2020
Previous page; Electronics - Designing with discrete semiconductors
OrCAD 16.6 or higher AL-0013-01a
- From inspection you can see that the loop gain for the proportional control example is about 100 this is likely to be the optimal value for the total loop gain. In a simple system with one sensor one driver one significant lag component such as a heating or motion control.
- From inspection you can see that the loop gain for the proportional integral control example is about 50 this is likely to be the optimal value for the total loop gain.
- For the proportional integral controller Add; dV/dT = i/C, where i = (Setpoint-Error voltage)/22K. This sum does not help much.
- The time constant 1M.100nF of 1/10 second is the loop time constant and is set to about double the physical rise time of the system would be the fastest time and could be just unstable.
This P.I controller requires two variables be changed and this gives a good starting point.
- By comparison a nudge up nudge down (P.I) software control loop requires one variable - the size of the nudge (the proportion) the Integral being the system time constant.
Generally the filter capacitor must be a maximum of 1/5th the size of the integral capacitor. Generally 1/10th or 1/20th is normal for the filter capacitor but the smaller the more stable the loop provided higher frequency noise is managed adequately.
There is comparability between using a low Q soft magnetic, bead or common mode choke and a C + R+C network for EMC filtering to control loop stabilisation. The term circuit damping is good.
Control Loop Compensation
In the case of Motor Speed control for example, You may avoid control loops or minimise the need for a control loop, for example by;
- Use a permanent magnet (PM) or shunt wound motor which have very good self speed regulation. In the case of a PM motor the speed is proportional to the supply voltage and is largely independent of the motor's load.
- Use a stepper motor, but take care to optimise ramp up rate when getting the motor to the desired speed. If the speed is increased too slowly the stepper motor may resonate and the shaft stop rotating. This resonance issue can be minimised by avoiding loading the motor with a lot of inertia by using a flexible coupling or belt drive should resolve the issue. The electronic drive can be optimised for efficiently or low resonance ST Microelectronics have particularly good application notes on there range of ICs. The motor will also stop and not restart if stalled by loading or if the speed is ramped up to quickly.
- Use feed-forward techniques to minimise the the amount of feedback. That is will adjust the voltage, in anticipation of load changes this method also applies to amplification in general because amplifiers include control loops.
During the 1980's Japanese manufacturers such as Sanyo introduced very good quality 200 step stepper motors that were made with smaller air gaps and more rigid construction than British makers were making. They were more efficient, quieter running and cost a lot less. The quietest running stepper motors are five phase motors such as; 500 step Berger Lahr, but there are some trade off's in using these motors. A shaft encoder, motor and control can be more precise though that would introduce a small amount of control loop noise.
Similar and other strategies can be applied to other situations such as for temperature control
- Having two control loops, is very effective approach. The inner fast tight response, and an outer slow for accuracy. For example Temperature controller see manufactures of thermoelectric devices application notes which explain the approach in detail. The maths given are based on electric current but using voltage drive may be more convenient because primarily a thermoelectric device is resistive so Voltage or Current control are interchangeable in this case.
*** Picture of a PID controller compensation with ancillary functions - this is indicative but not be functional (AL-0023-) ***
How to find the constants for PID controller.
When you consider buying a second hand car; Test the suspension by leaning on each corner then release that corner in turn - the car should rise, fall then rise and stop this is critically damped, and the shock absorbers are ok. If your design to over damp the control loop will be stable under a range of component tolerance, in this case the car should rise more slowly then just stop,if you set it just right that would be in the same time as the critically damped condition this is a good safe setting. In the case of the second hand car that takes a long time to return then someone has filled the shocks with treacle or heavy grease because they are worn-out.
Include some high frequency filtering - this is usually set to a factor of 1/5th to 1/10th the value of integral constant but can be 1/100th. This will compromise the loop stability a little but it is necessary.
Start without any Integral (Capacitor shorted) or differential constant (capacitor removed)
1) Reduce the loop gain (constant or resistor) until the loop is just stable, the loop is therefore simply a proportional control. The loop error as a very broad guess might be 2% (loop gain 50-100).
2) Halve the loop gain.
If this meets the requirement then don't go any further. You a proportional controller (P only).
3) Add the differential capacitor (or constant) and progressively reduce it's value until the loop is just stable. Double the capacitor value, and fix it at that.
The loop is now stable just over damped. To give yourself more margin you can quadrupling the capacitor and halving the resistor again. If that achieves the requirement leave it at that Proportional Integral controller but with no Differential Control term.
I have to not got a good strategy for the Differential control but the following works somewhat. It is rarely necessary to have a differential control term.
4) Progressively increase I and reduce the D constant and progressively reduce loop gain P until you can go no further. Then give yourself a factor of two to four margin by reducing I and increasing D and P.
A P and PI controllers can be set empirically quickly, but PID is a bit more fiddly to set-up, and I am not sure of the best method. Using the above method increases the frequency of the loop jitter and reduces its amplitude.
A method of finding the approximate value of the Integral term (capacitor) is to increase the gain as (1) measure the free running frequency. Halve the gain (2), then fit a capacitor which gives a time constant equal to the period of oscillation, or double that period. Then proceed to (3).
Look at Wikipedia on PID control you will see that they show you how to derive the terms for critical damping, whereas I have describe how you achieve over-damping, gives you a good solution with a margin for variation in load and tolerance. What you need to consider and experiment with is how the the PID will behave after the item under consideration has had a number of years use. For example shaft encoders often have shaft sealing which will wear in quickly and the amount of motor effort need to turn the encoder will reduce.
Class D amplifier formed by a relaxation oscillator - single control loop.
There are alternatives. I have not made the first variant which because for me figuring out if the two stage output filter could be difficult to compensate for and therefore potentially oscillation. In the case of the first variant my concerned about oscillation can be be dealt with using LTspice to help me. In any case the oscillation is an avoided but the complication and risk is a trade off with lower output chopping frequency ripple noise - I don't recommend this first design.
I have made the second circuit and it works very well as the LTspice model. But it is straightforward and therefore their would have been little benefit in modelling it. In this case the use of LTspice would have done nothing for this example.
Class-D amplifier with good output linearity but not accurate AL-0021-01E. LTspice IV
The circuit can be described as a variable analogue input Pulse Width Modulator with an output filter. The type of circuit is a relaxation oscillator. Coilcraft also stock a range of chokes for Class-D amplifiers with a flat magnetic characteristic but I have not select those. The chokes selected are particularly small, efficient with low magnetic field leakage type made by Coilcraft but Vishay also make similar parts - The feature of these chokes is that the winding is created and then the ferrite is extruded around the winding so that there is no join to leak magnetic field and the copper winding is very small because the ferrite is very close to the winding resulting in a very short low resistance electrical path.
Features of the circuit;
- The circuit is more linear over a signal range than the variant below, due to the accurate op-amp based integrator stage. The circuit should be optimal as a low distortion amplifier although not particularly voltage accurate, such as an audio amplifier.
- The output low pass filtering is not part of the feedback loop and therefore the feedback is simple.
- Conversely the feedback is part of the relaxation oscillator circuit making the circuit complex. Consequently the circuit is responsive in correcting for power supply voltage and power transistor's on resistance fluctuation.
- The circuit is stable with the resistive loads shown. The frequency response of this circuit depends on the load and is >10KHz. At 1 ohm load appears to give a false high frequency response value with the LTSpice but also gives a very low frequency response with 10 ohm load.
- The circuit has a low part count and only parts relevant to the simulation tools are shown. The circuit requires the use of comparatively large output inductors and there is a lot of power circuiting in the first inductor with losses. Even so this compromise is worthwhile in an audio amplifier in which distortion would be the most important parameter.
Out standing design work;
- The MOSFETs are not the most suitable but were available in the LTspice library.
- Comparator U3; The propagation delay of this part is a significant parameter in setting the operating frequency.
- The circuit could be implemented more cheaply with better control using a small micro-controller instead of the operational amplifier and comparator. There may be an HCS08 8 pins with pins; +V, 0V, debug/program, reset, PWM, 2x analogue input, 1 spare port pin for example?
- The output drive could be replaced by a full bridge power driver IC and http://www.st.com such as L6208 may be a suitable IC designed for stepper motor drive. But this may not be a cheaper solution but these types of ICs have various overload protection features built in.
Class D amplifier with an outer and an inner control loop.
Both circuits below have surprisingly simple feedback and loop compensation strategies and both are sound.
The above class-D amplifier (AL-0021-02G) was created using LT Spice IV follow the link for discussion on simulation tools. The circuit has a switching frequency of ~100KHz to 200KHz and the full bridge variant of this circuit has a frequency response of >200Hz depending on the load up to -3dB at 1KHz. A better -3dB bandwidth of ~1.5KHz was observed in the above half bridge circuit as shown above. The circuit is also known as a switch-mode amplifier.
- This circuit is shown driving 2V peak to peak with a pulse input settling in 1-2mS. With 1 ohm load the output looks under damped but with 10-100 ohm output looks over damped at higher load impedances the circuit oscillates at the frequency determined by the output filters L.C. There is an oscillator ripple current of 200mA to 20mA for 1R to 100R load that could be reduced by increasing the operating frequency.
- The block on the left shows the slow but more accurate outer control loop amplifier than the inner loop. This could be a digital control and the parameter that is being controlled need not be voltage but any parameter. This circuit is stable without the R+C (across C5) proportional integral element in the outer control loop.
- The circuit is stable with a resistive load but a reactive or slow response load would need more compensation in the outer control loop amplifier. But the circuit also works with a two stage L.C+L.C output filters tuned to different frequencies but in that case the circuit can not tolerate higher value load resistance. The circuit works with a load of up to 100 ohms but becomes an oscillator with a load of 1K. The circuit works better with lower values of output capacitor C4,8 = 1.0uF this probably could be reduced to 100nF keeping the filters resonate frequency comfortably below the oscillator frequency under all load conditions?
- A variations of this circuit using 47uH + 2.2uF +47uH + 4.7uF output filters in each half bridge driver would require a lot of low pass filtering in the outer loop to prevent the circuit oscillating, but beneficial has lower output ripple. This variant does not have a faster pulse response and the bandwidth is about 800Hz to the -3dB point at best.
- The best use of this circuit is an accurate variable D/C voltage source as opposed to an audio amplifier. This is also because there is some distortion with small AC signals.
- The dash link and cross alternative shown a simplified oscillator circuit. There is no advantage in doing this because the inner loop would not be correcting for output transistors drive losses.
- The design is incomplete and the working component values have been found by trial and error as opposed to calculation that I show in the many examples elsewhere. This is a variation in my normal approach to design that is made easy by using simulation tools. The strategy is similar to how a child would try and see but the maths is still necessary to carry out the worst case design. A try-and-see strategy is validity.
- The output transistors were selected from the LT Spice library but that library does only has some N-channel MOSFET thermal models for the transistors available.
The circuit is simple but it requires the use of comparatively large output power inductors and with a lot of power circuiting in the inductor with consequent high losses.
- An alternative approach that works well is to use a variable buck converter power supply followed by a transistor bridge forming a polarity switch with a linear element to better control the small signal case. Such an approach has less power circulating in the inductor and less losses.
The circuit as it is could be implemented more cheaply with better control using a small micro-controller instead of the (outer control) operational amplifier Alternatively both the outer control and the integrator comparator function could all be integrated into a micro-controller. There may be an HCS08 (NXP originally Motorola), 8 pins with pins; +V, 0V, debug/program, reset, PWM, 2x analogue input and 1 spare port pin for example that would do it?
Two Control Loops - inner and outer;
Consider being in a room with the heating on and the room thermostat handy. The two loop strategy for getting the room to a comfortable temperature is. The out-loop usually should have a longer time-constant than the inner loop in order to prevent oscillation.
1) If I am cold and I can hear the heating going, then;
2) If I find the room becomes warm enough before the thermostat clicks off, then I turn the thermostat down until it just clicks off.
3) Alternatively if the room does not reach the desired temperature before the thermostat clicks off, then guess how much warmer I would like it then increase the temperature setting of the thermostat by that amount.
4) Leave it for a while then go to (1) if not satisfied.
What you are doing is being the outer control (nudge up/down the Integral part of PID) with, importantly, limits necessary to prevent the set point (thermostat in this case) running away.
This gives you a good understanding, but not all controllers are simply on/off control with dead-band. As I said nudging the set point is the Integral term. To avoid set point running away clamp the set point so that it can not be set much higher or much lower when the temperature is already going in the correct direction.
Pictured is a Gill 3-axis Anemometer which senses wind speed, pressure, and direction data using ultrasonic transmitters and receivers. I worked on an environmentally monitoring project some years back, for another company which incorporated a Gill Anemometer. My part in this project was to develop the electronics for an infra-red spectrometer, for sensing quantity of CO2, NO, Oxygen. The spectrometer was formed from an under driven low voltage filament lamp at the top of the Anemometer and a long wavelength temperature controlled infra-red light sensor below. There was also a rotating disk with a number of light filters. There was an analogue control loop, for the motor and another to control the temperature of the infra-red sensor.
The diagram right is of a fairly standard digital averaging filter. It gives a fast response time if there is a big change but then the averaging progressively increases so that the reading becomes stable.
- This looks like an analogue meter where the needle is fluctuating but you can interpret by-eye where it is fluctuating around. Except that the by-eye judgement is done for you.
- An improvement in this design of filter is to add the newest sample to the sum and subtract the last sample from the sum. In that way you don't need to keep summing the whole data set each time a new sample is added.
- The amount of the average increases as the period of time increases from the detection of the fluctuation. In this case I have set the average to increase by one for every two samples collected. That is so that the oldest samples near the fluctuation are dropped.
- The diagram is a test control panel for the above averaging block diagram.
- This digital filter is not like an analogue RC low pass filter. A Resistor Capacitor type filter filters less as time increases and as a rule of thumb after five time constants does not filter. But in a digital filter like this simple low pass filter the averaging is set at a precise number of samples say 30 seconds and all the data within the set has equal value but all older data is removed does not count therefore the filter is as a precise length block.
To avoid control loop jitter
- Use an open loop system.
- Trade accuracy for simplicity and predictability.
- Such as a modest proportional control loop with no Integral or Differential terms.
- Chose current or voltage drive where one of those tends to self regulating such as low impedance voltage drive in a system with a DC motor is largely speed regulating.
Synchronous noise and Resonance
- Stability and EMC related issues from another prospective
Consider soldiers marching, they break step when crossing a bridge to avoid resonances at the high amplitude synchronous noise. The application of this strategy to stability and noise is worth considering but it may not be helpful.
In a Switch mode power supply some of the noise comes from the high current gate drive, plus snubber circuit and any other parasitic capacitance pulse at switching time and appears across the source current sense resistor. This could misleadingly trigger current limiting or affect control. These pulse can be filtered with an RC filter, but usually (in current mode controllers) the pulse is gated out and therefore ignored, and if the designer attempts to add RC filtering this would upset the feature by spreading this switching noise pulse into the time region that is not gated out. Alternatively voltage mode control with feed-forward where current sensing is used for protection only but not for control resolves this issue by avoiding injecting this switching noise back into the control loop.
Resonance and noise in stepper motor drive;
One phase on - the motor steps from one pole to the next. There is not much to recommend this mode other than lower power consumption.
Two phase on - the motor steps to a position is not held so precisely but is held between the two poles. Consequently the step is a softer pulling motion though still not a smooth transition from the previous position but the noise and resonances are reduced.
Half step - The motor is stepped to one phase on then two phase on repeatedly. The size of each step is halved so the resonance and noise can be reduced. The frequency is higher and the resulting velocity ripple can be filtered more consequently. The pattern is broken unlike the soldiers marching by making smaller steps and alternating between two weightings.
The current drive could be by series resistor from a high voltage supply, this is the most stable drive method, but this method wastes lots of power. The most efficient method is to use switch mode technique from a high voltage supply;
- current source switching between supply current and allowing the circulating current is the most efficient. This is the least stable and likely to resonate because as the motor shaft moves the current can increase and that increased current does not dissipated or be returned to the supply, in addition the switching frequency tends to be low, and consequently the current control is not very tight.
- current source switching between supply current or dumping the current back into the supply as opposed to allowing it to circulate current is less efficient, but stability is good because as the motor shaft moves the current might have actually increase is returned to the supply, in addition the switching frequency tends to be high so consequently the current control is good.
Mechanically you should avoid directly driving to a high inertia load from a stepper motor. Motor manufactures make a point about this recommend using flexible couplings. A high inertia load directly coupled the motor may resonate and could be very loud at speed and you need to ramp up the motor speed and you may need to fine tune the motor ramp up rate.
ST Electronics' application notes cover these issues very well and it may be worth looking at older chip sets in order to get a fuller explanation, if the current ICs data leaves you wondering? I am unsure whether the application notes are all still available for ST's L297 which is a quite old, basic but full feature stepper motor controller used with a driver such as L6205. This driver can be configured to the modes I have listed.
Decca made in England, transistor VHF/MW/LW radio purchased from Strange of Sevenoaks in about 1962.
Originally this radio was returned for repair a number of times but only the VHF band is any good which is my father wanted. It uses the AC and AF series germanium transistors rather than the original OC series - leading edge at the time, I believe?
The aerial broke so I replaced it. I also replaced PP3 battery supply with a mains power supply based on a 6.3V heater transformer. Used daily, and unaffected by mobile phones in close proximity. The reason the mobile phones don't affect the radio is because the transistors used barely enough bandwidth to function at VHF frequency and they probably do not respond to so do not rectify higher frequencies broadcast by a mobile phone even though the power is considerably more than the VHF broadcast being received.