A Two Wheeled Robot Control Ssytem - Boskovich

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

Transcript of A Two Wheeled Robot Control Ssytem - Boskovich

Page 1: A Two Wheeled Robot Control Ssytem - Boskovich

A Two Wheeled Robot Control System

Scott M. Boskovich

California State Polyrechnic University, Pomona 3801 W: Temple

Pomona, CA 91 768

Abstract

The purpose of this project was to desigq build and test a control system that controls two motors for a two wheeled robot. By implementing the control system, the robot will maintain a straight path under normal conditions. Without such a control system, the robot’s path would deviate from the specified direction. To implement the control system for the robot a two wheeled platform was built. Each wheel was interfaced to a microcontroller where the microcontroller performed a controlling routine stored in software. By implementing this design, the robot is able to correct for deviations.

Introduction

Soon, robots will become an everyday occurrence in people’s daily lives. Today, the field of robotics is in its infancy. Robot designers are plagued with problems of controlling the robots to compensate for simple operations people take for granted. Therefore, control systems must be implemented to ensure correct operation.

Several different types of drivetrain codgurations exist for mobile robots. There are legged robots that try to mimic the propulsion of a mammal, and there are wheeled robots. Of the wheeled robot types, there can be a single drive with a differential, or an independent drive to each wheel. The legged variety tends to be very difEicult to control and is very costly. The wheeled type tends to be more realizable for mobile robot operation.

With the wheeled robot type, there exists either a single drive or an independent drive configuration, The single type relies on one motor and some type of dzerential providing power to both wheels. A servo motor provides steering. This type must move forward

or reverse in order to turn, and therefore usually has a large tuming radius when compared to an independent type. The mechanics also tend to be much more involved. An example of a single drive system would be an automobile.

The independent type has a motor attached to each drive wheel which is mounted opposite of one another. The two adjacent sides have support casters attached to them to provide balance. The independent type allows for pivoting while in a stationary position by spinning each wheel in opposite directions. Depending on the direction of wheel rotation, the robot can pivot counter-clockwise or clockwise. To move forward or reverse, the wheels must spin in the same direction where the direction of spin determines forward or reverse movement. This type of robot can also turn about one wheel without the need for forward or reverse movement. This can be accomplished by spinning one wheel and not the other one. Depending on the direction of rotation of the wheel, the robot will turn about the stationary wheel.

By examining the difficulties associated with performance, the independent drive codlguration provides the best combination. However, there is a problem associated with this configuration. It assumes that both wheels have identical drivetrains, and the surface of travel is perfectly level and smooth. In the real world, this does not exist. Since no two

in the motors and fictional losses could cause one wheel to travel faster than the other. This causes the robot’s travel to deviate. Therefore, if the robot is commanded to travel straight, in actuality, the robot will drift toward the slower side. This severity of driR is dependent on the amount of difference between the two drivetrains and motors. For this reason, a means of control and compensation needs to be implemented to ensure that the robot travels in the specified direction.

drivetrains or motors are ever identical, the differences

ISBN# 0-7803-2636-9 7 50

Page 2: A Two Wheeled Robot Control Ssytem - Boskovich

Discussion

General System Theory

A control system for a two wheeled robot must involve the following:

1. A means of sensing the speed of each wheel. 2. A means of ‘bowing” the distance traveled.

3. The system must be able to adjust the speed of

4. The system should be able to allow for each wheel separately.

“imperfect” conditions.

Due to the complexity of the system requirements, a microprocessor is used for control. The microprocessor implemented is the MC68HCllE9 microcontroller from Motorola. The method of speed control utilized is Pulse Width Modulation (PWM). By varying the duty cycle of the signal sent to the motors, the speed is changed thusly. To extract the speed of each wheel, encoder discs and opto-interrupters are used. This combination incorporates a disc mounted on each drive shaft. The edge of the disc has 128 slots spaced evenly around the perimeter of the disc. The interrupters are mounted such that the disc fits between the void of the emitter and detector pair. Therefore, as the disc turns, the detector “sees” pulses fiom the emitter caused by the slots in the perimeter of the encoder disc. The frequency of these pulses correlate directly with the rotation of the wheel. Therefore, the speed of each wheel is obtained fiom the emitter. Figure 1 shows the general block diagram.

TO PCUSER MOTOR SHPIT T (PMSIW CONNECTION)

DRIVER MOTOR2

MOTOR SHAFT PMSlCAL CONNECTIOHJ

Figure 1 System Block Diagram

This control loop can also fimction to correct the robot’s drift that could be caused by unlevel surfaces. For example, a robot traveling on an unleveled path without this control loop implemented will drift towards the downward side. However, due to the nature of this control loop, the robot will maintain the specified trajectory. This is because the system will think there is a drivetrain difference, and therefore will adjust accordingly.

Electrical

