Вы находитесь на странице: 1из 6

A Two Wheeled Robot Control System

Scott M. Boskovich
California State Polyrechnic University, Pomona
3801 W: Temple
Pomona, CA 91768

Abstract or reverse in order to turn, and therefore usually has a


large tuming radius when compared to an independent
The purpose of this project was to desigq build type. The mechanics also tend to be much more
and test a control system that controls two motors for a involved. An example of a single drive system would
two wheeled robot. By implementing the control be an automobile.
system, the robot will maintain a straight path under
normal conditions. Without such a control system, the The independent type has a motor attached to
robot’s path would deviate from the specified direction. each drive wheel which is mounted opposite of one
To implement the control system for the robot a two another. The two adjacent sides have support casters
wheeled platform was built. Each wheel was interfaced attached to them to provide balance. The independent
to a microcontroller where the microcontroller type allows for pivoting while in a stationary position
performed a controlling routine stored in software. By by spinning each wheel in opposite directions.
implementing this design, the robot is able to correct Depending on the direction of wheel rotation, the robot
for deviations. can pivot counter-clockwise or clockwise. To move
forward or reverse, the wheels must spin in the same
Introduction direction where the direction of spin determines
forward or reverse movement. This type of robot can
Soon, robots will become an everyday also turn about one wheel without the need for forward
occurrence in people’s daily lives. Today, the field of or reverse movement. This can be accomplished by
robotics is in its infancy. Robot designers are plagued spinning one wheel and not the other one. Depending
with problems of controlling the robots to compensate on the direction of rotation of the wheel, the robot will
for simple operations people take for granted. turn about the stationary wheel.
Therefore, control systems must be implemented to
ensure correct operation. By examining the difficulties associated with
performance, the independent drive codlguration
Several different types of drivetrain provides the best combination. However, there is a
codgurations exist for mobile robots. There are problem associated with this configuration. It assumes
legged robots that try to mimic the propulsion of a that both wheels have identical drivetrains, and the
mammal, and there are wheeled robots. Of the wheeled surface of travel is perfectly level and smooth. In the
robot types, there can be a single drive with a real world, this does not exist. Since no two
differential, or an independent drive to each wheel. The drivetrains or motors are ever identical, the differences
legged variety tends to be very difEicult to control and in the motors and fictional losses could cause one
is very costly. The wheeled type tends to be more wheel to travel faster than the other. This causes the
realizable for mobile robot operation. robot’s travel to deviate. Therefore, if the robot is
commanded to travel straight, in actuality, the robot
With the wheeled robot type, there exists either will drift toward the slower side. This severity of driR is
a single drive or an independent drive configuration, dependent on the amount of difference between the two
The single type relies on one motor and some type of drivetrains and motors. For this reason, a means of
dzerential providing power to both wheels. A servo control and compensation needs to be implemented to
motor provides steering. This type must move forward ensure that the robot travels in the specified direction.

ISBN# 0-7803-2636-9 7 50
This control loop can also fimction to correct
Discussion the robot’s drift that could be caused by unlevel
surfaces. For example, a robot traveling on an
General System Theory unleveled path without this control loop implemented
will drift towards the downward side. However, due to
A control system for a two wheeled robot must the nature of this control loop, the robot will maintain
involve the following: the specified trajectory. This is because the system will
think there is a drivetrain difference, and therefore will
1. A means of sensing the speed of each wheel. adjust accordingly.
2. A means of ‘bowing” the distance traveled.
Electrical
3. The system must be able to adjust the speed of
each wheel separately. The electrical subsystem of the robot comprises
4. The system should be able to allow for of three parts; analog, digital, and power. The analog
“imperfect” conditions. part is responsible for controlling the motors and
interpreting the inputs from the encoder disc. The
Due to the complexity of the system digital portion, consisting of memory and a processor,
requirements, a microprocessor is used for control. executes the controlling algorithm stored in software.
The microprocessor implemented is the MC68HCllE9 The digital part also provides an interface to a second
microcontroller from Motorola. The method of speed dedicated processor for fbture developments. The
control utilized is Pulse Width Modulation (PWM). By interface board was designed as part of my senior
varying the duty cycle of the signal sent to the motors, design project and the processor board was purchased
the speed is changed thusly. To extract the speed of fiom New-Micros Inc. The processor board provides a
each wheel, encoder discs and opto-interrupters are 64K address space which can be configured with a
used. This combination incorporates a disc mounted on combination of 8K-32K SRAM, 8K-32K EPROM,
each drive shaft. The edge of the disc has 128 slots and/or 8K-32K EEPROM. It also provides an
spaced evenly around the perimeter of the disc. The expansion port, serial communications via RS232, and
interrupters are mounted such that the disc fits between LCD display capabilities. The power system provides
the void of the emitter and detector pair. Therefore, as two sources of 5V ( one for each board ) and 12V to
the disc turns, the detector “sees” pulses fiom the the motors.
emitter caused by the slots in the perimeter of the
encoder disc. The frequency of these pulses correlate The power system consists of two sealed lead
directly with the rotation of the wheel. Therefore, the acid batteries configured in parallel providing a total of
speed of each wheel is obtained fiom the emitter. 14A/h. There are two linear voltage regulators,
Figure 1 shows the general block diagram. LM7805K, which provide the 5V required by each
TO PCUSER
board. They are in a TO-3 style package and mounted
MOTOR SHPIT to a heatsink on the robot chassis. The 12V is obtained
T (PMSIWCONNECTION)
directly fiom the batteries.

