ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 13.06.2025
Просмотров: 4183
Скачиваний: 0
3 Actuators
There are two principal ways of stopping the motor:
•set both x and y to logic 0 (or both to logic 1) or
•set speed to 0
x |
a |
speed |
M |
y |
b |
Figure 3.5: Power amplifier
3.3 Pulse Width Modulation
PWM is digital control
Duty cycle
Pulse width modulation or PWM for short is a smart method for avoiding analog power circuitry by utilizing the fact that mechanical systems have a certain latency. Instead of generating an analog output signal with a voltage proportional to the desired motor speed, it is sufficient to generate digital pulses at the full system voltage level (for example 5V). These pulses are generated at a fixed frequency, for example 20 kHz, so they are beyond the human hearing range.
By varying the pulse width in software (see Figure 3.6, top versus bottom), we also change the equivalent or effective analog motor signal and therefore control the motor speed. One could say that the motor system behaves like an integrator of the digital input impulses over a certain time span. The quotient ton/tperiod is called the “pulse–width ratio” or “duty cycle”.
V |
t low speed |
||||||||||||||||||
V |
is equivalent to: |
||||||||||||||||||
t |
|||||||||||||||||||
V |
|||||||||||||||||||
t |
|||||||||||||||||||
V |
is equivalent to: |
high speed |
|||||||||||||||||
t
Figure 3.6: PWM
46
Pulse Width Modulation
The PWM can be generated by software. Many microcontrollers like the M68332 have special modes and output ports to support this operation. The digital output port with the PWM signal is then connected to the speed pin of the power amplifier in Figure 3.5.
|
Velocity [rad/s] |
Velocity [rad/s] |
time [s] |
PW ratio [%] |
Figure 3.7: Measured motor step response and speed versus PW ratio
Figure 3.7, left, shows the motor speed over time for PWM settings of 10, 20, .., 100. In each case, the velocity builds up at time 5s with some delay, then stays constant, and will slow down with a certain inertia at time 10s. These measurements are called “step response”, since the motor input signal jumps in a step function from zero to the desired PWM value.
Unfortunately, the generated motor speed is normally not a linear function of the PWM signal ratio, as can be seen when comparing the measurement in Figure 3.7, right, to the dashed line. This shows a typical measurement using a Faulhaber 2230 motor. In order to re-establish an approximately linear speed curve when using the MOTORDrive function (for example MOTORDrive(m1,50) should result in half the speed of MOTORDrive(m1,100)), each motor has to be calibrated.
Motor calibration Motor calibration is done by measuring the motor speed at various settings between 0 and 100, and then entering the PW ratio required to achieve the desired actual speed in a motor calibration table of the HDT. The motor’s maximum speed is about 1,300 rad/s at a PW ratio of 100. It reaches 75% of its maximum speed (975 rad/s) at a PW ratio of 20, so the entry for value 75 in the motor calibration HDT should be 20. Values between the 10 measured points can be interpolated (see Section B.3).
Motor calibration is especially important for robots with differential drive (see Section 4.4 and Section 7.2), because in these configurations normally one motor runs forward and one backward, in order to drive the robot. Many DC motors exhibit some differences in speed versus PW ratio between forward and backward direction. This can be eliminated by using motor calibration.
47
3 Actuators
Open loop control We are now able to achieve the two goals we set earlier: we can drive a motor forward or backward and we can change its speed. However, we have no way of telling at what speed the motor is actually running. Note that the actual motor speed does depend not only on the PWM signal supplied, but also on external factors such as the load applied (for example the weight of a vehicle or the steepness of its driving area). What we have achieved so far is called open loop control. With the help of feedback sensors, we will achieve closed loop control (often simply called “control”), which is essential to run a motor at a desired speed under varying load (see Chapter 4).
3.4 Stepper Motors
There are two motor designs which are significantly different from standard DC motors. These are stepper motors discussed in this section and servos, introduced in the following section.
Stepper motors differ from standard DC motors in such a way that they have two independent coils which can be independently controlled. As a result, stepper motors can be moved by impulses to proceed exactly a single step forward or backward, instead of a smooth continuous motion in a standard DC motor. A typical number of steps per revolution is 200, resulting in a step size of 1.8°. Some stepper motors allow half steps, resulting in an even finer step size. There is also a maximum number of steps per second, depending on load, which limits a stepper motor’s speed.
Figure 3.8 demonstrates the stepper motor schematics. Two coils are independently controlled by two H-bridges (here marked A, A and B, B). Each four-step cycle advances the motor’s rotor by a single step if executed in order 1..4. Executing the sequence in reverse order will move the rotor one step back. Note that the switching sequence pattern resembles a gray code. For details on stepper motors and interfacing see [Harman, 1991].
Switching Sequence: |
|||||||||||
Step A B |
|||||||||||
1 |
1 |
1 |
|||||||||
2 |
1 |
0 |
|||||||||
A |
B |
3 |
0 |
0 |
|||||||
A |
B |
4 |
0 |
1 |
|||||||
Figure 3.8: Stepper motor schematics
Stepper motors seem to be a simple choice for building mobile robots, considering the effort required for velocity control and position control of standard DC motors. However, stepper motors are very rarely used for driving mobile robots, since they lack any feedback on load and actual speed (for example a missed step execution). In addition to requiring double the power electronics, stepper motors also have a worse weight/performance ratio than DC motors.
48
Servos
3.5 Servos
Servos are not servo motors!
DC motors are sometimes also referred to as “servo motors”. This is not what we mean by the term “servo”. A servo motor is a high-quality DC motor that qualifies to be used in a “servoing application”, i.e. in a closed control loop. Such a motor must be able to handle fast changes in position, speed, and acceleration, and must be rated for high intermittent torque.
Figure 3.9: Servo
A servo, on the contrary, is a DC motor with encapsulated electronics for PW control and is mainly used for hobbyist purposes, as in model airplanes, cars, or ships (see Figure 3.9).
A servo has three wires: VCC, ground, and the PW input control signal. Unlike PWM for DC motors, the input pulse signal for servos is not transformed into a velocity. Instead, it is an analog control input to specify the desired position of the servo’s rotating disk head. A servo’s disk cannot perform a continuous rotation like a DC motor. It only has a range of about ±120° from its middle position. Internally, a servo combines a DC motor with a simple feedback circuit, often using a potentiometer sensing the servo head’s current position.
The PW signal used for servos always has a frequency of 50Hz, so pulses are generated every 20ms. The width of each pulse now specifies the desired position of the servo’s disk (Figure 3.10). For example, a width of 0.7ms will rotate the disk to the leftmost position (–120°), and a width of 1.7ms will rotate the disk to the rightmost position (+120°). Exact values of pulse duration and angle depend on the servo brand and model.
Like stepper motors, servos seem to be a good and simple solution for robotics tasks. However, servos have the same drawback as stepper motors: they do not provide any feedback to the outside. When applying a certain PW signal to a servo, we do not know when the servo will reach the desired position or whether it will reach it at all, for example because of too high a load or because of an obstruction.
49
3 Actuators
V
t
V
t
V
t
Figure 3.10: Servo control
3.6 References
BOLTON, W. Mechatronics – Electronic Control Systems in Mechanical Engineering, Addison Wesley Longman, Harlow UK, 1995
EL-SHARKAWI, M. Fundamentals of Electric Drives, Brooks/Cole Thomson Learning, Pacific Grove CA, 2000
HARMAN, T. The Motorola MC68332 Microcontroller - Product Design, Assembly Language Programming, and Interfacing, Prentice Hall, Englewood Cliffs NJ, 1991
50
C. . .ONTROL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
. 4 |
|
. . . . . . . . . |
losed loop control is an essential topic for embedded systems, bringing Ctogether actuators and sensors with the control algorithm in software.
The central point of this chapter is to use motor feedback via encoders for velocity control and position control of motors. We will exemplify this by a stepwise introduction of PID (Proportional, Integral, Derivative) control.
In Chapter 3, we showed how to drive a motor forward or backward and how to change its speed. However, because of the lack of feedback, the actual motor speed could not be verified. This is important, because supplying the same analog voltage (or equivalent: the same PWM signal) to a motor does not guarantee that the motor will run at the same speed under all circumstances. For example, a motor will run faster when free spinning than under load (for example driving a vehicle) with the same PWM signal. In order to control the motor speed we do need feedback from the motor shaft encoders. Feedback control is called “closed loop control” (simply called “control” in the following), as opposed to “open loop control”, which was discussed in Chapter 3.
4.1 On-Off Control
Feedback is everything
As we established before, we require feedback on a motor’s current speed in order to control it. Setting a certain PWM level alone will not help, since the motor’s speed also depends on its load.
The idea behind feedback control is very simple. We have a desired speed, specified by the user or the application program, and we have the current actual speed, measured by the shaft encoders. Measurements and actions according to the measurements can be taken very frequently, for example 100 times per second (EyeBot) or up to 20,000 times per second. The action taken depends on the controller model, several of which are introduced in the following sections. However, in principle the action always looks similar like this:
•In case desired speed is higher than actual speed:
Increase motor power by a certain degree.
•In case desired speed is lower than actual speed:
Decrease motor power by a certain degree.
5151
4 Control
In the simplest case, power to the motor is either switched on (when the speed is too low) or switched off (when the speed is too high). This control law is represented by the formula below, with:
R(t) |
motor output function over time t |
||
vact(t) |
actual measured motor speed at time t |
||
vdes(t) |
desired motor speed at time t |
||
KC |
constant control value |
||
R t |
KC |
if vact t vdes t |
|
® |
0 |
otherwise |
|
¯ |
|||
Bang-bang
controller
What has been defined here, is the concept of an on-off controller, also known as “piecewise constant controller” or “bang-bang controller”. The motor input is set to constant value KC if the measured velocity is too low, otherwise it is set to zero. Note that this controller only works for a positive value of vdes. The schematics diagram is shown in Figure 4.1.
desired speed
des.<act. ?
R(t) |
actual speed |
|||||||
* Kc |
Motor |
|||||||
encoder |
||||||||
0 or 1 |
0 or Kc |
|||||||
measurement |
||||||||
feedback |
||||||||
Figure 4.1: On-off controller
The behavior over time of an on-off controller is shown in Figure 4.2. Assuming the motor is at rest in the beginning, the actual speed is less than the desired speed, so the control signal for the motor is a constant voltage. This is kept until at some stage the actual speed becomes larger than the desired speed. Now, the control signal is changed to zero. Over some time, the actual speed will come down again and once it falls below the desired speed, the control signal will again be set to the same constant voltage. This algorithm continues indefinitely and can also accommodate changes in the desired speed. Note that
vactual
R(t) |
vdesired |
t |
Figure 4.2: On-off control signal
52
On-Off Control
the motor control signal is not continuously updated, but only at fixed time intervals (e.g. every 10ms in Figure 4.2). This delay creates an overshooting or undershooting of the actual motor speed and thereby introduces hysteresis.
Hysteresis The on-off controller is the simplest possible method of control. Many technical systems use it, not limited to controlling a motor. Examples are a refrigerator, heater, thermostat, etc. Most of these technical systems use a hysteresis band, which consists of two desired values, one for switching on and one for switching off. This prevents a too high switching frequency near the desired value, in order to avoid excessive wear. The formula for an on-off controller with hysteresis is:
KC |
if |
vact t von t |
|
R t 't |
° |
if |
vact t ! voff t |
® 0 |
|||
¯°R t |
otherwise |
||
Note that this definition is not a function in the mathematical sense, because the new motor output for an actual speed between the two band limit values is equal to the previous motor value. This means it can be equal to KC or zero in this case, depending on its history. Figure 4.3 shows the hysteresis curve and the corresponding control signal.
All technical systems have some delay and therefore exhibit some inherent hysteresis, even if it is not explicitly built-in.
R(t) |
vactual |
||
R(t) |
|||
voff |
|||
von |
|||
von |
voff |
vact |
t |
Figure 4.3: On-off control signal with hysteresis band
From theory to practice
Once we understand the theory, we would like to put this knowledge into practice and implement an on-off controller in software. We will proceed step by step:
1.We need a subroutine for calculating the motor signal as defined in the formula in Figure 4.1. This subroutine has to:
a.Read encoder data (input)
b.Compute new output value R(t)
c.Set motor speed (output)
2.This subroutine has to be called periodically (for example every 1/100s). Since motor control is a “low-level” task we would like this to run in the background and not interfere with any user program.
53