You are on page 1of 33

Mandalay Technological University

Department of Mechatronic Engineering

Modeling and Control of Ball and Beam System


using Arduino and Matlab

Supervisor Presented by
Dr. Kyaw Thiha Date: 9.4.2018 Aye Su Thwe
Professor VI.BE.McE(2)
9-Apr-18 1
Outlines
• Introduction
• Aim and Objectives

• Components and Software


• Schedule
• Progress
 Transfer Function Calculation
 Sensor Calibration
 Motor Speed Control
 Graphic User Interface (GUI)

• Future Plan
• Conclusion
9-Apr-18 2
Introduction
• Balancing a ball at a desired reference point on a beam using a
controller
• Basic to study the implementation of classical or modern control
theories, such as horizontal and vertical stabilization of aerospace
and airplanes during turbulent flow and landing
• Two degree of freedom system
 Ball rolling along the beam

 Beam rotating through its central axis

• Creating a graphic user interface (GUI) to provide a user-friendly


application
9-Apr-18 3
Ball and Beam System

9-Apr-18 4
Set Point Ball Position
PID Ball & Beam
+_ Controller System

PSD Sensor

Block Diagram for PID Controller

Reference Motor
angle angle
Inner Motor Ball and Beam
+_ Model
Controller Model

Potentiometer

Ball and Beam Sub-system


9-Apr-18 5
Aim and Objectives

Aim
• To model the ball and beam system with a suitable controller (PID
or LQR) to control the ball position

Objectives
• To develop the program with Matlab/Simulink and Arduino for the
control system design
• To understand how the combination of hardware and software
works
9-Apr-18 6
Objectives (Continue…)

• To study how to model ball and beam system to demonstrate one


based on gained knowledge and theories from studied systems
• To learn control methods for ball and beam system
• To compare the theoretical results and the practical experiment
results
• To make the experiment more convenient for users with the use of
graphic user interface (GUI)

9-Apr-18 7
Components and Software

• Components
 Arduino controller

 DC motor with high power gear-box


 Position sensitive detector (PSD) sensor

 Ball and beam mechanism

• Software
 Matlab/Simulink

9-Apr-18 8
PSD sensor – to detect DC motor – to move the beam
the position of the ball for balancing the ball position

Arduino – to act as input/output Ball and Beam mechanism –


interface and controller the experimental setup
9-Apr-18 9
Schedule

To study To Carry Out


and Calculate and Create

Control Graphic User


Methods Interface
Program and
Experiment
Simulink Model
Transfer Motor
Function Parameters
Theories and Sensor
Equations Calibration

Planned Schedule and Deviations


9-Apr-18 10
Progress
Transfer
Sensor Motor Speed Graphic User
Function
Calibration Control Interface
Calculation

Ball and beam Relation of


Input/output
transfer voltage and Simple tutorials
test
function distance

Motor
Calculation of Parameter Communication
transfer
parameters identification with USB port
function

PID tuning
Real time plot
methods

Progress Chart
9-Apr-18 11
Transfer Function Calculation

• Ball and Beam system


– Newtonian method

– Lagrange method

Ball and Beam System Model


9-Apr-18 12
Ball and Beam Transfer Function

• Newtonian method
– Use force and torque equations

– Two forces acting on the ball: translational and rotational

Force equation: F = ma
Torque equation: = FR = J ä

X ( s) mgd
=

( )
θ( s) Jb 2
L m+ 2 s
R

Newtonian Model

9-Apr-18 13
• Lagrange method
– Use kinetic energy and potential energy equation

Kinetic energy: K= +
Potential energy: U = mgh
Lagrange equation: L = K – U

X (s) mgd 1
=−

( ) s2
θ(s) Jb
Lagrange Model L 2 +m
R

The same result as Newtonian model, except the negative sign

Take transfer function from Newtonian method as final result


9-Apr-18 14
Motor Transfer Function

di(t)
V a ( t )=i ( t ) R a+ La +V b ( t )
dt

Armature-controlled motor circuit

θ (s ) Km
=
V a ( s) s ( Js+ b ) ( R a + L a s ) + K m K b s
9-Apr-18 15
Sensor Calibration

PSD Sensor’s Pins and Wire Connection Experimental Setup

9-Apr-18 16
Sensor Calibration

• Distances from 6 cm to 36 cm is measured


• Using Matlab program, each centimeter is measured for 500 times

• The output voltages are recorded


• Repeat three times and the best result is shown
Distance(cm) Voltage(V) Distance(cm) Voltage(V) Distance(cm) Voltage(V)
6 2.796237 13 1.524555 24 0.764321
7 2.469785 14 1.427527 26 0.703548
8 2.325484 15 1.311544 28 0.647331
9 2.104731 16 1.196031 30 0.647996
10 1.932825 18 1.071134 32 0.519726
11 1.778641 20 0.962923 34 0.481398
12 1.639570 22 0.857253 36 0.405308