The analog system must convert everything


fiom analog to digital or fiom digital to analog. The
first part of this task is accomplished by the
emitteddetector (E/D) pairs. They provide a train of
pulses dependent on the speed of each wheel. This is
done by turning on an IR diode, and then obtaining the
pulses of IR in a phototransistor mounted opposite the
DRIVER MOTOR2 diode. Each disc has two E/D pairs where one pair
from each disc has its fiequency converted into an
analog signal fiom OV to 4.5V. First, the pulse train
MOTOR SHAFT must be amplified and “squared up” by using a 74LS14
PMSlCALCONNECTIOHJ
Schmitt trigger inverter. The square pulse is then
Figure 1 System Block Diagram converted to an analog voltage. This is accomplished
75 1
by using the LM331 frequency to voltage converter. the on time is half. The average voltage to the motor
This analog voltage is then filtered using an RC then becomes 6V, even though each swing is between
network, shown in figure 2. OV and 12V. This P W M signal is applied to a
Darlington pair for each motor. The motors’ directions
squared pulse from are determined by the digital value from Port A,
El0 pair specifically Port A bit 4 (PA4) and Port A bit 6 (PA6).
If PA4 is a ‘logic one” then the motor turns one
direction, if it is a ‘logic zero” then it turns the other
direction. This is performed by the H-Bridge
configuration of transistors. Each of the opposing
adjacent transistors is connected to the same digital
Figure 2. signal fiom the relay. When one pair is ‘logic one,” the
current in the motor is in one direction causing one
The value of 5V indicates excessive speed that direction of rotation. By turning on the other pair, the
might be incurred in downhill traveL The 0.5V current in the motor is opposite and therefore the
difference is simply a safety margin. Therefore, by motor turns the opposite direction. By controlling the
limiting the output to 4.5V under normal operation, time the H-Bridge is active via the Darlington transistor
downhill travel will be no problem pair with PWM, and choosing which state the direction
bit is in, 111 control over each motor is achieved
The analog voltage represents the speed of the simultaneously. This is shown below in figure 3.
wheel where OV is no rotation and 4.5V is maximum
speed. The analog voltage is fed into the analog ports
on the microcontroller (MC68HC11, or just HC11)
where it is converted into a digital signal by the
P 12” II l2V9
2N30SS
I

onboard analog to digital converters (ADC). The


