23
0 Position Control of a Ping-Pong Ball Position Control of a Ping-Pong Ball Within a Glass Tube Using a P.I.D. Control System James Goddings St. No.3131147 11/22/2015 Project Supervisor: Shyamal Mondal Dynamics and System Modelling (ENG_6_451)

Position Control of PP ball

Embed Size (px)

Citation preview

Page 1: Position Control of PP ball

0

Position Control of a Ping-Pong Ball

Position Control of a Ping-Pong Ball Within a Glass Tube Using a P.I.D. Control System

James Goddings St. No.3131147

11/22/2015

Project Supervisor: Shyamal Mondal

Dynamics and System Modelling (ENG_6_451)

Page 2: Position Control of PP ball

Table of Contents Aim........................................................................................................................................................ 1

Apparatus ............................................................................................................................................. 1

Hardware .......................................................................................................................................... 1

Software ........................................................................................................................................... 4

PID Controller Theory ........................................................................................................................... 4

Proportional Controller ..................................................................................................................... 4

Differential Controller ....................................................................................................................... 5

Integral Controller............................................................................................................................. 6

Experimental Procedure ....................................................................................................................... 7

Open Loop System ............................................................................................................................ 7

Open Loop Results ........................................................................................................................ 7

Closed Loop System .......................................................................................................................... 7

Proportional Control ......................................................................................................................... 8

Proportional Gain Results ........................................................................................................... 10

Integral Control ............................................................................................................................... 11

Integral Gain Results ................................................................................................................... 13

Differential Control ......................................................................................................................... 14

Integral Gain Results ................................................................................................................... 15

Changing Demand Position ............................................................................................................. 15

Changing Demand Position Results ............................................................................................. 17

Calibration of Ultrasonic Range Finder Scale .................................................................................. 18

Conclusion .......................................................................................................................................... 20

References ............................................................................................................................................ 1

Page 3: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

1

Aim

The aim of this investigation was to achieve stable position control of a Ping-Pong ball using A PID controlled DC fan adjusting airflow through a glass tube.

This investigation will achieve the objective of familiarising the operator with the following:

PID control systems

Matlab Simulink Models and Real Time Windows Target

Use of Feedback and Feed-Forward Control

Use of the Sensoray 626 Interface Card

Use of the FR04 Ultrasonic Range Finder

Apparatus

Hardware

Figure 1.1 Ping-Pong ball in a glass tube apparatus

Page 4: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

2

Figure 1.2 Close-up of base of glass tube showing fan impeller assembly, vent and motor

controller.

The hardware consists of:

A Ping-Pong ball constrained vertically within a close fitting glass tube, with a fan at the base and a position sensor at the top; as shown in Figure 1.1.

The fan is a Mini 9V DC model with an impeller mounted on a common shaft above it, drawing air in a side vent and propelling it upward through the glass tube.

The position sensor is an FR04 ultrasonic range finder that consists of 2 elements, a transmitter and a receiver. Activated by a 50 ms period pulse from one of the counters on a Sensoray 626 interface card, the transmitter emits a 20μs ultrasonic pulse which travels at the speed of sound down the tube, rebounds off the ball, and returns at the speed of sound to the receiver.

Simultaneous to the ultrasonic pulse, an electrical signal in the form of a 40 kHz series of pulses is output back to the Sensoray 626 interface card. When the ultrasonic echo is received by the receiver the electrical output pulses are stopped, therefore the time it takes for the ultrasonic pulse to return (time of flight) can be measured by counting the number of electrical pulses received by the Sensoray 626 interface card. (See Figure 1.3)

Page 5: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

3

Figure 1.3 Graphical representation of the ultrasonic range finder signal input and output

traces.

“The Sensoray model 626 is a Multifunction Input/Output Interface card.

Some of the features include:

• 48 digital I/O channels.

• 20 of the digital I/O channels have edge detection and interrupt

capability.

• 7 of the digital Outputs can be used as counter overflow outputs.

• Digital I/O connectors are industry standard pinouts.

• Watchdog timer with several selectable reset periods that can reset the

PCI bus.

• Six 24 bit up/down counters arranged in 3 pairs with:

• Inputs that can be driven in various modes (1x, 2x, 4x) from

incremental encoders inputs, the digital inputs, the paired counter’s

overflow, the system clock or software driven.

• Can generate an interrupt on counter overflow or encoder/digital input

index.

• Can be preloaded/cleared on an overflow.

• Output of second counter can be captured on the overflow of the first.

• Can be used as a programmable periodic interrupt generator.

