Ball Balancing System Using Fuzzy Logic
B.E. Project Report-A
Submitted in partial fulfillment of the requirements
For the degree of
Bachelor of Engineering
(Electronics Engineering)
by
Yash Shukla (15EE1136)
Akshay Pate (15EE1149)
Supervisor
Ms.Hemalata Biradar
Department of Electronics Engineering
Ramrao Adik Institute of Technology,
Sector 7, Nerul , Navi Mumbai
(Affiliated to University of Mumbai)
November 2019
Ramrao Adik Education Society’s
Ramrao Adik Institute of Technology
(Affiliated to the University of Mumbai)
Dr. D. Y. Patil Vidyanagar,Sector 7, Nerul, Navi Mumbai 400 706.
Certificate
This is to certify that, the project report-A titled
“Ball Balancing System ”
is a bonafide work done by
Akshay Pate (15EE1149)
Yash Shukla (15EE1136)
and is submitted in the partial fulfillment of the requirement for the
degree of
Bachelor of Engineering
(Electronics Engineering)
to the
University of Mumbai.
Examiner 1 Examiner 2 Supervisor
Project Coordinator Head of Department Principal
i
Declaration
I declare that this written submission represents my ideas in my own words and where
others’ ideas or words have been included, I have adequately cited and referenced the orig-
inal sources. I also declare that I have adhered to all principles of academic honesty and
integrity and have not misrepresented or fabricated or falsified any idea/data/fact/source
in my submission. I understand that any violation of the above will be cause for disci-
plinary action by the Institute and can also evoke penal action from the sources which
have thus not been properly cited or from whom proper permission has not been taken
when needed.
(Signature)
(Name of student and Roll No.)
Date:
Abstract
An intelligent system is designed that aims at moving a ball from wherever it is placed
on a plate to the center. The system includes a ball, a plate, two servo motors, a web
camera and EVK1100 microcontroller board. The plate has two degrees of freedom in
order to achieve this objective and its movement is controlled by using two servo motors
placed perpendicular to each other. A webcam is used to capture the frames and image
processing is done in MATLAB to find the position of the ball. A fuzzy controller is used
to bring the ball to a stop at the center of the plate. EVK1100 microcontroller board is
programmed to give the required pulse width modulated signal to the motors which con-
trols the movement of the plate. In this report, we have detailed the problem description,
the approach adopted to do this project and the various phases of implementation.
Keywords:
Control system, Webcam,EVK1100 microcontroller, PWM.
iii
Contents
Abstract iii
List of Figures v
List of Tables vi
1 Introduction 1
1.1 System Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Problem Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Organization of Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Literature Survey 4
3 System Design 5
3.1 COMPONENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 IMPLEMENTTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4 Result 8
5 Conclusion and Future work plan 9
Bibliography 10
Acknowledgments 12
iv
List of Figures
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.1 Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 ImageProcessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3 ImageProcessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
v
List of Tables
vi
Abbreviations
ASIC Application Specific Integrated Circuit
CLB Configurable Logic Block
FPGA Field Programmable Gate Array
HDL Hardware description language
I/O Inputs and Outputs
ISE Integrated software environment
IEEE Institute of Electrical andElectronic Engineers
JTAG Joint Test Action Group
LUT Look Up Table
PWM Pulse Width Modulation
RTL Register-transfer level
SVPWM Space Vector Pulse Width Modulation
VHDL VHISC Hardware Description Language
VHSIC Very High Speed Integrated Circuit
XST Xilinx Synthesis Technology
Chapter 1
Introduction
The balancing ball on plate is an intelligent control system capable of controlling the
movement of ball so that it comes to a halt at the center of the plate. The initial position
of the ball will be captured by the web camera which is recorded as the initial error and
both the motors are moved such that the ball moves to the center of the plate. We assume
that the ball is only rolling on the plate without slipping. The new position of ball on
the plate is a feedback to the previous movement of motors and again motors are moved
to rectify that. This process continues until the ball comes to a complete halt at the
center of the plate. Before implementing this project, we have referred quite a number of
literatures to see how researchers have done previously. We have studied similar kind of
projects like balancing ball on beam which is basically controlling the movement of ball
in only one dimension. Also, we have studied various techniques adopted to control the
motion of ball like the PID controller and fuzzy logic controllers and we found that fuzzy
logic is more effective and the state of the art technique used for this kind of applications.
One of the major challenges that we faced in this project is locating the ball on the plate.
The literatures that we referred show that people have used various techniques such as
web camera, resistive touchscreens, and sensors etc. for finding the position of the ball
on the plate. In this project, we have used a web camera to find the position of the ball
which is relatively a good method of feedback for the position of the ball on the plate.
The system has a reaction time of 20 milliseconds to respond to changes on position of
the ball as it is the period of the pulse width modulated signal given to the micro servo
motors used. A physical system has been designed and overshoots are minimal unless the
ball is thrown at a higher velocity on to the plate.
1.1 System Overview
The working of the system starts with capturing the position of the ball by using a web
camera and the frames are sent over to MATLAB. In MATLAB, the captured frames are
processed such that the required area is cropped out of the captured frames. Then the
pixel values above a certain threshold are treated as black and below that as white. So
the processed image is black and white with ball as white and the plate (background)
as black. Now the center of the white circular area is considered the current position
of the ball. The error in position as well as speed is calculated and fed into the fuzzy
controller. The fuzzy controller calculates the required pulse width modulated (PWM)
signal for the motors and send it to the EVK1100 microcontroller board via a USART
interface. The signals to the microcontroller board are decoded and the respective PWM
signals are given to the servo motors which tilt the plate accordingly. The new error in
position is recorded by the web camera and sent it to MATLAB. This process continues
until the ball comes to a halt at the center of the plate.
Figure 1.1: Overview
1.2 Objective
An intelligent system is designed that aims at moving a ball from wherever it is placed
on a plate to the centre. The system includes a ball, a plate, two servo motors, a web
camera and microcontroller board
The ball on plate system is an experimental set-up to control the position of the ball
in 2-dimension.
1.3 Problem Definition
The problem defined here is to balance a moving or static ball from any part of the plate
to it center. The ball should try to become stable at the center of the plate if it is thrown
from different directions at different speeds. One can either throw the ball to the plate
or place it at some point on it. We broke down the system into three main problems:
• Calculating the position of the ball
• Calculating the position of the ball
• Controlling the motors using PWM signals
2
1.4 Organization of Report
The report is organized as follows. Chapter 2 includes the literature survey,chapter 3
discusses the system design,it includes hardware design and Software design and imple-
mentation.
3
Chapter 2
Literature Survey
Different types of ball on plate system have been done before:
1. System 1: At RPI, resistive touch screen ball on plate system using DC gear
motors for the tilting of the plate.At RPI (Renssselaer Polytechnic Institute), they have
developed a ball on plate balancing where they have used initially a horizontal plate which
is tilted along each of two axes in other to control the position of the ball. Each tilting axis
operated by an electric motor. The motor is controlled using software with a minimum
of position feedback for control. The position of the ball on plate is sensed through a
resistive touch screen.1.13
2. System 2: At Monash University Malaysia, CCD camera ball on plate system
and Stepper motors for moving the plate.The balancing ball project has also been done
at School of Engineering, Monash University Malaysia. A PC based system has been
developed. A vision system named CCD camera has been incorporated as the feedback
sensor to acquire the real-time position of the steel ball. Two actuators, namely the
stepper motors are utilized to control the motion of the base plate system. These actuators
are controlled from NI-ELVIS workstation.1.13
3. System 3: At RPI, PID controller and brushed DC motors have been used to
design the balancing ball on plate.Another ball on plate balancing has been designed at
RPI; they have used a spatial linkage mechanism for actuating the plate. They have use
a resistive touch-sensitive glass screen for sensing the ball position. Simple brushed DC
motors have been used to control the encoder feedback to achieve a servo position control.
A PID controller has been used.1.13
4. System 4: LEGO PID controller has been used to develop the balancing ball on
plate by Kenn.The ball on plate balancing has been developed using LEGO by Kenn.
Using a webcam to control the position of the ball on the plate and PID control.1.13
5. System 5: By Daniele, the balancing ball on plate has been developed using
LEGO MINDSTORMS, using a model predictive control of PID for the controller, for the
feedback system, he used NXTcam.1.13
Chapter 3
System Design
3.1 COMPONENTS
• 30cm X 30 cm square plate.
• 2 X 9g servo motors
• Web Camera
• EVK 1100 board
• USB to serial cable
• MATLAB
• AVR32 Studio
3.2 IMPLEMENTTION
The various steps involved in hardware implementation are as follows:
A.Plate and motors
Figure 3.1: Motor
The square plate should be drilled with a hole at the centre and is mounted on
a screw which is attached to the base. The plate should be able to move freely in all
directions.The motors are fixed to the base such that the two motors are perpendicular to
each other. Also the arm of the motor should be directly in line with the plate’s axis.The
joints which connect the arm from motors to the plate are made. These jointsprovide two
degrees of freedom in movement. This is required to avoid rotatory motion of the plate
about the centre when only one motor is moving.The joints are attached to the plate using
glue such that the joints are at the same distance from the plate centre as the motors are
from the centre of screw at the base. The joints should also be on the x and y axes of the
plate.The joints are attached to the arm of the motor using the screw.The movement of
the plate is tested.
B. Setting up the camera
The camera is mounted on the arch using the glue such that the camera is directly
over the centre of the plate. Also the camera should be mounted such that the plate is
not rotated with respect to the camera frame
C. Image Processing Implementation
Figure 3.2: ImageProcessing
This requires getting the image from the camera and extracting the co-ordinates of
the center of the ball from the image. The image acquisition and processing is done in
MATLAB.The image shows a blue square of 400x400 pixels which encloses the plate and
the centre of the square is at the centre of the plate. In the image we can see the ball as
Figure 3.3: ImageProcessing
a white spot.
6
D.Motor Control
Figure 3.4:
The motor is controlled by giving PWM (Pulse width Modulated) signals from the
EVK1100 board. The steps in implementing control for motors are: Step 1: Initialize the
PWM module in AVR32. Step 2: The clock used is 12 MHz clock with a prescaler of 32.
Hence the effective clock rate is 375 kHz. Step 3: The servo motors require a periodic
signal with period of 20ms. Hence the period for the PWM signal is set to 375000 * 20 /
1000 = 7500. Step 4: The motor is controlled by adjusting the pulse width of the signal.
E.Implementation of Fuzzy Controller
The fuzzy controller is implemented using fuzzy toolbox in MATLAB.
Step1: Since the plate is symmetric about x and y axis hence we just need one fuzzy
design. The output values for x and y can be calculated by passing the respective input
values.
Step 2: To stop the ball at the centre of the plate we need to know the position and
speed of the ball.
F.Serial Communication
The PWM values output from the fuzzy controller are sent over serial cable to the
EVK1100 board. The implementation requires sending data from MATLAB and receiving
data in AVR32.
A. MATLAB Implementation
Step1: Initialize the serial port with baud rate = 9600, Data bits = 8. Open the
serial port for communication. Step2: Convert the output values from fuzzy controller
from range -130 to +130 to 0 to 260. Step3: Send a character which has the ASCII value
of the output over the serial port. The x output value is sent followed by the y output
value.
B. AVR32 Implementation
Step 1: Initialize the USART on AVR32 with same parameters as on MATLAB. Step
2: The interrupt is enabled for USART and the interrupt function reads from the USART
whenever the data is there. We receive the output values for x and y alternatively which
is then added to the PWM value for the horizontal plate for respective axes and then sent
to the respective PWM channel for output to motor.
7
Chapter 4
Result
We were able to bring the ball to a halt at the center of the plate. The ball was thrown
from different directions and different speeds and in each case the plate reacted and made
the ball stop at the centre.
Chapter 5
Conclusion and Future work plan
Our hypothesis is that the system would have reacted much better if the plate that we
have used would have been flat. Also in the middle of the plate there was a raised point
from the assembly that kept the plate still, which made the system react in some situation
for longer than what we expected. Other than that the system reacted very well to the
tests and each and every time the ball stopped in the middle of the plate, even if it took it
longer in some situations because of the mechanical assembly inequalities. An interesting
future study would be to use better mechanical parts and try to make the plate tilt even
more so it can react to ‘some higher speeds of the ball.
Sr.No. Task to be completed Expected month of completion
1 Collection of components August 2019
2 Software simulation tool November 2019
3 Collection of required sources December 2019
4 Hardware and testing December 2019
5 Arduino December 2019
6 Hardware and software testing January 2019
7 Project completed February 2019
8 Project improvement March 2019
9 Report Writing April 2019
Bibliography
[1] M. Kashmiri ET. Al. “Modeling and Control of Ball and Beam System Using Model
Based and Non-Model Based Control Approaches”, Journal on Smart Sensing and
intelligent Systems, vol. 5, no. 1, March 2012.
[2] Hao Ying, “Fuzzy Systems Technology: A Brief Overview”
[3] C. C. Lee, “Fuzzy Logic in Control Systems: Fuzzy Logic Controller – Part I”, IEEE
Transactions on Systems, Man and Cybernetics, vol. 20. April 1990
[4] http://www.mathworks.se/
[5] http://www.servocity.com/html/howd os ervosw ork. htmlJuanDomingoEsteve; Robotica−
Apuntesparalaasignatura.ContieneconceptosdeRoboticaM ovil.2001.
[6] F. Torres, J. Pomares, P. Gil, S.T. Puente, R. Aracil - Robots y SistemasSensoriales; Ed.
Prentice-Hall. 2002.
[7] A. Barrientos, L. F. Pe˜nin, C. Balaguer y R. Aracil - Fundamentos deRobotica. (1er
Edicion en Espa˜nol) McGraw-Hill. 2007.
[8] Braunl T.; Embedded Robotics: Mobile Robot Design and Applicationswith Embedded
Systems; Ed. Springer-Verlag. 2006
[9] Ferre M., Buss M., Aracil, R., Melchiorri C., Balaguer C. (Eds.);Advances in Telerobotics;
Series: Springer Tracts in Advanced Robotics.2007.
[10] M.N Cirstea, E. B. Patterson, D. Morley, P. G. Holmes “A complete ASIC controlled
Electric Drive System”, IEEE International Symposium on Circuit and Systems, Vol. 1,
pp. 561-564, 1996.
[11] Rafael R. Ramos, Domingo Biel, Enric Fossas, Francesc Guinjoan “A Fixed-Frequency
Quasi-Sliding Control Algorithm-Application to Design by Means of FPGA Implementa-
tion”, Transactions, Vol. 18, No. 1, pp.344-355, 2003.
[12] Siegwart R., Nourbakhsh I. R.; Introduction to Autonomous MobileRobots (Intelligent
Robotics and Autonomous Agents); Ed. The MITPress. 2004.
[13] Ollero Baturone A.; Robotica: Manipuladores y Robots Moviles; Ed.Alfaomega. 2007
[14] http://www.sappiens.com/castellano/articulos.nsf/0/7a2c33366766724441256b2500500b8f
[15] H. Kopka and P. W. Daly, A Guide to L A T E X , 3rd ed. Harlow, England:Addison-
Wesley, 1999..
10
[16] E. Ali and N. Aphiratsakun, AU Ball on Plate Balancing System,B.Eng. in Computer
Sys. senior project, Assumption Univ., Bangkok,Thailand, 2015
11
Acknowledgments
Date Signature