PWM MOTOR CONTROL
|ANALYSIS AND DESIGN|
A Direct Current (DC) motor was
selected for the drive system as the only direct power source available on the robot would be
DC batteries. Converting to AC would require an extra step, decreasing efficiency and thus
reducing battery life.
Controlling the speed of a DC motor requires a variable voltage DC power source. Taking a 12v
motor and applying full power to it will cause the motor to rotate, gradually (relative)
building up speed. Since motors do not respond immediately, it will take a shot amount of time
to reach full speed. Likewise, there will be a time ?t between when the power to the motor is
removed and when the motor armature stops revolving. Switching the power on and off quickly
enough will enable the motor to run at some speed part way between zero and full speed. Pulse
Width Modulation (PWM) does exactly this, switching the motor on in a series of pulses. To
control the motor speed, it varies (modulates) the width of the pulses, hence Pulse Width
A DC motor can be run in either direction by simply changing the polarity applied to its two
terminals. In order to actuate this change a switching circuit is required. There are normally
two types of switch, either reed switches or mosfets. Since the current passing through these
circuits may be large, coupled with the extra circuitry required to run a circuit using reed
switches, the mosfet approach was selected. To control the DC motor in all four quadrants a
bi-directional current flow is required, this was achieved by using an H-Bridge:
Efficiency is maximised by operating the circuit in switching mode rather than the highly
dissipative linear (always on) mode. The power mosfets only dissipate power when they are
conducting current or switching between their two states. When fully on, the resistance of a
MOS transistor is very low (0.007 Ohms in this case), thus the power dissipated across the device
is small (about 35mW). The motor terminal voltage is controlled by switching the transistors at
constant frequency and varying the on and off times. Varying the duty factor of the PWM signal
will vary the average voltage across the motor, hence varying the speed.
The table in figure below (with reference to the figure above) shows the switching states used.
Applied voltage across the output Vout can be either +Vs or -Vs. The average value of the output
voltage is controlled by the relative time spent in either State 1 or State 2.
To allow satisfactory control of the mosfets, a short time delay was added. This was to ensure
that time is given during the direction change for the first set of mosfets to turn off before
the second set is switched on. If this delay is not added, a short circuit across the power
supply may result. When the motor is moving in a particular direction, the appropriate top
mosfet is switched on and left on, the corresponding bottom mosfet is then switched on and
off by the PWM signal.
Control of the mosfets in the H-bridge is handled by a small programmable microprocessor, the
PIC16F84 chip. The outputs of the PIC are connected to an opto-isolator with a rail voltage of
30V. The 30V rail is required to drive the top mosfets, since the gate voltage of the top
mosfets has to be greater than the 24V supplied to the H-bridge. The C code used to program
the PIC is in appendix F. An illustrative diagram showing the interconnection of the different
blocks is displayed below.
During competition, the drive motors may be stalled. In this situation, a large current will flow through
the MOSFETs and the motors (taking that the applied voltage remains high). To protect the
devices, the power-bridge must include a current sensing device, which will limit the output
current to preset value. This is done by reducing the duty ratio of the output, and therefore
the effective output voltage, if the current exceeds the desired threshold.
Controlling the motors acceleration and deceleration is also necessary so that the robot is not
thrown into a rapid acceleration as it tries immediately to reach full speed or change direction
. This is done using a "ramp". The figure below shows the effect of the linear ramp, where
acceleration and deceleration are constant with no 'speed fading'.
At the point A, the demand on the speed control is suddenly turned to full speed. Initially the
motor speed starts increasing quickly. However, as it gets faster, its rate of speed increase
decreases and as it reaches full speed, the rate is relatively slow. At point B, the demand
speed is suddenly reduced to zero. The linear ramp control is encapsulated within the PWM signal
Although it would have been easier to buy in pre-fabricated motor controllers, this would have
represented a large increase in cost. Designing the controllers is by far the cheaper option
and also ensures that they will be able to function under the conditions that the robot wars
environment subjects them to.
PWM MOTOR CONTROL