Switching for Controlling Mobile Robots
A robot is a dynamic system possessing parts called actuators that are used to perform physical actions such as transporting the robot from one point to another. A typical actuator is an electric motor which can turn the robots wheels enabling the robot to explore its environment. Since interesting robots are autonomous, the motor needs to be controlled by the robot's "brain" in some fashion. The simplest form of motor control is to switch it on or off. This tutorial will explain the concept of switches, both mechanical and electronic, and the use of the switching concept to control drive motors in a simple mobile robot. It is meant to be a simple introduction and thus lacks details which will be presented later in the ECE curriculum.
A mechanical single-pole, single-throw (SPST) switch is one of the simplest circuit elements. It consists of two conductors which can be physically separated or brought into contact with each other. A familiar example is the wall switch that controls the ceiling lamp in a room. In a circuit, when the switch conductors are separated, current cannot flow through the switch and we say that the switch and the circuit are "off" or "open." In the case when the conductors are in contact, current can flow and we say that the switch and the circuit are "on" or "closed." Animation 1 shows the schematic representation of a simple series circuit containing a power source (battery), a load (resistor-LED combination) and a SPST switch. The schematic symbol for the switch can be drawn in two ways to indicate that the switch is open or closed. Press the "Switch On" button in the animation to turn on the circuit and the "Switch Off" button to turn it off.
Animation 1. A simple SPST-switched series circuit.
Using the switching concept, the drive motor of a robot can be controlled in an extremely limited fashion; that is, we can turn the motor on or off. This is demonstrated in Animation 2 where the motor is schematically represented by an inductor and a wheel which rotates indicating that the motor is on.
Animation 2. A simple SPST-switch controlling a motor.
To this point we have used a mechanical switch to demonstrate the concept of switching. However, this type of switch requires a mechanical action, such as a human pressing or toggling the switch, to operate it. For the brain of a robot (typically a microprocessor) to control its motors, we need an electro-mechanical or preferably, an electronic switch. A relay is a typical example of an electro-mechanical switch. It operates by energizing an electro-magnet which closes or opens mechanical contacts. An electronic switch can be fashioned using semiconductor devices such as transistors to achieve the switching operation. The use of electronic switches is the basis of operation for digital computing.
A transistor is an electronic device which essentially provides a method of achieving power gain. That is, put in small currents and/or voltages and get out larger currents and/or voltages. This process is called amplification. At high levels of amplification, the transistor can be used as a switch. There are two basic types of transistors: the bipolar-junction transistor (BJT) and the field-effect transistor (FET). BJTs can be used as current-controlled switches, whereas FETs can be use as voltage-controlled switches.
We will use a type of FET called an n-channel, enhancement mode MOSFET in our examples. The FET is typically available as a three-terminal device. The terminals are called the gate (G), source (S), and drain (D). When used as a switch, the voltage between the gate and source (VGS) is used to control the resistance between the drain and source (RDS). In the n-channel, enhancement-mode MOSFET, there is a gate-source voltage called the threshold voltage (VGS(THRESH)) which represents the switch-point of the device. When VGS is less than the threshold voltage, RDS is very large and the switch is off. If VGS is greater than the threshold voltage, RDS is small and the switch is on. Animation 3 demonstrates the switching operation of a FET circuit.
Animation 3. A MOSFET switch controlling a motor.
We now know how to turn a motor off and on. However, to make effective use of the motor for transporting a mobile robot, the robot brain should also be able to control the rotation direction of the motor and possibly the speed. If we assume a permanent magnet, direct current motor is used as the drive motor, the direction of rotation can be changed by the direction of the current flowing through the motor.
As a first approach, a single-pole, double-throw (SPDT) switch can be used to control direction. (We will use the schematic symbol for the mechanical versions of the switches. However, realize that the switches can be implemented using transistors.) SPDT switches have a center pole (contact) which is switched between two outer poles. There will always be a combination of contact with the center pole to one of the outer poles and no contact with the other outer pole. When the switch is operated, the contact/no contact combination is reversed. Motor rotation direction is controlled by switching between two power supplies using the SPDT switch and turning the motor on and off using a SPST switch. This process is demonstrated in Animation 4.
Animation 4. Bidirectional motor operation.
Adding an extra power supply to achieve bi-directional operation is expensive. The need for the extra supply can be obviated by using two SPDT switches in a configuration called an H-bridge. The motor resides at the center-bar of the H and is electrically reversed by the bridge. The SPDT switches are operated in a manner such that while one pair of contacts are closed, the other pair of contacts are open. If the bridge is implemented electronically, the SPST switch that turns the motor on and off can be eliminated by embedding its operation into the transistors that make up the H-bridge. Animation 5 demonstrates H-bridge operation.
Animation 5. Motor control using an H-bridge.
Motor speed can be controlled by switching the motor very fast. The motor can't respond to the speed of the switch, but does respond to how long the switch is closed during an on/off cycle. This process is called pulse-width modulation and can be used for different types of power control. A familiar example would be handling a hot potato. If you were to hold the potato, you would certainly get burned. If, however, you juggled the potato, it would be in the air more than in contact with your hand reducing the heat conducted to your hand from the potato. For PWM, the ratio of time the switch is closed to the total cycle time is called the duty-cycle and is typically measured in percentage. A 100% duty-cycle translates to the switch being closed 100% of the cycle resulting in the motor rotating at full speed. A 0% duty-cycle translates to the switch being open 100% of the cycle and thus the motor is off. Accordingly, a 50% duty-cycle means the switch is closed for 50% of the cycle and open for the other 50% resulting in a motor speed which is near half of its maximum.
The methods discussed in this tutorial are used frequently enough to warrant the existance of special purpose integrated circuit versions of H-bridges and PWM systems. In our robotics project, we will use an H-bridge circuit to control the robot's drive motors, but will only require the motors to be on or off. That is, we will not use PWM for speed control.