Documente Academic
Documente Profesional
Documente Cultură
Thats the task given to four senior electrical engineering students at Oklahoma Christian University nearly two years ago. While the original intent of this project was to raise funds for the IEEE student branch at Oklahoma Christian University, the chance to supply robot enthusiasts with a highly functional motor controller for a fraction of the price is equally as satisfying. After the initial functional requirements put forth by both faculty and robot hobbyists, the bar was set to create a motor controller unlike any
discussed, however, two basic principles of motor controllers must be considered. First, the motor controller must be capable of sending as well as receiving a signal. In a closed-loop system, this signal is called the feedback signal. For the motor controller discussed here, the feedback signal is generated by the use of quadrature encoders placed on each motor. Quadrature encoders contain two optical sensors mounted on the motor shaft as shown in Fig. 1(a). Figure 1(b) shows the output of each sensor as the motor rotates. The pulse width of the square wave represents how fast the motor is
motor eliminates the initial overshoot, oscillating corrections, and the steadystate error involved with a system that does not utilize PID.
System overview
After understanding the two basic principles involved with a motor controller system, the task of creating a highly functional motor controller becomes much simpler. In essence, a highly functional controller needs to output a PID-controlled signal to the users motors and accept an encoded feedback signal as input. Since this
DIGITAL VISION
James Klein
40
IEEE POTENTIALS
Commands are sent to the motor controller by either the users microprocessor or a PC. These commands are input only to the master processor, which then relays any necessary information to the slave processor. The master and slave processors then maintain a constant line of communication as they each control their individual motor to achieve the desired movement.
Hardware
Since a conceptual design is not able to actually turn a motor, the next step is to build a prototype. Initially, a breadboard circuit was created from the schematic shown in Fig. 4. This breadboard circuit was tested to validate the conceptual design. Once it was clear that the design was appropriate, the printed circuit board (PCB) shown in Fig. 5 was fabricated. For the master and slave processors, the PIC18F2431 was chosen. For the power delivery to the motors, the Motorola MC33186 was selected. The voltage regulation task is accomplished by the LM2575, and the RS-232 interfacing is achieved by the DS276 integrated circuit. With these components, this dual motor controller system is capable of accepting an input voltage of up to 28 V. The LM2575 would then regulate this voltage level down to a steady 5-V signal, while the MC33186 h-bridges would perform PWM manipulation of the input voltage. The MC33186 h-bridges are capable of outputting a maximum of 28 V and 5 A continuously, while handling peaks of 40 V and 6 A. These high power levels are seldom needed for normal hobby robot applications, but the ability of the controller to output these signals increases the versatility and functionality of the system. The physical dimensions of the PCB shown in Fig. 5 are 3.0 in x 2.7 in x 0.7 in. This compact size is due in part to the fact that all components, except for wire connectors, are surface mount packages. This PCB also contains a shared clock signal between the two PIC18F2431 processors. The ability to share this single clock signal reduces both the size and cost of the motor controller system. The final product created by the completion of this project will be even smaller than the prototype PCB shown in this document. The two large programming connectors located at the bottom of the PCB will not be needed for the final product, since the processors will already contain the final version of software discussed in the following section. The small size and
low clearance of this dual motor controller system will allow the user to implement this controller in various locations and applications. Currently, the prototype PCB is being tested to show that it is capable of meeting the functional requirements that have been set for it. A simple test program has been run to prove the systems ability to output a PWM signal to two motors simultaneously. A second test program was used to test the ability of the master processor to receive a command from an external processor. All testing has been successful to this point, and it is believed that the creation of this hardware platform is the first milestone in producing one of the first dual closed-loop dc motor controllers.
Software
Now that the hardware has laid the foundation for a dual motor controller system, sophisticated software must be developed to build on this foundation. Research was initially performed to gain a better understanding of the overall flow of information involved. From this research, a flowchart was developed that detailed the necessary transfer of information throughout the entire motor controller system (Fig. 6). This flowchart can be broken into four functional tasks: command, encoder, motor, and self-tuning. The command task may be thought of as the brains of the operation. This task is responsible for receiving commands from the user and then outputting the appropriate command to the motor task. The command task must also consider
1.5 1 0.5 0 0
1.5 1 0.5 0
0.5
1.5
2.5
0.5
1.5
2.5
Fig. 2 The effect of PID terms on a systems output (voltage versus time)
User I/O
Legend Information Signal Power Signal (5 V) Power Signal (Vin) Deliverable Item Encoder
Interface
Encoder
Microprocessor (Master)
Motor
H-Bridge
Voltage Regulator
H-Bridge
Battery
AUGUST/SEPTEMBER 2005
41
self-tuning function utilizing the Ziegler/Nichols method. The real-time implementation of this software within the motor controller system has yet to occur, however. The most difficult software-related task that arises when constructing a dual motor controller system is not how to control the motors or how to calculate the PID values but rather how to communicate effectively throughout the entire system. Multiple communication protocols are needed to facilitate the transfer of information inside and outside of the motor controller system. The user may choose to control the motor controller from a PC or directly from a microprocessor on the same robotic platform as the controller. If the PC is chosen, an RS232 serial transmission is required. If an external microprocessor is used, communication with the Fig. 4 Schematic design of the dual closed-loop dc motor PIC18F2431 master processor controller system of the motor controller will take place using the Universal Synchroinformation received from the encoder nous-Asynchronous Receiver/Transmitter task, which compares the actual output of (USART) protocol. A third protocol, Unithe system to the desired output. After versal Asynchronous Receiver/Transmitter obtaining this error information from the (UART) is used for the communication encoder task, the command task must between the master and slave processor constantly update its output to the motor within the motor controller system. task. To ensure that the output of the Clearly, the software involved with a motor task is as optimal as possible, the dual motor controller system requires self-tuning task calculates the appropriate more than simply creating an output gain values for each PID term to be used and reading an input. Each functional in the PID control algorithm. piece of code, such as PID calculation The self-tuning task is another distincor USART communication, is created tion that sets it apart from currently availand tested individually before being able motor controllers. The self-tuning placed into the overall software of the task contains a specialized PID algorithm master and slave processors. Currently, that will automatically calculate the correct the motor controller system is able to P, I, and D gain values by performing a receive a command from the user, sent series of initialization movement tests. The either through an RS-232 or USART user may request this initialization to take connection. That command is then recplace by sending the appropriate comognized by the master processor, and mand to the system. Once the initial gain all necessary data is relayed to the slave values have been found, the self-tuning processor through the UART connectask will then automatically update these tion. Finally, each processor controls its values periodically to ensure precise own motor according to the specific movement at all times. The self-tuning command sent by the user. Presently, task will also store the latest PID gain valthe user may send a command for the ues within the master and slave processor. robotic platform to either move a speciThe user may then request these values fied distance or turn at a specified by once again sending a single command angle. If a movement command is sent, to the motor controller system. Currrently, the user may also specify trapezoidal software has been written to perform the
MCLR RESET1 R7 P$2 2 1 P$1 + 180 P$3 P$4 4 3 + C6 Vdd +5V 33uF + C7 1N4148 ENCODER1 22uF D2 C3
1 Vcc RXout 2 Vdrv+ RXin 3 TXin + Vdrv 4 GND TXout 14 RC3 13 RC2 12 RC1 11 RC0 10 OSC2 9 OSC1 8 GND AVss 7 AVdd1 AVdd 6 + RA4 5 RA3 4 RA2 3 RA1 2 RA0 1 MCLR
velocity control values such as acceleration rate, maximum velocity, and deceleration rate. The steady acceleration and deceleration of the trapezoidal velocity software allows the motor controller to precisely control the distance traveled by preventing any uneven starts or sliding stops. At the completion of this project, other commands such as self-tuning and change direction will be integrated into the final software. Once the existing hardware platform is joined by this completed software, a motor controller system unlike any other currently available will be realized.
DS276
IC1
14 RC3 13 RC2 12 RC1 11 RC0 10 OSC2 9 OSC1 8 AVss 7 AVdd 6 + RA4 5 RA3 4 RA2 3 RA1 2 RA0 1 MCLR
GND AVdd2 1 2
8 7
6 5
ENCODER2
1 2
Vss Vdd RB0 22 RB1 23 RB2 24 RB3 25 RB4 26 RB5 27 RB6 28 RB7
15 16 17 18 19 20 21
15 16 17 18 19 20 21 22 23 24 25 26 27 28
IC2
+5V
COUT
330uF
+5V
+ CCP2
CCP1
33nF
330uH +
LM2575
L1
GND
100uF
+ CIN
20 19 18 17 16 15 14 13 12 11
+5v
H1
H2
1 2 3 4 5 6 7 8 9 10
+5V
10k
R1
+5V
R2
MOTOR1 2 1
MOTOR2
2 1
AGND
PGND
PGND
NC
VBAT
+5V
33nF
42
6 6 5 5 4 4+ 3 3 2 2 1 1
PROG2
33uF
VBAT
VBAT
10k R8
AVdd2
10k R6
PWM4
PWM3
PWM2
D4
D5
D3
PWM1
2 1 6 5 4 3
PROG1
2 1 6 5 + 4 3
125
R5
R3 125
R4 125
VBAT
VBAT
24pF
10MHz C2 + C1
Q1
AVdd1
24pF
D1
40v,1A
+5V
+5V
BATTERY
TX 1 RX 2
1 2
1 2 3
RS-232
USER_UP
Production costs
Along with considering the hardware and software aspects, it is also necessary to mention the costs associated with this motor controller system. If this project created a motor controller that is more functional than any existing controller, but cost twice as much, the project would be a failure. It is vital to the successful completion of this project that the motor controller being designed is done so in the most efficient manner possible. Table 1 shows the manufacturing budget, which is broken down into four hardware subsystems. Each category includes the main integrated circuit (IC) necessary to complete the task of the subsystem and the miscellaneous electrical and hardware components necessary to properly operate the ICs. In addition to the four subsystem categories, there are also two separate manufacturing categories. The first, PCB fabrication, is the cost of fabricating the PCB of the motor controller system. It has been found that for approximately US$300 it is possible to manufacture 100 PCBs of the size and complexity of our motor controller. The second category, miscellaneous manufacturing, is designated to cover manufacturing expenses such as solder, soldering iron tips, and flux. The original requirements stated that the dc motor controller created
IEEE POTENTIALS
Table 1 Component Costs Category Data processing (PIC18F2431) Data processing components Motor control (MC33186) Motor control Components Voltage regulator (LM2575) Voltage regulation components RS-232 interface (DS276) RS-232 interface components PCB fabrication Miscellaneous manufacturing Total: Budget: Cost $10.76 $1.48 $7.44 $0.22 $1.38 $1.94 $2.66 $0.55 $3.35 $0.10 $29.88 $30.00
future will greatly impact the motor controller industry by creating a product that performs far beyond its expectations.
Acknowledgments
This project is based on the work performed by four senior electrical engineering majors at Oklahoma Christian University: James Klein (team leader, hardware creation and testing), Jacob Richardson (software concept creation; interface programming), Dominic Rodriguez, (motor control programming; hardware testing), and Benjamin Thornton (PID control research and analysis; software concept creation). This team of students is mentored by Dr. David Waldo, an engineering professor at Oklahoma Christian University.
control: Implementing a PIC-SERVO controller, Circuit Cellar, no. 12, pp. 5459, July 2000. M. Dvorsky, Fighting fire with robots: How to build a mobile robot base, Circuit Cellar, no. 128, pp. 2638, Mar. 2001. J. Kerr, PIC-SERVO motion control products, Jan. 2005 [Online]. Available: http://www.jrkerr.com/orders.html
must be manufactured for less than US$30 per board, when manufactured in quantities of 100 boards or greater. Due to this requirement, the prices of components and the cost of PCB manufacturing all pertain to orders in quantities of 100 or greater. Therefore, if only one motor controller circuit were to be built, the cost would be slightly higher than the US$29.88, especially due to the high cost of manufacturing a single PCB design. However, the current budget calculations show that this project has met the requirement to produce a dc motor controller in quantities of 100 for less than US$30 per board. By meeting this requirement, the dual closed-loop dc motor controller will be able to be sold for less than the cost of an equivalent single dc motor controller. This will allow a greater number of robot hobbyists and enthusiasts to create a sophisticated robotic platform that they otherwise would not have been able to.
Slave
Actual Speed
Command Task
Actual Speed
Processor Data
PID Gains
Write To Flash
Conclusions
The successful completion of this project will introduce a new type of dc motor controller into the hobby robotics industry. Testing has shown that the hardware platform designed and created by this project is capable of performing all the functionality of a high-end motor controller while controlling two dc motors. The finalization of remaining software will definitively accomplish the goal of creating a dual motor controller that is more functional and more userfriendly than any motor controller currently available. The creation of such a product will allow experienced and novice robot hobbyists alike to create complex and inexpensive designs that they otherwise may not have. In short, the completion of this project in the near
Serial Transmit
Serial Receive
User Commands
PID Gains
Motor Task
H-Bridge Motors
AUGUST/SEPTEMBER 2005
43