Professional Documents
Culture Documents
TECHNOLOGY
DEPARTMENT OF ELECTRICAL ENGINEERING
Course: Project Report Practical 2
PROJECT REPORT:
BALANCING BALL
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Table of Contents
Page no.
1.1 Introduction.........................................................................................6
1.2 Problem statement..............................................................................7
1.3 User requirement specification...........................................................7
1.4 Budget................................................................................................7
1.5 Literature review.................................................................................8
1.5.1 Feedback systems........................................................................8
1.5.2 Mechanical design of a ball-on-plate balancing system...............8
1. Mechanical actuators..........................................................................9
2. Hydraulic actuators...........................................................................10
3. Pneumatic actuators.........................................................................10
1.5.3 Control electronics......................................................................10
1.5.4 RC Servo Motors.........................................................................12
1.5.5 Software algorithms....................................................................14
1.6 Proposed practical design or strategy...............................................15
1.7 Design of product..............................................................................17
1.7.1 Software Flow Diagram and description.....................................17
1.7.2 Circuit Diagram and description.................................................18
1.7.3 PCB Layout.................................................................................20
1.7.4 Software Code and Comments...................................................21
1.8 Implementation of product...............................................................26
1.9 Testing procedure..............................................................................26
1.10 Necessary changes encountered.......................................................27
1.11 Results of the tested product / procedure..........................................27
1.12
Comparison of results vs. requirements........................................27
1.10 conclusions and recommendations...................................................27
Appendix.......................................................................................................28
1.11 A.1 Final Gantt chart.........................................................................28
1.12 A.3 Detail designs.............................................................................30
1.13 A.4 Software......................................................................................31
1.14 Bill of Materials.................................................................................36
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Table of Figures
Page
no.
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
Figure
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
List of Tables
Page no.
Table 1-1 Most important component cost......................................................7
etc.
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Abstract
This report is to describe the design and development strategy to accomplish a control
system to balance a ball on a plate. We will have two modes of operation in the system; one
mode of operation is the Joystick control used to control manually the X-Y axis and the other
mode is the Autonomous mode where we will use the IR beam to control the X-Y axis.
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
1.1
Introduction
The goal of this project is to develop a ball-on-plate balancing system, capable of controlling
the position of a ball on a plate for both X and Y positions without the risk of the ball falling off.
Each tilting axis will be operated on by an RC servo electric motor. Each motor will be
controlled using software, with a minimum of position feedback for control. The control of the X
and Y positions should be with a joystick or automatic using IR beam control.
Various modes of operations have been used:
1. System 1: 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.
2. System 2: 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.
3. System 3: 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 touchsensitive 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.
4. System 4: 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.
5. System 5: At Miskabir University of Technology a fuzzy logic controller has been
developed; they have used a resistance sensor for controlling the position of the ball.
6. System 6: 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.
The aim of this project will be to create a ball-plate system using a joystick control and
autonomous control platform to allow the X and Y-axis of movement of a ball by means of RC
servo motors.
1.2
Problem statement
6
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
The Goal of the balancing ball system will be first to create a system
that can hold a ball in a certain defined position. From there, the goal will
then be able to move the ball on the platform in varying specific position.
1.3
1.4
Budget
The budget cost will be determine according to the 40X40 IR led, the RC
servo motor and the joystick input control.
Refer to appendix A.5 for a detail layout of the budget.
Table 1-1 Most important component cost
Components
Cost [R]
3, 45 per 10 = R27, 6
2 X RC servo motor
R100
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
1.5
Literature review
Different types of ball on plate system have been done before:
1.
2.
3.
4.
5.
System 1: At RPI, resistive touch screen ball on plate system using DC gear motors for
the tilting of the plate.
System 2: At Monash University Malaysia, CCD camera ball on plate system and
Stepper motors for moving the plate.
System 3: At RPI, PID controller and brushed DC motors have been used to design the
balancing ball on plate.
System 4: LEGO PID controller has been used to develop the balancing ball on plate by
Kenn.
System 5: Fuzzy logic controller ball on plate at Miskabir University of Technology.
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
3. System 3:
The physical system consists of an acrylic plate, an actuation mechanism for tilting the plate
about two axes. Each motor drives one axis of the plate rotation angle and is connected to the
plate by a spatial linkage mechanism. Each side of the spatial linkage mechanism is a four-bar
parallelogram linkage. See Figure 2 1.
1. Mechanical actuators
Mechanical linear actuators operate by conversion of rotary motion into linear motion.
Mechanical actuators typically convert rotary motion of a control knob or handle into linear
displacement via screws and/or gears to which the knob or handle is attached.
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
2. Hydraulic actuators
Hydraulic actuators or hydraulic cylinders typically involve a hollow cylinder having a
piston inserted in it. The two sides of the piston are alternately pressurized/de-pressurized to
achieve controlled precise linear displacement of the piston and in turn the entity connected to
the piston. The physical linear displacement is only along the axis of the piston/cylinder. This
design is based on the principles of hydraulics. A familiar example of a manually operated
hydraulic actuator is a hydraulic car jack. Typically though, the term "hydraulic actuator" refers
to a device controlled by a hydraulic pump.
3. Pneumatic actuators
Pneumatic actuators, or pneumatic cylinders, are similar to hydraulic actuators except they
use compressed gas to provide pressure instead of a liquid.
4. Electro-mechanical actuators
Electro-mechanical actuators are similar to mechanical actuators except that the control knob
or handle is replaced with an electric motor. Rotary motion of the motor is converted to linear
displacement of the actuator.
A rotary driver (e.g. electric motor) is mechanically connected to a lead screw so that the
rotation of the electric motor will make the lead screw rotate. A lead screw has a continuous
helical thread machined on its circumference running along the length (similar to the thread on a
bolt). Threaded onto the lead screw is a lead nut or ball nut with corresponding helical threads.
10
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
A.
DC MOTORS
A DC motor is designed to run on DC electric power. The most common DC motor types are
the brushed and brushless types, which use internal and external commutation respectively to
periodically reverse the current in the rotor windings. There are two types:
Brushed DC motors: A brushed DC motor is an internally commutated electric motor
designed to be run from a DC power source.
When the coil is powered, a magnetic field is generated around the armature. The left side
of the armature is pushed away from the left magnet and drawn toward the right, causing
rotation.
Brushless DC motors: BLDC motors also known as electronically commutated motors
(ECMS, EC motors) are synchronous electric motors powered by direct current(DC)
electricity and having electronic commutation systems, rather than mechanical
commutations and brushes.
B.
AC MOTORS
An AC motor is an electric motor driven by an alternating current. There two types named:
Induction motor: runs slightly slower or faster than the supply frequency. The magnetic
field on the rotor of this motor is created by an induced current.
Synchronous motor: does not rely on induction and as a result, can rotate exactly at the
supply frequency or a sub-multiple of the supply frequency. The magnetic field on the
rotor is either generated by current delivered through slip rings or by a permanent
magnet.
C.
STEPPER MOTORS
A stepper motor (or step motor) is a brushless, synchronous electric motor that can divide a
full rotation into a large number of steps. The motor's position can be controlled precisely
without any feedback mechanism, as long as the motor is carefully sized to the application.
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Stepper motors operate differently from DC brush motors, which rotate when voltage is
applied to their terminals.
Stepper motors have multiple "toothed" electromagnets arranged around a central gearshaped piece of iron. The electromagnets are energized by an external control circuit, such as a
microcontroller. To make the motor shaft turn, first one electromagnet is given power, which
makes the gear's teeth magnetically attracted to the electromagnet's teeth. When the gear's teeth
are thus aligned to the first electromagnet, they are slightly offset from the next electromagnet.
When the next electromagnet is turned on and the first is turned off, the gear rotates slightly to
align with the next one, and from there the process is repeated. Each of those slight rotations is
called a "step", with an integer number of steps making a full rotation. In that way, the motor can
be turned by a precise angle.
D.
SERVO MOTORS
Figure 2 6:
12
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Figure 2 7:
Figure 2 8:
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
They do not simply run on a DC voltage like a standard DC motor. They have 3 wires.
Red is power (generally 3V 12V max), black is ground and then there is another wire, usually
white or yellow that is the input signal wire.
The RC servo motor is the best one because of his property to position its output into a
position that exactly corresponds with the movement of the corresponding stick.
14
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
1.6
Two Joysticks
for X-Y axis
control
CONTROLLER
Servos control
IR beam control
Figure 2 10:
15
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
c) The Controller
This is the brain of the whole system. It reads the two inputs. Its convert the two inputs to
the two outputs. The two outputs are the servos. These servos checked the pulse that has been
send and also the beam that have been broken. If the beam that has been broken is greater than
20, the pulse should tell the system to turn fully clockwise and if the beam is less than 20, it
should go clockwise opposite direction. In case the beam is near the middle, close to the middle
nothing should happen the ball should remain in the middle of the plate.
I will be using the PIC16F684 see Figure 2 12:
Label
Description
+5V
Ground
External Voltage Reference
PORTA/PORTC Programmable I/O
A/D Channel
External Interrupt Input
PWM Output
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
duty cycle, the motor will move in a forward motion, where 2 milliseconds will be the full speed.
To generate these signals, the PWM module of the PIC is used. The ability to create an 20
millisecond pulse depends on the selected frequency of the oscillator, and the settings of the
timer modules of the microcontroller. For this reason a slow frequency of 500 KHz are used to
drive the PIC.
1.7 Design of product
Set I/O
50% Duty Cycle
(Set Panel Flat)
Test Switch?
Joystick
mode
Autonomous
mode
Read
Analogue
Voltage
2,
3>
Change
Duty Cycle
Figure 2 13:
>2,
7
Change
Duty Cycle
Set Panel
Flat
End
Read
Voltage
Analogue
2,
Change
Duty Cycle
>2,
7
Change
Duty
Cycle
17
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Figure 2 15: Circuit diagram of RC Servo motor, Power Supply and ICSP
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
R1,R2, Resistor
Connector 1, Power Supply
Connector 2, ICSP
Connector 3, Inputs
SW5, Switch
40 x Led
R1, R2, R3, R4, R5, R6, R7, R8, Resistor 180Ohms
Connector, Power Supply
19
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
20
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
ADCON1=0b01110000;
//FRC: Clock derived from a dedicated internal
oscillator=500KHz max
ADCON0=0b00001101;
//Left
justified,
voltage
reference=VDD,
AN3=Analog Input, Initiate ADC and wait for start conversion
__delay_us(10);
//wait 10us for acquisition time
GODONE=1;
while(GODONE);
adc_result_y=(ADRESH);
return adc_result_y;
}
/********************************DELAY*************************************/
void delay()
{
unsigned int j;
for(j=0; j<100;j++)
{
__delay_us(20);
}
}
/
***********************************SWITCH**********************************/
unsigned char IS_SW5_PRESSED()
{
if(RA5==1)
//Is SW pressed?
{
//YES
__delay_ms(10);
//Wait 10ms for debounce
return 0;
//if not pressed
}
else
{
return 1;
}
}
/**************************MAIN FUNCTION*********************************/
void main()
{
OSCCON=0b00110101;
initialize();
CCP1CON=0b00001100;
//Single Output
CCPR1L=13;
while(1)
{
if(IS_SW5_PRESSED()==1)
{
count++;
}
if(count==1)
{
adc_x=ADC_x_READ();
if(adc_x>138)
22
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
}
else if(adc_x<120)
{
if(CCPR1L > 0)
{
CCPR1L --;
}
__delay_ms(100);
}
else
{
CCPR1L=13;
__delay_ms(100);
}
}
if(count==2)
{
count=1;
}
}
}
23
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
1.8
Implementation of product
Testing procedure
24
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
SERVO 2
25
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
ADC1
PWM 1
CENTER POSITION
LEFT POSITION
RIGHT POSITION
ADC2
IR 1
IR 2
1.12
PWM 2
PWM 1
CENTER POSITION
LEFT POSITION
RIGHT POSITION
CENTER POSITION
LEFT POSITION
RIGHT POSITION
PWM 2
CENTER
POSITION
LEFT POSITION
RIGHT POSITION
26
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Appendix
1.11
A.1
27
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Literature Review
1.
http://www.cats.rpi.edu/~wenj/ECSE4962S04/final/team2finalreport.pdf,
(11Ja)
2.http://digital.ni.com/worldwide/singapore.nsf/web/all/A0420E70B017638F8625724
9002EC41E, (11Ja)
3.http://www.das.ufsc.br/~camponog/Disciplinas/DAS-5341/Interesting_articles/ballplate.pdf, (11Fe)
4. http://eissq.com/BallandPlate/index.html#Introduction , (11Fe)
5.http://oru.academia.edu/NimaMohajerin/Papers/375716/Position_Control_of_Ball_a
nd_Plate_System_Using_Fuzzy_Logic_Controller, (11Fe)
28
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
1.12
A.3
Detail designs
Joystick
29
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
1.13
A.4
Software
include<htc.h>
__CONFIG(INTIO & UNPROTECT & MCLRDIS & PWRTEN & WDTDIS & BORDIS);
#define _XTAL_FREQ
500000
//oscillator
frequency for __delay_ms
unsigned char adc_result_x, adc_result_y;
unsigned char adc_x, adc_y;
unsigned char count=0;
/***************************INITIALIZATION******************************/
void initialize()
{
//1=Input 0=Output
CMCON0=7;
//Disable comparators
PORTA=0b00000000;
//Clear port A
TRISA=0b00110100;
//RA4 RA2 RA5 INPUTs
PORTC=0b00000000;
//Clear port B
TRISC=0b00001111;
//RC5 OUTPUT
ANSEL=0b00001100;
//AN3 analog input
PR2=155;
PIR1=0;
//Peripheral Interrupt request register 1
T2CON=0b00000111;
//prescaler 1:16, postscaler 1:1, Timer2 On
TMR2=0;
//Start with zero counter
}
/******************************ADC X****************************************/
unsigned char ADC_x_READ()
{
ADCON1=0b01110000;
//FRC: Clock derived from a dedicated internal
oscillator=500KHz max
ADCON0=0b00001001;
//Left
justified,
voltage
reference=VDD,
AN2=Analog Input, Initiate ADC and wait for start conversion
__delay_us(10);
//wait 10us for acquisition time
GODONE=1;
while(GODONE);
adc_result_x=(ADRESH);
return adc_result_x;
}
/******************************ADC Y****************************************/
unsigned char ADC_y_READ()
{
ADCON1=0b01110000;
//FRC: Clock derived from a dedicated internal
oscillator=500KHz max
ADCON0=0b00001101;
//Left
justified,
voltage
reference=VDD,
AN3=Analog Input, Initiate ADC and wait for start conversion
__delay_us(10);
//wait 10us for acquisition time
GODONE=1;
while(GODONE);
adc_result_y=(ADRESH);
return adc_result_y;
}
30
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
/********************************DELAY*************************************/
void delay()
{
unsigned int j;
for(j=0; j<100;j++)
{
__delay_us(20);
}
}
/
***********************************SWITCH**********************************/
unsigned char IS_SW5_PRESSED()
{
if(RA5==1)
//Is SW pressed?
{
//YES
__delay_ms(10);
//Wait 10ms for debounce
return 0;
//if not pressed
}
else
{
return 1;
}
}
/**************************MAIN FUNCTION*********************************/
void main()
{
OSCCON=0b00110101;
initialize();
CCP1CON=0b00001100;
//Single Output
CCPR1L=13;
while(1)
{
if(IS_SW5_PRESSED()==1)
{
count++;
}
if(count==1)
{
adc_x=ADC_x_READ();
if(adc_x>138)
{
if(CCPR1L < 25)
{
CCPR1L ++;
}
__delay_ms(100);
}
else if(adc_x<120)
{
if(CCPR1L > 0)
{
31
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
CCPR1L --;
}
__delay_ms(100);
}
else
{
CCPR1L=13;
__delay_ms(100);
}
}
if(count==2)
{
count=1;
}
}
32
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
}A.5 Datasheets
PHOTOS
SERVOS
Larger-Standard size digital servo with large torque and featuring strong metal gears.
Ideal for wheel steering on a Crawler, 1/8th Scale Buggy and 50 size airplane
Features
Production and quality control of plastic component in our servos follow the standard of branded
digital camera
33
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
Totally Green from material to production, our servos are environmentally friendly.
Spec Check
Weight: 61g
Gear: Metal
Case: Plastic
IR LED
PHOTOTRANSISTOR (Receivers)
34
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
1.14
Bill of Materials
:
:
:
:
:
:
Circuit Complet.DSN
<NONE>
<NONE>
15 March 2011
20 June 2011
9
2 Modules
Quantity:
2
References
M1, M2
Value
TBLOCK-I3
Order Code
References
R1, R2
Value
10k
Order Code
Value
PIC16F684
Order Code
Value
Connector 2
TBLOCK-I4
Connector 1
SPDT - SW
Order Code
2 Resistors
Quantity:
2
1 Integrated Circuits
Quantity:
1
References
U1
4 Miscellaneous
Quantity:
1
1
1
1
References
ICSP
OUTPUTS
POWER SUPPLY
SW5
35
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
:
:
:
:
:
:
8 Resistors
Quantity:
8
References
R1-R8
Value
180
Order Code
References
D1-D4
D5-D40
Value
MV2108
LED
Order Code
Value
Connector
Order Code
40 Diodes
Quantity:
4
36
1 Miscellaneous
Quantity:
1
References
POWER SUPPLY
36
Template for Project Report by A.J. Visser, 2008, Updated by J. De Vries 2011
:
:
:
:
:
:
82 Resistors
Quantity: References
42
R1, R3, R5, R7, R9, R11, R13,
R15, R17, R19, R21, R23,
R25, R27, R29, R31, R33,
R35, R37, R39, R41, R43,
R45, R47, R49, R51, R53,
R55, R57, R59, R61, R63,
R65, R67, R69, R71, R73,
R75, R77, R79, R81, R82
40
R2, R4, R6, R8, R10, R12,
R14, R16, R18, R20, R22,
R24, R26, R28, R30, R32,
R34, R36, R38, R40, R42,
R44, R46, R48, R50, R52,
R54, R56, R58, R60, R62,
R64, R66, R68, R70, R72,
R74, R76, R78, R80
Value
1k
Order Code
100
40 Transistors
Quantity: References
40
Q1-Q40
Value
2N3390
Order Code
1 Miscellaneous
Quantity: References
1
POWER SUPPLY
Value
Order Code
Connector 1
24 June 2011 12:38:32 AM
37