The electrical subsystem of the robot comprises of three parts; analog, digital, and power. The analog part is responsible for controlling the motors and interpreting the inputs from the encoder disc. The digital portion, consisting of memory and a processor, executes the controlling algorithm stored in software. The digital part also provides an interface to a second dedicated processor for fbture developments. The interface board was designed as part of my senior design project and the processor board was purchased fiom New-Micros Inc. The processor board provides a 64K address space which can be configured with a combination of 8K-32K SRAM, 8K-32K EPROM, and/or 8K-32K EEPROM. It also provides an expansion port, serial communications via RS232, and LCD display capabilities. The power system provides two sources of 5V ( one for each board ) and 12V to the motors.

The power system consists of two sealed lead acid batteries configured in parallel providing a total of 14A/h. There are two linear voltage regulators, LM7805K, which provide the 5V required by each board. They are in a TO-3 style package and mounted to a heatsink on the robot chassis. The 12V is obtained 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 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 must be amplified and “squared up” by using a 74LS14 Schmitt trigger inverter. The square pulse is then converted to an analog voltage. This is accomplished

75 1

Page 3: A Two Wheeled Robot Control Ssytem - Boskovich

by using the LM331 frequency to voltage converter. This analog voltage is then filtered using an RC network, shown in figure 2.

squared pulse from El0 pair

Figure 2.

The value of 5V indicates excessive speed that might be incurred in downhill traveL The 0.5V difference is simply a safety margin. Therefore, by limiting the output to 4.5V under normal operation, downhill travel will be no problem

The analog voltage represents the speed of the 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 onboard analog to digital converters (ADC). The digital signal is 8 bits wide providing a representation 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 information about the direction of rotation. The pulses fi-om the second pair of Ems are fed directly into the HC11. These features are not currently implemented but are there for fimre use. Once the HC11 has calculated the amount of speed to adjust for each wheel, the data is sent internally to Port A. This data contains the speed in a Pulse Width Modulation (PWM) format. Likewise, the direction of the motors is also specified. For the wheel to be stationary, no PWM is specsed, and therefore has a duty of zero. All data is buffered going into the HC 11 or from the HC 11 via 74HC541 buffers.

Pulses from the left E/D pair are also fed into the HCl l to the pulse accumulator in Port A PA7 to determine how far the robot has traveled. This will be explained hrther in the software section.

The speed of each motor is controlled by PWM where the duty cycle of the pulses determines the overall voltage applied. If the duty cycle is 50%, then

the on time is half. The average voltage to the motor then becomes 6V, even though each swing is between OV and 12V. This P W M signal is applied to a Darlington pair for each motor. The motors’ directions are determined by the digital value from Port A, 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 signal fiom the relay. When one pair is ‘logic one,” the current in the motor is in one direction causing one direction of rotation. By turning on the other pair, the current in the motor is opposite and therefore the motor turns the opposite direction. By controlling the time the H-Bridge is active via the Darlington transistor pair with PWM, and choosing which state the direction bit is in, 111 control over each motor is achieved simultaneously. This is shown below in figure 3.

I P 12” I I l 2 V 9 2N30SS

From Conkoner

2N3055 2N3OSS

‘1 SpeedControl

Figure 3.

The H-Bridge is implemented with 2N3055 transistors m a TO-3 style case mounted to a heatsink on the robot chassis. The 2N3055 was selected for its high current capacity in the case of fhure upgrades of the motors. The Darlington pair consists of a 2N2222 from the buffer via the port and its pair is a 2N3055 which handles the high current from the H-Bridge. Connectors to the H-Bridge ftom the interface board were used to allow for system upgrades and repair without any desoldering. This is also true for the Darlington pair with the power transistor the 2N3055. The relay used is a sealed “dip” pack and can be switched up to 3 million times. The relay was used to provide the necessary current to the transistors at 12V and not 5V. If the relay was not used, an additional gate would need to drive an intermediate transistor before the power transistor. By using the relay, eight transistors and eight resistors are eliminated. Since

Page 4: A Two Wheeled Robot Control Ssytem - Boskovich

board space is at a premium, the relay was selected. Note, that a power MOSFET could be used, but the price of a MOSFET capable of meeting the motor's current demand would be much higher.

Software

The fimction of the software is to implement a controlling algorithm which uses the data collected from the hardware. The algorithm adjusts the speed of each motor such that the robot travels along the specified trajectory. The data received by the HCl l is analog, and is converted into digital via onboard ADCs. The data in the ADCs is 8 bits and represents the speed of each wheel respectively.

The software must ensure the following occurs:

1. The robot travels the specified

2. The robot maintains the specified

3. The robot attempts to maintain the

distance.

trajectory.

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 program stops what it is doing to service the Interrupt Service Routine (ISR). Once the ISR has been executed, the program resumes where it had been prior to executing the ISR. The other background operation is the PWM control. The PWM is performed separate to the main program except for altering the PWM value.

The PWM is carried out through the use of the dedicated internal timers and compare registers. Once the comparing registers are configured, the program only needs to write the value of the desired PWM speed. The internal timer continuously counts by declaring a compare register to transition its port (Port A) after N counts have occurred. After a successfd compare, the port changes state until the main counter completes its cycle. Therefore, by specifying the