Recorded Data for Sensor Calibration


9-Apr-18 17
Sensor Calibration

The equation between voltage


and distance is:

y = distance (cm)
x = output voltage (volt)

Plot for Output Voltage Vs Distance

The results are non-linear as shown

This is because of noises, deviation in IR radiation and sensor reading,

orientation of the sensor, or human errors

9-Apr-18
Voltage-distance relationship is derived from that nature 18
Sensor Calibration

Data Values and Fitting Curve

The data values have only a little deviation from the fitting curve

Parameters a, b, and c are calculated by least square method

a = 31.847812 b = 0.357408 c = -4.017942


9-Apr-18 19
Motor Speed Control

• DC motors x 2
• Potentiometer
• FET 2SK2231
• 4.5V supply
• Arduino board

• 1N4001 x 2
• 0.1µF x 2
• 100kΩ & 1.5k Ω

Components and Experimental Setup

9-Apr-18 20
Input/Output Test

• Test by a potentiometer (as input)


• By Matlab/Simulink
• Output result from scope
 Output value less than input
 Output lags input
 Output requires certain voltage to starts

Input and Output Result

Simulink Block Diagram


9-Apr-18 21
Prameter Identification

• Identification steps
 Gain K and offset

 Gain K, offset and Time constant T

 Verification process V t ( s) y (s ) K
= =
V a ( s) u (s ) Ts+1
• By step response method

( )
t
• Matlab/Simulink and .m file y ( t )= K 1 −e

T

At
At

9-Apr-18 22
Identification for Gain K

Simulink Block Diagram

K = 0.583650
u_offset = 1.254492
Fitting Line for the Result

Most of the data values fit with the fitting line

The gain K is obtained from this plot

9-Apr-18 23
Identification for Gain K and Time Constant T

K = 0.566671
T = 0.8
u_offset = 1.362502

Output Response and Time Constant Calculation

Time constant T obtained

K and u_offset nearly equal to the results

from first identification


Take this values as final result
Simulink Block Diagram
9-Apr-18 24
Verification Process for K and T
• Taking results from experiment 2
• Compare target value and output
response
 Output is not identical with target value
 Deviation due to some errors in K,T, and
u_offset or some imprecision in
experiment
Output Response and Target Value from Scope
 Acceptable results

Motor parameters:
K = 0.566671
T = 0.8
u_offset = 1.362502
9-Apr-18 Simulink Block Diagram 25
PID Tuning Methods
 Manual tuning
 Limit sensitivity method
 Pole assignment method
Manual Tuning
𝑡
𝑢 ( 𝑡 )= 𝐾 𝑃 𝑒 ( 𝑡 ) + 𝐾 𝐼∫ 𝑒 ( 𝜏 ) 𝑑 𝜏
0

Proportional gain:
Integral gain:

 Only little deviation exists


 No overshoot
 Zero steady-state error
Output Response by Manual Tuning  The output response best fit with the
9-Apr-18 target value 26
Limit Sensitivity Method

Oscillatory System Response Output Response by Limit Sensitivity Method

𝐾 𝑃 =0.45 𝐾 𝐶 Proportional gain:


1.2 𝐾 𝐶
𝐾 𝐼=
𝑇𝐶

 and taken from oscillatory system response


 Overshoot and vibration greater than manual tuning method
 Steady-state error approximately zero
9-Apr-18 27
Pole Assignment Method

( 𝑝 1+ 𝑝2 ) 𝑇 +1
𝐾 𝑃 =−
𝐾

𝑝1 𝑝2 𝑇
𝐾 𝐼=
𝐾

Multiple poles at:


Proportional gain:

Output Response by Pole Assignment Method

 Gains calculated by assigning arbitrary poles


 Test multiple real poles: -2, -4, -8
 Best results obtained at -4
 Overshoot only exists at start

9-Apr-18  Zero steady-state error 28


Graphic User Interface (GUI)
• To provide more convenient interaction with the user

Simple Tutorials
9-Apr-18 29
Graphic User Interface (GUI)

USB Communication and Real Time Plot from Potentiometer and PSD Sensor
9-Apr-18 30
Future Plan
• Motor position control
 Parameter identification for motor used

 Angle detection unit

 Control methods
 Link with ball and beam system

• GUI animation
 Ball and beam graphic

 More plots of the system

 Input from GUI

 More options

9-Apr-18 31
Conclusion
• Transfer functions and sensor parameters, needed to use in ball and
beam system, has been calculated
• Speed control system, basic to learn about position control, has been
studied
• Among three PID tuning methods, manual tuning method yields the
best results but it needs more steps and adjustment
• Gains directly obtained by pole assignment method (no adjustment
needed)
• More control methods are to be studied
9-Apr-18 32
THANK YOU!

9-Apr-18 33

You might also like