Sunteți pe pagina 1din 6

2010 7th International Multi-Conference on Systems, Signals and Devices

Fuzzy Control ofa Two-Wheel Balancing Robot using DSPIC


Samer Miasa, Mohammad AI-Mja/i, Anas AI-Haj Ibrahim, and Tarek A. Tutunji Department of Mechatronics Engineering, Philadelphia University
Abstract- This paper is concerned with the design and implementation of a two-wheel balancing robot. The angle and angle change are used as inputs to the robot system in order to calculate the appropriate motor force to balance the robot. ADXL330 accelerometer and two DC motors are used as the sensor and actuators, respectively. More importantly, the robot system uses fuzzy control that is implemented on DSPIC30F2010. The robot under study represents a mechatronic system because it involves an integrated design among mechanics, electronics, and embedded smart controllers. The system model is first tested under Matlab/Simulink. Then, the Printed Circuit Boards are designed, the C-program is written, and the mechanical structure is built. Finally, the robot is built and tested in the laboratory.
Keywords: DSP

Balancing Robot, Fuzzy Control,


INTRODUCTION

I.

Self-balancing electric vehicles are considered to be an appropriate form of transportation in several areas, such as police departments, military bases, warehouses, corporate campuses or industrial sites. This is due to their compact size, efficient energy consumption, ease of use, and low cost. Therefore, the design and implementation of a prototype two-wheel balancing robot is considered in this paper. Fully autonomous balancing robots come in all shapes and sizes. Examples of such balancing robots are: NBOT, EPFL, and EQUIBOT. The NBOT was designed and implemented by NASA [1]. This robot's initial design had three wheels with a ball-bearing pivot attached to a three-foot wooden pole. A potentiometer was used for measuring the tilt angle of the pole. After learning to balance the pole, the robot was re-built as a two-wheel version, with the battery mounted directly above the wheels. The ball bearing pivot was attached to the bottom of the robot with a short aluminum feeler touching the floor. Two feedback sensors were used: an angle sensor to measure the tilt of the robot and wheel

encoders to measure the position of the robot base. The Industrial Electronics Laboratory at the Swiss Federal Institute of Technology built a two-wheeled prototype vehicle called EPFL [2]. Each of the wheels was coupled to a DC motor. The vehicle was able to do stationary U-turns. The control system was made up of two decoupled state-space controllers to keep the system in equilibrium. Each controller applied an appropriate torque to its associated axis. A decoupling unit then translates these two signals into a torque to be applied to the left and right hand side motor respectively. The system angle and rate were measured using incremental encoders mounted on the two DC motors The EQUIBOT was based on the RISC microcontroller [3]. The base was built from acrylic sheet. Six batteries with 5V regulator were used to provide power to the microcontroller and sensors. An infrared sensor was used to measure distance to the floor and therefore the robot's leaning direction. Pulse Width Modulation (PWM) was used to control the rotation of servo motors. Other interesting research on balancing robotics follows: a two-wheeled mobile robot for baggage transportation and navigation [4], an adaptive control using radial-basis-function neural networks for a two-wheeled self balancing scooter [5], and a single-wheeled mobile robot with mouse-ball drive [6]. In this paper, a two-wheel balancing robot was design and implemented. The robot used a fuzzy control system programmed in a DSP chip. Two DC motors were used for rotation and an accelerometer sensor was used to measure the tilt angle. The mechanical structure was composed of four plastic plates and four aluminum rods. This paper is divided as follows: section II presents the design background, section III gives the simulation results while section IV provides the hardware implementation. Finally, section V concludes the paper.

978-1-4244-7S34-6/l0/$26.00 2010 IEEE

2010 7th International Multi-Conference on Systems, Signals and Devices

II.

DESIGN BACKGROUND

The objective of this project was to design and implement a robot capable of sustaining a vertical orientation by balancing on two wheels. In order to initiate the design process, a thorough understanding of the system dynamics and modeling is needed. Since the balancing robot system dynamics were not available and were difficult to acquire, the well-known pole cart problem was used as a reference as shown in Figure I. The pole-cart system has many similarities with the proposed project and therefore was used as basis for this work. The task of the controller is to apply an appropriate force u(t) to the cart to keep the rod standing upright. The main task is to design a controller that can control both the pendulums angle and the carts position.

The pole-cart problem was used as a reference for developing the fuzzy controller rules and tuning its parameters. This was a necessary step in order to tune and simulate the controller. Note here that the mathematical model of the proposed two-wheel balancing robot was not available and was difficult to calculate. Therefore, intelligent controllers, such as fuzzy was the appropriate decision. This is due to the fact that fuzzy controllers can be applied to systems using "IF ... THEN" rules without the need to defme the system mathematically. The design steps used in this work was organized as shown in Figure 2. Notice that the design followed parallel steps: simulation, mechanical, and electronic. This methodology is crucial, especially for mechatronic systems, in order to apply synergic design and therefore shorten the design cycle time.

