Introduction
Some time ago I had a need to control DC motors in speed feedback, but without the ability to add any sensors to the rotor to measure the speed directly. Turns out I'm not the first to have this situation in my hands, and not the first to try and figure out how to do it. Precision Microdrives has a good article on the subject. However, for my application I needed bidirectional motor control with an H-bridge, which their article does not cover.
I've tried to capture here what I've learned. Hopefully useful for others, but at least as a reference for myself.
Brushed motors 101
Construction of a typical toy DC motor. Image by Haade from Wikimedia Commons |
A current through the motor terminals will pass through to the armature via brushes, which brush against the commutators. The commutators are connected to the three coils in such a way as to produce a torque in one direction, regardless of the orientation of the rotor. The basic idea behind this is very well illustrated in this YouTube video.
It is often assumed that the commutation event, when a brush changes from one commutator to another is instantaneous. In reality the coils have inductance, and thus instantaneous changes in current are not possible. I've not found a proper explanation of the specifics happening during this event. It may be that the residual magnetic energy simply gets dissipated through arcing (as seen in this video, although that motor has a much greater number of poles). In any case, the fact that there is significant inductance in the armature makes DC motors much more interesting.
The ideal DC motor equivalent electrical circuit is simply a voltage source (representing the so called back-EMF of the motor) with a voltage that is directly proportional to the rotation speed of the motor (the KV factor). That is, the voltage across the motor, when rotating at speed omega is
Spoiler alert: in the end it is this voltage, which allows us the measure the rotation speed without sensors.
The torque M produced by the ideal motor, on the other hand, is directly proportional to the current I passing through the armature (The KT factor). That is,
Now, the electrical power going in to the motor is Vemf*I, while the mechanical power is
In the ideal case the mechanical power matches the electrical power, and thus (when using SI units, omega in rad/s)
See also Wikipedia.
However, connecting an ideal motor to a voltage source would show infinite current, which is clearly not correct. To improve the model, an obvious thing to add is the wire resistance of the armature, which is seen in series with the ideal motor. This already improves the model, and is enough to handle the static situation. Unfortunately it still fails to catch the dynamic effects, when the motor voltage is switched quickly high and low, as happens in an H-bridge with pulse width modulation. To catch this dynamic behavior, the winding inductance also needs to be accounted for.
Ideal motor model with armature resistance and inductance added. |
Motor driving modes
As mentioned before, the plan is to drive the motor with an H-bridge driver. This allows driving the motor in both directions, and the speed can be varied by pulsing the motor. However, there are a few ways a motor can be driven in an H-bridge.
Below are the typical four configurations used by common motor driver ICs. Illustrated current is the steady state current, after inductive dynamic effects have died out.
Driving the motor in the forward direction. Motor positive is connected to VCC, motor negative is connected to GND. |
Driving the motor in the backward direction. Motor positive is connected to GND, motor negative is connected to VCC. |
Braking the motor. Both motor terminals are connected to GND. Current flow direction depends on the motor rotation direction. |
Motor freewheeling. Both motor terminals are floating. There is no current flow and motor terminal voltage is proportional to rotation speed. |
When a motor speed is controlled using PWM in an H-bridge, the motor is either pulsed between the drive and brake configurations or between the drive and freewheel configurations. My intuition intially was that pulsing the motor with the brake configuration would be wasteful, as it seems obvious that braking would dissipate mechanical energy as heat, which reduces the efficiency.
Let's take a closer look at the two different pulsing strategies. First, let's lay down some hypothetical model parameters of the motor. Take VCC as 5V, and say the motor is rotating at a speed, which produces 2.5V as back-EMF, and say the motor takes an average current of 0.1A to maintain this speed. Take the armature resistance as 0.1 ohms and the armature inductance as 10 millihenry. Assume everything we consider happens so quickly, that the motor doesn't have time to change its speed.
That is
That is
Forward drive
Initially we're in the forward drive configuration. Motor positive terminal is connected to 5V and negative terminal is connected to GND. This drives a current I (approximately Iavg) through the motor. Writing the voltage drop in the circuit, we obtain the equation (omitting the H-bridge switch resistances)
We see that the current is in fact not constant, but changes in time due to the inductance. The change is
With our hypothetical values, this evaluates as I' = 249 A/s. That is, the current is increasing in time and the armature magnetic field is growing.
With our hypothetical values, this evaluates as I' = 249 A/s. That is, the current is increasing in time and the armature magnetic field is growing.
Let's assume that the motor pulsing scheme is such, that the current doesn't grow or decrease much. Thus the current I remains approximately Iavg at all times. If the switching frequency were e.g. 10 kHz, then the current would change a maximum of only 0.0249A during a cycle in our example.
Multiplying the equation for the voltage drop with the current (and arranging a bit) gives the power balance as
The terms can now be identified as
- Vcc*I is the input electical power
- Larm*I'*I is the power getting stored in the growing magnetic field of the armature
- Rarm*I² is the power dissipated in the armature resistance
- Vemf*I is the power getting converted to mechanical power
Braking (also known as slow decay mode)
Motor switched to brake configuration, while current is flowing. Armature inductance forces current to flow. Current flow indicated with red arrow. |
Next, we consider what happens when the H-bridge switches from the drive configuration to the brake configuration. Here we have both terminals of the motor connected to GND. The voltage drops around the circuit give the following equation
Again, we see current is not strictly constant in time. However, it must remain continuous over the switching event. Solving for the current derivative now gives
Which with our hypothetical values evaluates as I' = -251 A/s. That is, the current is decreasing with time and the armature magnetic field is collapsing.
Again, multiplying the equation for the voltage drops with the current (and re-arranging) gives the power balance as
The terms can again be identified as
- -Larm*I'*I is the power extracted from the collapsing magnetic field of the armature
- Rarm*I² is the power dissipated in the armature resistance
- Vemf*I is the power getting converted to mechanical power
If we stay in the brake configuration for a long period of time, eventually the current will decrease to zero, and go negative. At this moment the torque produced by the motor to the mechanical load reverses, and the motor starts to take energy from the mechanical side back to the electrical side, storing it to the armature magnetic field, which now is growing in the opposite polarity as the inital drive was.
Freewheel (also known as fast decay mode)
Knowing now, that the current through the motor cannot change instantaneously due to the inductance, it is not immediately clear what will happen if the H-bridge were to switch to the freewheel configuration from the drive configuration. In fact, the H-bridge needs to be carefully designed to be able to handle such a situation.
Motor switched to freewheel configuration, while current is flowing. The armature inductance forces current through the parasitic diodes of the MOSFETs. Current flow indicated with red arrow. |
When the H-bridge is built using MOSFET transistors (as they typically are), there are (parasitic) body diodes inside the MOSFETs, which start to conduct, allowing the current to continue flowing as shown above. Often there will be additional Schottky diodes parallel to the MOSFETs to not just rely on the body diodes.
Motor switched to freewheel configuration, while current is flowing. The armature inductance forces current to flow. Current flow indicated with red arrow. |
Solving for the current derivative now gives
With our hypothetical values (and Vdiode = 0.7V), this evaluates as I' = -891 A/s. The current is decreasing, and thus the magnetic field is again collapsing. Since the current is decreasing much faster here than in the braking configuration, this motivates the alternate terms "slow decay" and "fast decay" for these two configurations.
With our hypothetical values (and Vdiode = 0.7V), this evaluates as I' = -891 A/s. The current is decreasing, and thus the magnetic field is again collapsing. Since the current is decreasing much faster here than in the braking configuration, this motivates the alternate terms "slow decay" and "fast decay" for these two configurations.
We again get the the power balance through multiplying the equation for voltage drop with the current
The terms are now identified as
- -Larm*I'*I is the power extracted from the collapsing magnetic field of the armature
- Vdiode*I is the power dissipated in each diode
- Rarm*I² is the power dissipated in the armature resistance
- Vemf*I is the power converted to mechanical power
- Vcc*I is power that is absorbed back to the power supply
If we were to remain in the freewheel configuration for a long time, the current would decrease quite quickly to zero. However, since the current is passing through diodes, the current can not change direction and will simply stop when the current reaches zero. Since the current is then zero and also unchanging, the rotation-speed-dependent back-EMF of the motor can be seen and measured across the terminals. This is the key for the sensorless speed measurement.
Driving scheme for sensorless speed feedback
The mechanical dynamics of the systems are much slower than the electrical dynamics of the system. That is, the motor rotational speed remains constant in the time scale of say 100 Hz, while the time scale to consider the current a constant is around 10 kHz. It is enough to measure the motor speed at 100 Hz, while the switching occurs at 10 kHz.
Since the drive-brake pulsing is more efficient than drive-freewheel, it makes sense to use that most of the time, while occasionally going to the freewheel configuration and letting the current fully decay in order to measure the speed.
Two important things to note regarding the motor current decaying.
- The motor torque remains directly proportional to the current. Having the current decay to zero and back up again causes torque oscillations, which may cause mechanicals problems if the frequency is close to a mechanical resonance.
- The current decay rate is a function of the back-EMF of the motor. When the motor is turning quickly, the current decays up to twice as fast as to when the motor is turning very slowly. Further, the decay time is also proportional to the motor current at the start of the decay. If a fixed delay is used to wait for the current decay, it needs to be determined by stalling the motor at the maximum expected current.
All that said, if torque oscillations and motor drive efficiency are not relevant issues, perhaps the simplest solution is to run the motor with freewheel pulsing using a pulse frequency low enough, which results in the current decaying to zero in every cycle. This allows also measuring the back-EMF in every cycle, which then permits reducing noise through a simple low-pass filter.
No comments:
Post a Comment