Power balance of the AC commutator motor is described by this equation. Integrals can be replaced by sums:
RΣ - equivalent summary resistance of motor circuit.
Sums must be calculated from one zero-crossing of current to next zero-crossing of current.
The motor speed can be calculated as follows:
- Rekv - equivalent resistance which is created by the back-EMF.
- Rmotor - motor resistance in Ohms.
- K - constructive coefficient of the motor.
The motor speed is proportional to the Rekv.
First, we should determine motor's resistance. That's done in stopped state, passing 1 pulse (positive period of sine wave) and observing current's behavior.
If motor isn't rotating, active power is equivalent to Joule power on motor resistance. Integrals can be replaced by sums.
Count all ticks from triac opening to moment when current crosses zero.
Compensating armature frequency-related losses
In ideal world, equations above should work. But in reality R is not constant and not linear it - depends on triac phase. Motor has additional losses (caused by eddy currents) when "frequency" rises. Measured R at zero phase is 1.5x smaller than at full phase.
So, we have to measure resistance at multiple phases and build interpolation table. Then, to calculate speed - use interpolated value, appropriate to current triac phase. This helps a lot to calculate small speeds right. In theory, losses may depend on motor load, but described compensation is enough for good result.
Note, after each "positive" measuring pulse it worth to make negative pulse to demagnetize armature. Also, it worth to make small pause between measurements, to keep rotor stopped.
It's enough to measure R at 0%-50% of "speed" (triac phase). On high speed R does not affect calculated speed too much. Measure at 100% pulse can make motor rotate and return wrong value. So, we measure only in 0%-50% range and propagate last value to max (100%) speed.
Implementation notes
It's important to count sum until current become zero, not until voltage become zero! Since we can't measure negative voltage, we use simple trick: record positive value into memory, and replay after zero cross.
If you need to implement this on low memory devices, it's possible to record only 1/4 of positive voltage wave. But we had no so big restrictions, and recorded full wave (both voltage and current) for simplicity.
Also, you may have overflow with fixed point math. Since performance is not
critical with recorded data, using float
types is preferable.
Signal may be noisy at short pulses. To filter accidental peaks, measure multiple times, until 3 consecutive results become stable.
Grinder motors are very inconvenient for PID-based systems:
- RPM/Volts response is non linear, and varies significantly between different grinder models. The same about zero speed offset.
- Cooling fan adds extra distortion.
So, we use ADRC instead of PID. Adaptive character of the ADRC system makes it possible to use without the RPM/Volts response linearization. Deviations from the linear RPM/Volts response are eliminated by the generalized disturbance observer (they are part of the generalized disturbance).
First-order ADRC system consists of linear proportional controller with Kp
gain
and 2 state observers - speed observer, generalized disturbance observer.
Observers are integrators with Kobservers
gain and L1
, L2
time constants.
Output of the linear proportional controller is corrected by generalized
disturbance signal. This correction eliminates (in the steady state) the motor
speed deviation caused by mechanical motor load, motor parameters deviation,
inaccurate motor parameters estimation.
ADRC system parameters and equations:
b0
= K / T
, where K=1
due to speed and triac setpoint normalization,
T
- desired optimal motor time constant.
L1
- time constant of the speed observer.
L2
- time constant of the generalized disturbance observer.
u0
- output of linear proportional controller in ADRC system.
Speed observer equation:
Generalized disturbance observer equation:
P_correction
- proportional correction signal, makes reaction to motor load change significantly faster.
Output signal of ADRC regulator:
General steps of ADRC calibration are:
- Measure motor start/stop time. Then use it for understand max possible oscillations period.
- Find
Kp
in range [0.3*b0..0.3*b0+4] by halving (division by 2) method. Criteria - "no oscillations" (speed dispersion should not exceed normal noise). - Find
Kobservers
in range [0..max] by halving method. Criteria - "no oscillations". - Find
P_corrcoeff
in range [0..max] by halving method. Criteria - "no oscillations".
Implementation notes
Basic start/stop time measure:
- We should select begin/end setpoints, where speed can be measured good enougth. Use 0.35 and 0.7.
- Common criteria of interval end is "when speed reach 2% window of desired
setpoint". But signal is noisy, and we use simple trick: wait 15% window and
multiply to
log(0.15)/log(0.02)
(because speed growth is ~ logarithmic).
Measure Kp
:
- Set
Kobservers
to safe value (1.0),Kp
min possible (0.3*b0),P_corrcoeff
to 0.0, measure all at minimal allowed speed. - Wait for stable speed
- Measure noise amplitude, abs(max - min) for period ~ start/stop time.
- Use starting step = +4.0, and halving method. Check noise amplitude not exceed 110% of initial value.
- Make 7 iterations total (last step will be 0.1 - good precision).
- Use 0.6 of final value as safe.
It would be better to count dispersion instead, but that's more complicated. Counting min/max after median filter seems to work. Note, speed value is very noisy. Applying some filter before min/max check is mandatory.
Measure Kobservers
:
- Set
Kobservers
to 0.0,Kp
to calibrated,P_corrcoeff
to 0.0, measure all at minimal allowed speed. - Wait for stable speed
- Measure noise amplitude, abs(max - min) for period ~ start/stop time.
- Use starting step = +4.0, and halving method. Check noise amplitude not exceed 110% of initial value.
- Make 7 iterations total (last step will be 0.1 - good precision).
- Use 0.6 of final value as safe.
Measure P_corrcoeff
:
- Set
Kobservers
to calibrated,Kp
to calibrated,P_corrcoeff
to 0.0, measure all at minimal allowed speed. - Wait for stable speed
- Measure noise amplitude, abs(max - min) for period ~ start/stop time.
- Use starting step = +4.0, and halving method. Check noise amplitude not exceed 110% of initial value.
- Make 7 iterations total (last step will be 0.1 - good precision).
- Use 0.6 of final value as safe.
Links below are not mandatory, but can simplify understating of this document.
- AN863, Improved sensorless control with the ST62 MCU for universal motor. Simplified algorithm, based on zero-cross current measure. Table-based, requires preliminary motor testing with stand. More cheap for mass production, but less universal. Recommended for reading, to undestand alternatives.
- DC Chopper control vs. Phase Angle control for appliance and power Tool Applications--Who wins? Has comparison of triac & chopper regulators, with details about harmonic-related losses. Helps to understand, why "active resistance" depends on triac control angle.
- Panasonic Application Note 030, Driving Triacs with Phototriacs.
- ST AN440. Triac control with a microcontroller powered from a positive supply
- A Simulative Study on Active Disturbance Rejection Control (ADRC) as a Control Tool for Practitioners - Gernot Herbst