From Conkoner
digital signal is 8 bits wide providing a representation
2N3055 2N3OSS
fiom Ox00 hex to O x F F hex. Once in digital format, the
processor can calculate the amount of of€set for the
controlling algorithm in software. A signal is also
obtained fi-om a J-K flip-flop and is configured in such
a way that both pairs from each wheel provide
SpeedControl
‘1
information about the direction of rotation. The pulses
fi-om the second pair of Ems are fed directly into the
Figure 3.
HC11. These features are not currently implemented
but are there for fimre use. Once the HC11 has
The H-Bridge is implemented with 2N3055
calculated the amount of speed to adjust for each
transistors m a TO-3 style case mounted to a heatsink
wheel, the data is sent internally to Port A. This data
on the robot chassis. The 2N3055 was selected for its
contains the speed in a Pulse Width Modulation
high current capacity in the case of fhure upgrades of
(PWM) format. Likewise, the direction of the motors
the motors. The Darlington pair consists of a 2N2222
is also specified. For the wheel to be stationary, no
from the buffer via the port and its pair is a 2N3055
PWM is specsed, and therefore has a duty of zero. All
which handles the high current from the H-Bridge.
data is buffered going into the HC 11 or from the HC 11
Connectors to the H-Bridge ftom the interface board
via 74HC541 buffers.
were used to allow for system upgrades and repair
without any desoldering. This is also true for the
Pulses from the left E/D pair are also fed into
Darlington pair with the power transistor the 2N3055.
the H C l l to the pulse accumulator in Port A PA7 to
The relay used is a sealed “dip” pack and can be
determine how far the robot has traveled. This will be
switched up to 3 million times. The relay was used to
explained hrther in the software section.
provide the necessary current to the transistors at 12V
and not 5V. If the relay was not used, an additional
The speed of each motor is controlled by PWM
gate would need to drive an intermediate transistor
where the duty cycle of the pulses determines the
before the power transistor. By using the relay, eight
overall voltage applied. If the duty cycle is 50%, then
transistors and eight resistors are eliminated. Since
board space is at a premium, the relay was selected. transition to occur after 80% of the counts, in effect a
Note, that a power MOSFET could be used, but the PWM of 80% has been performed. The robot uses two
price of a MOSFET capable of meeting the motor's such timers associated with PA3, and PA5. Their
current demand would be much higher. corresponding timer output compare registers are
TOC3, and TOC5 respectively. Each motor receives
data through the appropriate memory mapped register.
Software
To summarize, the main program must initialize
The fimction of the software is to implement a the two background routines, and then execute the
controlling algorithm which uses the data collected main body. First, it must obtain data fiom the user or
from the hardware. The algorithm adjusts the speed of host computer s p e c m g the speed, distance, and
each motor such that the robot travels along the direction. Once these parameters have been
specified trajectory. The data received by the H C l l is established, the program moves the robot. This is done
analog, and is converted into digital via onboard ADCs. by calculating the values for the PWM. After this, the
The data in the ADCs is 8 bits and represents the speed program executes until the interrupt from the distance
of each wheel respectively. counter occurs. It then services the ISR, and returns.
The control algorithm is implemented in the main
The software must ensure the following occurs: program body. The algorithm used is called a
Proportional-Integral control loop structure or simply a
1. The robot travels the specified PI controller, and is shown in figure 4.
distance.
2. The robot maintains the specified
trajectory.
3. The robot attempts to maintain the
desired speed unless the trajectory is
compromised.

In accomplishing these tasks, the program


incorporates background processing for the timers, and
the interrupts, while executing the main program. The
interrupt is used with the pulse accumulator to count
how many ticks from the encoder disc have been
received. This is done in the background while the main
program is executing. When the counter reaches its
limit and overflows, an interrupt occurs and the Figure 4. Proportional Integral Control Loop
program stops what it is doing to service the Interrupt implemented in software to control the system.
Service Routine (ISR). Once the ISR has been
executed, the program resumes where it had been prior The PI controller works as follows. First, the
to executing the ISR. The other background operation commanded speed is set and the robot starts by
is the PWM control. The PWM is performed separate "ramping-upyyto the commanded speed. This action
to the main program except for altering the PWM prevents any slippage that could occur under most
value. circumstances, and provides for uniform acceleration.
Once the robot is at the specified speed, the PI control
The PWM is carried out through the use of the system is implemented. The value of each wheel
dedicated internal timers and compare registers. Once encoder is read, and converted to digital. Shown in
the comparing registers are configured, the program figure 4 is the center feedback line where the two
only needs to write the value of the desired PWM velocities are subtracted and the error between them
speed. The internal timer continuously counts by integrated. This number is then multiplied by the
declaring a compare register to transition its port (Port integral constant called KI. The speed of each wheel is
A) after N counts have occurred. After a successfd also subtracted from the sum of the multiplied error and
compare, the port changes state until the main counter commanded speed. This value is then multiplied by a
completes its cycle. Therefore, by specifying the proportional constant KP. This &a1 offset value is
added, or subtracted depending on the sign, to the
753
existing value of command. This occurs when the port, and serial port. The motherboard, mounted on
program recalls the routine to move the robot. The the robot, will communicate all data to the H C l l
overall speed of each motor then adjusted. The robot directly via a special interface on the motherboard
then ramps down, or decelerates, to minimize error or attached to the expansion bus. The H C l l would
drifting that could occur due to sudden stops. communicate via its expansion bus by the userPC
Therefore, the robot slows down gradually. interface on the interface board. The user would then
communicate directly with the PC and never worry
The program can be summarized as follows: about the H C l l board.