• Counter circuitry can be battery backed up to prevent count loss during

a power failure.

• Charge control of the backup Ni-Cad battery.

Page 6: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

4

• 16 differential analog inputs (14 bit resolution).

• 4 analog outputs (13 bit resolution) with remote sense inputs to

compensate for any external output resistance.”(Sensoray, 2004)

The Sensoray 626 interface card acts as a conduit between the hardware system and the Matlab Simulink software, facilitating the control of the hardware system through models created in Simulink by the operator. A single digital input on the interface card is used to count the 40 kHz electrical pulse output from the ultrasonic sensor, this is converted to a voltage output by one of the interface card’s digital to analogue converters and relayed to the Simulink model as a voltage.

The Simulink model interprets the voltage from the interface card as a position using predetermined range information and returns an output voltage to one of the interface cards analogue inputs, this is digitised through an analogue to digital converter and converted back through a digital to analogue converter to a 0-10V DC output to the motor.

Software

Matlab is a long running mathematical software package originally designed with the intention of facilitating the processing of matrix calculations. Over its 30year history it has been developed into a very powerful software package capable performing complex mathematical calculations and of modelling and simulating complex systems. Simulink is a powerful plug-in tool developed as part of Matlab to enable graphical modelling of electronic hardware and process controllers within the Matlab environment, with the capability of simulating these models and components and outputting signals to an interface in real time using the Real Time Windows Target.

PID Controller Theory

The PID controller is a tuning controller that is very useful as it does not rely on the operator

having prior knowledge of the underlying mathematical model of the system being

controlled. In effect it combines 3 separate controllers that each implements different

mathematical operators on the system in the form of variable gains.

Proportional Controller

The proportional controller’s purpose is to increase the speed of a system’s response and

reduce the steady state error of the system response. The output of the system is measured

and fed back to the input of the system where the error between the output and the

demanded input value is multiplied by a gain proportional to the error.

Page 7: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

5

Figure 1.4 Block diagram of a proportional controller applied to a plant system. (Satar, 2013)

𝐸𝑞𝑛. 1.1 𝑓(𝑡) = 𝐾𝑝(𝑥𝑑(𝑡) − 𝑥(𝑡)) = 𝐾𝑝𝑒(𝑡)

There are downsides to proportional control; it reduces the damping’s effect of the overall

system, resulting in the system becoming less stable. At a point called the critical gain, the

proportional gain overcomes the damping of the system, moving the system poles to the

right hand side of the imaginary axis of the s-plane, causing the system to become unstable.

Proportional gain can also cause overshoot of the demand input, as a rule of thumb, an

overshoot of up to 25% is tolerated in return for the increased system response rate.

In the case of this investigation the proportional gain will act as a proportional multiplier to

the error in the Ping-Pong ball’s displacement from the demanded position.

Differential Controller

The differential controller’s purpose is to increase system response stability; this is achieved

by adding another feedback loop affecting the derivative (rate of change) of the primary

control variable. This increases damping, moving the system poles away to the left from the

imaginary axis of the s-plane, thereby increasing stability, and is often used in conjunction

with proportional control to alleviate the instability introduced by proportional gain.

Figure 1.5 Block diagram of a differential controller in conjunction with a

proportional controller applied to a plant system. (Satar, 2013)

𝐸𝑞𝑛. 1.2 𝑓(𝑡) = 𝐾𝑝(𝑥𝑑(𝑡) − 𝑥(𝑡)) − 𝐾𝑑�̇�(𝑡)

Kp Plant

System +

-

χd(t) χ(t)

Kp Plant

System -

χd(t)

χ(t)

+ -

+

dχ(t) dt

Kd

e(t) f(t)

e(t) f(t)

Page 8: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

6

In the case of this investigation the differential gain will act as a multiplier to the error in the

Ping-Pong ball’s velocity from the demanded velocity (zero for a fixed position), again too

much gain will overwhelm the system’s response to the demand input becoming the

overriding influence, causing instability.

Integral Controller

The integral controller’s purpose is to decrease the steady state error of the system

response to zero. This is achieved by integrating the error in the primary control variable

between the output and demand and feeding this forward as a ramp up of the control

signal. This is often used in conjunction with proportional control and differential control to

reduce any steady state error to zero. Integral control increases the type number of the

closed loop system by one, making the model more complex.

Figure 1.6 Block diagram of an integral controller in conjunction with a

differential controller and a proportional controller applied to a plant system.

(Satar, 2013)