transition to occur after 80% of the counts, in effect a PWM of 80% has been performed. The robot uses two such timers associated with PA3, and PA5. Their corresponding timer output compare registers are TOC3, and TOC5 respectively. Each motor receives data through the appropriate memory mapped register.

To summarize, the main program must initialize the two background routines, and then execute the main body. First, it must obtain data fiom the user or host computer s p e c m g the speed, distance, and direction. Once these parameters have been established, the program moves the robot. This is done by calculating the values for the PWM. After this, the program executes until the interrupt from the distance counter occurs. It then services the ISR, and returns. The control algorithm is implemented in the main program body. The algorithm used is called a Proportional-Integral control loop structure or simply a PI controller, and is shown in figure 4.

Figure 4. Proportional Integral Control Loop implemented in software to control the system.

The PI controller works as follows. First, the commanded speed is set and the robot starts by "ramping-upyy to the commanded speed. This action prevents any slippage that could occur under most circumstances, and provides for uniform acceleration. Once the robot is at the specified speed, the PI control system is implemented. The value of each wheel encoder is read, and converted to digital. Shown in figure 4 is the center feedback line where the two velocities are subtracted and the error between them integrated. This number is then multiplied by the integral constant called KI. The speed of each wheel is also subtracted from the sum of the multiplied error and commanded speed. This value is then multiplied by a proportional constant KP. This &a1 offset value is added, or subtracted depending on the sign, to the

753

Page 5: A Two Wheeled Robot Control Ssytem - Boskovich

existing value of command. This occurs when the program recalls the routine to move the robot. The overall speed of each motor then adjusted. The robot then ramps down, or decelerates, to minimize error or drifting that could occur due to sudden stops. Therefore, the robot slows down gradually.

The program can be summarized as follows:

1.

2. 3. 4. 5 . 6 . 7. 8.

9. 10.

Include libraries - technique used in C programming to import other code.

Declare macro definitions. Declare ISR. Initialize variables. Get information. Set up when overflow is to occur. Ramp up until overflow, then go on. Travel, and perform PI loop until robot can ramp down based upon interrupt state. Ramp down until overflow. Repeat process.

Current Limitations and Future Implementations

The current drawbacks of the control system are based upon the fact that all information about travel is obtained by wheel speed. There is no outside reference or redundancy in the system. Because of this, the robot may ‘‘~nk~~owingly” exhibit error and therefore be unable to correct for it. Another drawback is that the environment must still be somewhat controlled. Not much lateral inclination can be tolerated.

To combat these limitations of the current generation, there are some implementations that could improve the accuracy of the system. One such implementation is the use of a gyroscope. The gyroscope would detect any angle deviation that may be caused by slippage of the wheels. If the gyroscope is enabled and drift occurs, then the HCl l could be alerted by an interrupt. Another improvement to the system is redundancy. The other pair of Ems could be associated with input timers that could provide the robot with position information also. Using the two sources of information together, the error would could be reduced further.

Future enhancements will include a motherboard (PC) on the robot. This would consist of an Intel 80386 processor with 1 MB. of memory, and interfaces for a disk drive, graphics display, parallel

port, and serial port. The motherboard, mounted on the robot, will communicate all data to the HCll directly via a special interface on the motherboard attached to the expansion bus. The HCl l would communicate via its expansion bus by the userPC interface on the interface board. The user would then communicate directly with the PC and never worry about the HCl l board.

With the inclusion of a motherboard, a second HC 1 1 will be used to provide navigational information. This board will include a long range sonar system, and a close range infi-ared system. This board will communicate directly with the motherboard and only have an emergency line connected to the motor controller HC11. In the event a panic situation occurs, there is little time for the ranging board to communicate with the motor controller board. Instead, the ranging system will alert the motor controller directly. With the use of a PC, another addition will be speech recognition and synthesis. This will be accomplished with one of the many sound boards available on the market at fairly inexpensive prices. For example, a Sound Blaster board facilitates speech recognition, and synthesis. With this approach, the user communicates to the PC by talking not typing, and the PC uses speech instead of some type of display. Other such improvements then may include manipulators, and actual vision.

Conclusion

The field of robotics, and moreover mobile robotics, is still in its infancy. A great number of problems in robotics are created by interfacing a laboratory oriented device to the outside ‘kea1 world” where imperfect circumstances exist. A method for the robot to compensate for these “imperfections” becomes vital if a robot is to operate correctly outside these perfect environments. This design project looked at only one technique to combat a particular problem. In doing so, s o h g the problem only opened more avenues to explore in such a new diverse field.

Today, the “robot engineer” is provided with a multitude of possibilities to overcome the problems associated with managing a robotic system in the real world. The current state of processor technology versus price is just one example. The languages being developed also provide better support for robotics. Whether the robot is to be implemented as a servant or for pure entertainment still remains uncertain, however, the potential is here.

754

Page 6: A Two Wheeled Robot Control Ssytem - Boskovich

References

1. Chubb, Bruce, Build You Own Universal

2. F l y , Anita., Jones, Joseph, Mobile Robots - Computer Interface, Tab, 1989.

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.

New Micros, 1991. 8. New Micros Inc., NMM Evaluation Board,

755