SIMULINK Pole-Cart
u

r-i

I start I

Mechanical Structure 2-Wheel Robot

Electronic Circuit Design Figure I. Pole-Cart System The following model parameters are given next: is the mass of the cart, m is the mass of the pendulum, b is the friction of the cart resisting motion, L is the length of the pendulum to its center of mass, I is the inertia of the pendulum, u(t) is the force applied to the cart, x represents the cart position coordinate, () is the angle of the pendulum measured from the vertical. To design a controller for the inverted pendulum from a standard control viewpoint, it is first necessary to determine to draw its free body diagram and determine its mathematical model. The mathematical derivation is well established in the literature [7,8]. Here, the final model is presented
M

..
Proteus Simulation

4
Build and Test 2-Wheel Robot

+-

..
End

Figure 2. Design Chart


III. SIMULATION

(s) U(s) r

mL s r r r

( I)

The pole-cart model shown in equation I was used in Simulink as the plant model and a fuzzy controller was designed. The system block diagram is shown in Figure 3 while Simulink program is shown in Figure 4.

wher(J r= (M+m mi3+1 - (mL)2

2010 7th International Multi-Conference on Systems, Signals and Devices

DSPIC Controner
,-------, III) I ) I ) I ) ) I ) ) I l_____________________ _

DEC

INC

-200

200

d9/dt (degree/sec)

Figure 6. Fuzzy sets for the angle change (input)


NBB NB N Zero P PB PBB

Figure 3. System Block Diagram

o
Scopt1

-2

.
-0.5 0.5 Force (x1,OOO) 2

Figure 7. Fuzzy sets for the force (output) Table 1 Fuzzy Rules Figure 4. Simulink Program In the Simulink code, the reference angle was set to 0 while a disturbance pulse with amplitude of 10 and period of 2 seconds was added to the output of the controller. This disturbance was multiplied with a random signal between -2 and 2. The Fuzzy controller details are as follows: the system has two inputs (angle and angle change) and one output (force). The angle used five fuzzy sets (NB: Negative Big; N: Negative; Null; P: Positive; and PB: Positive Big) as shown in figure 5. The angle change used two fuzzy sets (Decrease and Increase) as shown in Figure 6. The output had seven sets (NBB: Negative Big Big; NB: Negative Big; N: Negative; Zero; P: Positive; PB: Positive Big PBB: Positive Big Big) as shown in Figure 7. The fuzzy set limits were later adjusted for practical implementation as will de described in section IV. The fuzzy rules are summarized in Table 1.
NB N Null P PB

e NB de/dt INC DEC

Null

PB

P PBB

Z PB

N P

NB Z

NBB N

During the simulation stage, several issues were considered and some problem had to be resolved: The initial simulation results had unstable oscillation. This unstability was solved by increasing the sample rate to 200 radls; the output signal from the scope was weak. This was solved by using amplifier; the system remained at rest when reference of '0' was used. This was solved by adding disturbance to the output of the controller. Figure 8 shows that the angle was able to balance around its reference (set value) of O. The disturbance effect on system can be easily noticed specifically the beginning (angle of -8) then the angle stabilized between -1 & +1. Figure 9 shows the output of the fuzzy controller. Note that at 6s the output was high because the angle change was large. So the controller gave an opposite action to stabilize the system.

-20

-10

0.0

10

20

9 (degree)

Figure 5. Fuzzy sets for the angle (input)

2010 7th International Multi-Conference on Systems, Signals and Devices

Figure 8. Angle Response using Simulink

Figure 9. Fuzzy Output using Simulink Once the SIMULINK program produced acceptable results, the electronic circuit was designed. The fuzzy program was written for DSP and simulated in Proteus program.
IV. IMPLEMENTATION

As indicted in the design section. The system design consisted of electronics and mechanical parts. The system block diagram is shown in Figure 10.

DSPIC