𝐸𝑞𝑛. 1.3 𝑓(𝑡) = 𝐾𝑝(𝑥𝑑(𝑡) − 𝑥(𝑡)) + 𝐾𝑖 ∫(𝑥𝑑(𝑡) − 𝑥(𝑡)) 𝑑𝑡 − 𝐾𝑑�̇�(𝑡)

In the case of this investigation the integral gain will act as a multiplier to the error in the

Ping-Pong ball’s displacement from the demanded position. Integral gain is very effective at

reducing steady state error when a system has a stable or slow changing system response,

however with a dynamic rapidly changing system response the integrator can “wind up”

causing instability.

Kp Plant

System -

χd(t)

χ(t)

+ -

+

dχ(t) dt

Kd

+

e(t) f(t)

Ki ∫dt

Page 9: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

7

Experimental Procedure

Open Loop System

The first part of the investigation is a simple test to familiarise the operator with the

procedures of building and operating Matlab Simulink models and compiling them for

export to the Real Time Windows Target environment for use with the Sensoray 626

Interface Card, the FR04 Ultrasonic Range Finder and the Ping-Pong ball in a glass tube/fan

arrangement.

An existing open loop Simulink model is opened in Matlab which enables a voltage gain

value to be applied to the fan controller and the resulting Ping-Pong ball position to be

displayed in the form of a value with an arbitrary scale. This value is an output from the

ultrasonic range finder that had been linearised by the Sensoray 626 interface card to have

a range between 0-10V to correspond with the 0-10V scale of the output voltage to the fan.

(The Ping-Pong balls resting position at the bottom of the tube corresponds to a value of

1.3V)

Open Loop Results

This resulted in Table 1.1 providing knowledge of voltages required to initiate the Ping-Pong

ball climbing the glass tube, hovering stationary and falling in a controlled manner.

Fan Voltage [V] P-P Ball Observation

6.1 Started to vibrate

6.85 Started to spin

7.57 Started to lift off

7.65 Upward movement

7.5 Controlled downward

movement

7.55 Hovers stationary

Table 1.1 Observed Voltages required for initiating movement of the Ping-Pong ball

Closed Loop System

The second part of the investigation involves designing and implementing a Matlab Simulink

PID control model to control the position of the Ping-Pong ball in the glass tube. This is done

in a methodical manner introducing proportional control, then integral control, then

differential control to establish and optimise control of the ball’s position.

When sufficient control is established, the arbitrary scale resulting from the output signal

from the ultrasonic range finder is calibrated against the measuring tape to the right of the

glass tube.

Figure 1.7 Shows the Simulink model used to apply PID control to the Ping-Pong ball in a

glass tube system through the interface card.

Page 10: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

8

Figure 1.7 Closed Loop Matlab Simulink model with PID block.

Proportional Control

For the PID investigation, an initial demand position of 8 on the arbitrary range finder scale

is selected. The proportional controller gain is then increased in steps to determine its effect

on the control of the Ping-Pong balls position and the ability of the control system to track

the demand position.

For all of the charts following:

Yellow Line = Demand Position

Cyan Line = Ping –Pong Ball’s Position

Magenta Line = Fan Controller Voltage

Page 11: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

9

Chart 1.1 Demand Position = 8, Proportional Gain = 1.0, Steady State Position = 1.5, Steady

State Output Voltage = 6.7V

Chart 1.2 Demand Position = 8, Proportional Gain = 2.0, Steady State Position =

4.1(Oscillating 1.2), Steady State Output Voltage = 7.7V (Oscillating 2.2V)

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Page 12: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

10

Chart 1.3 Demand Position = 8, Proportional Gain = 4.0, Steady State Position =

5.8(Oscillating 2.4), Steady State Output Voltage = 9.8V (Oscillating 6V)

Proportional Gain Results

Charts 1.1-1.3 show that increasing the proportional gain increased the speed of the system

response and decreased the error in the steady state response, however it also decreased

stability of the system and introduced oscillations at values above 1.5. A proportional gain of

1.2 was chosen to continue the investigation as it maintained stability whilst offering an

increase in the speed of the system response and reduction the error of the steady state

response.

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Page 13: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

11

Integral Control

Chart 2.1 Demand Position = 8, Proportional Gain = 1.2 Integral Gain = 0, Steady State

Position = 1.9, Steady State Output Voltage = 7.7V

Chart 2.2 Demand Position = 8, Proportional Gain = 1.2, Integral Gain -= 0.1, Steady State

Position = 7.7, Steady State Output Voltage = 7.7V, Rise Time = 27s

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Page 14: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