1. Include libraries - technique used in C With the inclusion of a motherboard, a second


programming to import other code. HC 11 will be used to provide navigational information.
2. Declare macro definitions. This board will include a long range sonar system, and
3. Declare ISR. a close range infi-ared system. This board will
4. Initialize variables. communicate directly with the motherboard and only
5. Get information. have an emergency line connected to the motor
6. Set up when overflow is to occur. controller HC11. In the event a panic situation occurs,
7. Ramp up until overflow, then go on. there is little time for the ranging board to communicate
8. Travel, and perform PI loop until robot can with the motor controller board. Instead, the ranging
ramp down based upon interrupt state. system will alert the motor controller directly. With the
9. Ramp down until overflow. use of a PC,another addition will be speech recognition
10. Repeat process. and synthesis. This will be accomplished with one of
the many sound boards available on the market at fairly
Current Limitations and Future Implementations inexpensive prices. For example, a Sound Blaster
board facilitates speech recognition, and synthesis.
The current drawbacks of the control system With this approach, the user communicates to the PC
are based upon the fact that all information about travel by talking not typing, and the PC uses speech instead of
is obtained by wheel speed. There is no outside some type of display. Other such improvements then
reference or redundancy in the system. Because of this, may include manipulators, and actual vision.
the robot may ‘‘~nk~~owingly” exhibit error and
therefore be unable to correct for it. Another drawback Conclusion
is that the environment must still be somewhat
controlled. Not much lateral inclination can be The field of robotics, and moreover mobile
tolerated. robotics, is still in its infancy. A great number of
problems in robotics are created by interfacing a
To combat these limitations of the current laboratory oriented device to the outside ‘kea1 world”
generation, there are some implementations that could where imperfect circumstances exist. A method for the
improve the accuracy of the system. One such robot to compensate for these “imperfections” becomes
implementation is the use of a gyroscope. The vital if a robot is to operate correctly outside these
gyroscope would detect any angle deviation that may perfect environments. This design project looked at
be caused by slippage of the wheels. If the gyroscope only one technique to combat a particular problem. In
is enabled and drift occurs, then the H C l l could be doing so, s o h g the problem only opened more
alerted by an interrupt. Another improvement to the avenues to explore in such a new diverse field.
system is redundancy. The other pair of Ems could be
associated with input timers that could provide the Today, the “robot engineer” is provided with a
robot with position information also. Using the two multitude of possibilities to overcome the problems
sources of information together, the error would could associated with managing a robotic system in the real
be reduced further. world. The current state of processor technology
versus price is just one example. The languages being
Future enhancements will include a developed also provide better support for robotics.
motherboard (PC) on the robot. This would consist of Whether the robot is to be implemented as a servant or
an Intel 80386 processor with 1 MB. of memory, and for pure entertainment still remains uncertain, however,
interfaces for a disk drive, graphics display, parallel the potential is here.
754
References

1. Chubb, Bruce, Build You Own Universal


Computer Interface, Tab, 1989.
2. F l y , Anita., Jones, Joseph, Mobile Robots -
Inspiration to Implementation, A.K.
Peters, 1993.
3. Heiserman, David, How to Build and Desinn
Your Own Custom Robot, Tab, 1981.
4. McComb, Gordon, WBuilder’s Bonanza,
Tab, 1989.
5. Leibson, Steve, The Handbook of
Microcomr>uter,Tab, 1989.
6. Motorola, MC68HC11 Reference Manual,
Motorola, 1991.
7. National Semiconductor Corporation, Linear
Applications Handbook, National
Semiconductor Corporation, 1986.
8. New Micros Inc., NMM Evaluation Board,
New Micros, 1991.

755

Вам также может понравиться