The search for a suitable angle sensor was started by looking for similar projects. The best choice was ADXL330 from Analog Devices. This sensor had appropriate accuracy with reasonable cost. ADXL330 sensor was used to convert the angle change to voltage change (x axis). The sensor was calibrated to provide 1.95 Volts for 0 degrees and 1.6 Volts for 90 degrees. A DSP controller was needed to provide fast response. DSPIC30F2010 from microchip was found to be an appropriate choice for the application at hand. This DSP chip had the following features: 16-bit signal controller, modified Harvard architecture, C-complier optimized, 30 MIPS operation, motor control PWM module, 10-bit ADC with 1Msps conversion rate, and single-cycle multiple-add operation. The fuzzy control algorithm was programmed in C and downloaded the DSP chip. It is worth noting here that the fuzzy sets given in the previous section (Figures 5,6, and 7) that were used in simulation were modified for the practical DSP implementation. The modification was as follows: the angle change limits were set between -20 and 20 (instead of 200 and 200 in simulation). Also, the force output in the practical implementation used Pulse Width Modulation (PWM) and applied to the wheels via the two motors. Here, the PBB was implemented as 100% duty cycle on the right hand wheel and NBB was the 100% duty cycle on the left hand wheel. The other fuzzy set limits were adjusted accordingly. Compatibility between sensor and the controller was studied. The sensor frequency used was 500 Hz that was sent as pulses the controller pins. This signal was also monitored on the oscilloscope. The design of the Printed Circuit Boards (PCBs) was done using Eagle program as shown in Figure 11. Then the circuit was built on fiber glass. Testing stages included the following: control circuit components were tested without DSPIC. Then the DSPIC was tested in the labs. The H-bridge drive circuit was tested by applying different PWM signals using function generators. Then, all the sub-systems were combined and tested.

Robot

Figure 10. System Block Diagram

2010 7th International Multi-Conference on Systems, Signals and Devices

activated by Pulse Width Modulation (PWM), were used for the wheels. The free-body diagram for the force calculations is shown in Figure 15.

Figure 11. Printed Circuit Design using Eagle


-.--+--

mg sin 20

The final PCBs are given in Figures 12, 13 , and 14. Those show the power circuit drive, DSP, and sensor PCBs respectively.

,II;-- f
Figure 15. Force Calculations Two sets of batteries were used: a single battery for the motors (4N6V) and four-batteries for the IC components that supplied 4.8V and 1.3A. Also, the batteries were coated with heat coat material for isolation purposes. The robot chassis design was constructed using four plastics plate as roofs with the same dimension (200x100mm), four aluminum rod with 200mm long and 10mm in diameter, two wheels with 120mm diameter. The robot was tightened by screws and nuts. The robot construction was designed to hold three layers for the needed system components. The total weight was 3 Kg. The chassis height can be lowered and increased as desired. This adjustment is useful for calculating the center gravity (CG) of the robot. The final robot prototype built is shown in Figure 16.

Figure 12. Power Circuit PCB

Figure 13. DSP PCB


ADXL330

Figure 14. Accelerometer ADXL330 PCB The maximum tilt angle was 20 degrees and therefore the maximum needed force was calculated to be 6.7 N. Two 6-V DC motors, Figure 16. Two-Wheel Balancing Robot Built

2010 7th International Multi-Conference on Systems, Signals and Devices

v.

CONCLUSION

8.

In this paper, a prototype for a two-wheel balancing robot was designed and implemented. Since the robot system dynamics were not available, the pole-cart problem was used as a study reference during simulation. The system was simulated and tested using two software packages: Matlab/Simulink and Proteus. More importantly, the robot was built and tested in the laboratory. The main components of the designed system were: ADXL330 analog sensor which provided voltages according to the angle tilt, DSPIC30F201O (with micro-controller embedded fuzzy program) used to control the robot balance, H-bridge power circuit, and two DC motors used to move the robot in order to balance the system. The selection and testing of the angle sensor and the controller was an important part of this work. Final results showed that the embedded fuzzy controller performed well in balancing the two-wheel robot prototype in real-time.
REFERENCES

Nguyen, Prasad, Walker, and Walker. "A First Course in Fuzzy and Neural Control" 2003 Chapman Hall ICRC Press Company

1. 2.

3. 4.

5.

6.

7.

http://www.geology.smu.edu/dpa www/robo/nbotl Accessed date 10/3/2010 Grasser, F. D'Arrigo, A Colombi, S. Rufer, AC. "JOE: a mobile inverted pendulum", IEEE Transactions on Industrial Electronics. Vol. 49, issue 1, Feb 2002 http://homepage.mac.com/sigfpe/Robotics/eq uibot.html. Accessed date 20/4/2009 Takei, T. Imamura, R. Yuta, S. "Baggage Transportation and Navigation by a Wheeled Inverted Pendulum Mobile Robot". IEEE Transactions on Industrial Electronics. Vol. 56, Issue 10, Oct. 2009 Tsai, Huang, and Lin. "Adaptive Neural Network Control of a Self-Balancing Two Wheeled Scooter" IEEE Transactions on Industrial Electronics. Vol. 57, Issue 4, April 2010 T. B. Lauwers, G. A Kantor, and R. L. Hollis."A Dynamically Stable Single Wheeled Mobile Robot with Inverse Mouse Ball Drive". Proc. IEEE Int'l. Conf. on Robotics and Automation, Orlando, FL, May 15-19, 2006 Ogata k, "Modem Control Engineering", Prentice Hall, Engle wood cliffs, NJ, 3rd edition.

S-ar putea să vă placă și