12

Chart 2.3 Demand Position = 8, Proportional Gain = 1.2, Integral Gain -= 0.2, Steady State

Position = 7.9, Steady State Output Voltage = 7.8V, Rise Time = 16s

Chart 2.4 Demand Position = 8, Proportional Gain = 1.2, Integral Gain -= 0.4, Steady State

Position = 8.0, Steady State Output Voltage = 7.8V, Rise Time = 7s

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Page 15: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

13

Chart 2.5 Demand Position = 8, Proportional Gain = 1.2, Integral Gain -= 0.8, Steady State

Position = 8.0(Oscillating 0.6), Steady State Output Voltage = 7.8V, Rise Time = 2.5s,

Overshoot =20%

Integral Gain Results

It is evident from Charts 2.1-2.5 that increasing the integral gain reduces the lead-lag of the

system, thereby increasing the speed of the system response and decreasing the error in the

steady state response by ramping up the gain in the system more the longer an error

between the demand and system response existed; however it also decreased stability of

the system and introduced overshoot and oscillations at values above 0.8. An integral gain

of 0.8 in conjunction with a proportional gain of 1.2 was chosen to continue the

investigation as these values offered a rapid system response and reduction in the steady

state error. The integral gain did introduce a 20% overshoot, however this is commonly

accepted prior to introducing differential control, as differential control can reduce or

eliminate overshoot.

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Page 16: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

14

Differential Control

Chart 3.1 Demand Position = 8, Proportional Gain = 1.2, Integral Gain -= 0.8, Differential

Gain =0.02, Steady State Position = 8.0 (Oscillating 1.2), Steady State Output Voltage = 7.6V,

Rise Time = 2.5s, Overshoot =15%

Chart 3.2 Demand Position = 8, Proportional Gain = 1.2, Integral Gain -= 0.8, Differential

Gain =0.1, Steady State Position = 8.0 (Oscillating 0.6), Steady State Output Voltage = 7.6V,

Rise Time = 3s, Overshoot =12%

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Page 17: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

15

Chart 3.3 Demand Position = 8, Proportional Gain = 1.2, Integral Gain -= 0.02, Differential

Gain =0.5, Steady State Position = 8.0 (Oscillating 0.4), Steady State Output Voltage = 7.7V,

Rise Time = 4s, Overshoot =2%

Integral Gain Results

Charts 3.1-3.2 show that increasing the differential gain was reducing the overshoot of the

system response, however instability and oscillations were being introduced, increasing the

error in the steady state response. Upon consultation with the laboratory supervisor, Mehdi

Zahir he suggested a review of the integral control procedure and the integral gain final

value. This review resulted in an optimised system shown by Chart 3.3, where the integral

gain had been reduced considerably, and the differential gain increased, producing a system

response that was fast, stable and with minimal steady state error.

Changing Demand Position

Having arrived at the PID system in Chart 3.3 it was realised that this system is optimised for

a demand position of 8.0, a large difference from the rest position of 1.3, but what if the

demand position was changed?

A further investigation is embarked upon to ascertain if the systems response would be

suitable for all demand positions.

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Page 18: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

16

Chart 4.1 Demand Position = 6, Proportional Gain = 1.2, Integral Gain -= 0.02, Differential

Gain =0.5, Steady State Position = 6.0, Steady State Output Voltage = 7.8V, Rise Time = 4s,

Overshoot =2%

Chart 4.2 Demand Position = 4, Proportional Gain = 1.2, Integral Gain -= 0.02, Differential

Gain =0.5, Steady State Position = 4.0, Steady State Output Voltage = 7.7V, Rise Time = 7s

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Page 19: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

17

Chart 4.3 Demand Position = 2, Proportional Gain = 1.2, Integral Gain -= 0.02, Differential

Gain =0.5, Steady State Position = 2.0, Steady State Output Voltage = 7.7V, Rise Time = 25s

Chart 4.4 Demand Position = 2, Proportional Gain = 1.2, Integral Gain -= 0.02, Differential

Gain =0.55, Steady State Position = 2.0, Steady State Output Voltage = 7.7V, Rise Time = 21s

Changing Demand Position Results

It is evident from Charts 4.1-4.3 that decreasing the demand position, and thereby the

difference from the rest position of 1.3 to the demand position, resulted in decreasing

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Po

siti

on

/Ou

tpu

t V

olt

age

Time (s)

Page 20: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

18

response times for the PID system implemented. Adjusting the differential gain in Chart 4.4

improved this slightly, however further investigation would have been required to obtain

proportional, integral and differential gains more suitable for a variety of demand positions,

and varying demand positions, such as a time dependant cyclic demand instead of a step

demand. Unfortunately due to the limited time of the lab session this further work lay

outside of the scope of the investigation.

Calibration of Ultrasonic Range Finder Scale

When sufficient control was established, the arbitrary scale resulting from the output signal

from the ultrasonic range finder was calibrated against the measuring tape to the right of

the glass tube. This involved using the Simulink model in figure 1.7 with the PID values

shown in Chart 4.3 and setting a range of range finder demand values, then reading off the

corresponding steady state position of the Ping-Pong ball on the measuring tape to the right

of the glass tube. This resulted in Table 1.2

Position Demand Range Finder

Output Measured Position

[V] [V] [mm]

1.4 1.4 1310

1.5 1.5 1300

3 3 1110

4.5 4.5 890

6 6 680

7.5 7.5 470

9 9 260

10 10 110

Table 1.2 System response to demand values, and the corresponding steady state position of

the Ping-Pong ball on the measuring tape to the right of the glass tube.

This table was charted, Chart 5.1, and the mathematical relationship evaluated relating the

arbitrary scale resulting from the output signal from the ultrasonic range finder to the

measuring tape to the right of the glass tube. A new Simulink model with a block facilitating

the input of a demand value for the position of the Ping-Pong ball in mm was developed,

Figure 1.8, and tested. This allowed for a demand to be tracked effectively by the Ping-Pong

ball upon a user input related to the measuring tape.

Page 21: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

19

Chart 5.1 Relationship between the arbitrary scale resulting from the output signal from the

ultrasonic range finder and the corresponding steady state position of the Ping-Pong ball on

the measuring tape to the right of the glass tube.

Figure 1.8 Simulink model facilitating the input of a demand value for the position of the

Ping-Pong ball in mm corresponding to a position on the measuring tape of the glass tube.

y = -0.0072x + 10.8465 R² = 0.9997

0

2

4

6

8

10

12

0 200 400 600 800 1000 1200 1400

Ran

ge F

ind

er O

utp

ut

Po

siti

on

[V

]

Position on Measuring Tape [mm]

Page 22: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

20

Conclusion The aim of this investigation was to achieve stable position control of a Ping-Pong ball using

A PID controlled DC fan adjusting airflow through a glass tube. This was achieved and the

PID system was tuned to control the system adequately to allow sufficient control of the

Ping-Pong ball’s position within the tube to accurately calibrate it to a physical scale.

The optimum PID control algorithm derived from his investigation was most dependent on

proportional and derivative gains, and was most effective at tracking larger changes in

positional demand to the system.

There is still room for improvement of the PID system developed in responding to small

demand changes; further testing would consist of investigating this and the systems

response to other demand types, i.e. cyclic demands.

The system was very dynamic with little damping (underdamped) due to the main dynamic

force acting on the system in the form of turbulent airflow being variable and transient in its

nature. This results in the system having some poles close to the imaginary axis of the s-

plane, which is evident from the system becoming unstable with the addition of larger

proportional and integral gains. The other dynamic force, gravity, remains constant and has

a predictable effect which enables the system to be controlled as it results in the system

having some poles close to, or situated on, the real axis.

The investigation was successful in achieving the objectives of familiarising the operator

with Matlab Simulink Models and Real Time Windows Target, Use of Feedback and Feed-

Forward Control, Use of the Sensoray 626 Interface Card and Use of the FR04 Ultrasonic

Range Finder. It was especially informative in the use and tuning of PID controllers on

dynamic systems, which the author feels he has a much better understanding of as a result

of carrying out this work.

Page 23: Position Control of PP ball

Position Control of a Ping-Pong Ball James Goddings 3131147

A-1

References

Ashwini Miryala, Kyle Scarlett, Zachary Zell, Brandon Kountz, (2006), The University of

Michigan Chemical Engineering Process Dynamics and Controls Open Textbook - PID

Downslides & Solutions, available at

https://controls.engin.umich.edu/wiki/index.php/PIDDownsides accessed on 14/11/2015

LSBU (2015), London South Bank University School of Engineering –Control Systems Lab

Room 405 – PID Position of a Ping Pong Ball in a glass tube.

Satar Dr. T. (2013), Principles of Control Lecture Notes - PID Control

Sensoray (2004), Sensoray Model 626 PCI Multifunction I/O Board Revision F available at

http://www.sensoray.com/downloads/man_626_1.0.5.pdf accessed on 14/11/2015