Sunteți pe pagina 1din 32

MECHATRONICS FINAL YEAR PROJECT FONTYS UNIVERSITY OF APPLIED SCIENCES

Ball Balancing Project

Group Members: -Rabindra Rijal -Huynh Phu Khanh -Frank Dooms -Bruce Appleton Author: Bruce Appleton

Summary
From the early stages of the project it became clear that a good construction was one of the key elements needed for this project to work. A couple of concepts were sketched and finally a construction concept with two independent axes was used. Some of the parts were to be designed from scratch in Autodesk Inventor (CAD) and later fabricated using the machinery in the mechanical engineering labs. The project was to balance a ball on a flat surface and to achieve this some form of feedback for the balls exact position on the flat surface was needed. For this it was decided to use a ten inch resistive touch screen. The touch screen can then provide the necessary feedback for position. A dedicated touch screen controller was added to read the coordinates and relay them to the PC via RS232. The touch screen controller relayed the touch screen coordinates via RS232 into labview. Although the touch screen controller supports USB, it was decided to use the RS232 interface due to protocol simplicity. The means to read the coordinates via RS232 had to be implemented in labview. To control the actuators a control system would have to be implemented using the touchscreen for feedback. It was decided to implement the controller in labview so we could change its parameters on the fly. To control the servo-motors a PWM signal would need to be generated within labview and supplied to each motor. The Ball Balancing project was a challenge, but we worked well together to achieve a lot.

Ball Balancing Project

Page 1

Glossary
SISO Single Input Single Output MIMO Multiple Input Multiple Output PWM Pulse Width Modulation CAD Computer Aided Design VI Virtual Instrument

Ball Balancing Project

Page 2

List of Figures, Graphs and Tables


Figure 1 5-wire resistive touch screen concept ....................................................................................... 8 Figure 2 touch screen controller.............................................................................................................. 8 Figure 3 construction concept sketch ...................................................................................................... 9 Figure 4 aluminium brace (CAD view) ................................................................................................ 10 Figure 5 aluminium brace dimensions .................................................................................................. 11 Figure 6 Translation arm (CAD view) .................................................................................................. 11 Figure 7 translation arm dimensions ..................................................................................................... 12 Figure 8 universal joint (CAD) ............................................................................................................. 12 Figure 9 HUCO universal joint dimensions .......................................................................................... 13 Figure 10 Rod-end bearing (CAD) ....................................................................................................... 13 Figure 11 IGUS rod-end bearing (EBRM-05) dimensions ................................................................... 14 Figure 12 Construction CAD model ..................................................................................................... 14 Figure 13 Final Construction (real image) ............................................................................................ 15 Figure 14 Ball on plate model concept ................................................................................................. 16 Figure 15 Motor time constant measurement circuit ............................................................................ 18 Figure 16 System Connections .............................................................................................................. 23

Ball Balancing Project

Page 3

Table of Contents

Summary ................................................................................................................................................. 1 Glossary .................................................................................................................................................. 2 List of Figures, Graphs and Tables ......................................................................................................... 3 Introduction ............................................................................................................................................. 6 Project overview ..................................................................................................................................... 7 Block schematic of the system ............................................................................................................ 7 Description of Individual Blocks .................................................................................................... 7 Construction ............................................................................................................................................ 9 Concept ............................................................................................................................................... 9 Construction components.................................................................................................................. 10 The Final Construction ..................................................................................................................... 14 CAD Model................................................................................................................................... 14 Construction implemented in reality ............................................................................................. 15 Modelling Section ................................................................................................................................. 16 Ball and plate .................................................................................................................................... 16 Motors and construction ................................................................................................................... 18 Simulation results ............................................................................................................................. 20 Implementation in LabVIEW ............................................................................................................... 23 Connection Diagram ......................................................................................................................... 23 Reading from Touch Screen ............................................................................................................. 24 VISA Open ..................................................................................................................................... 25 Validate Data................................................................................................................................. 25 Byte to (x, y) .................................................................................................................................. 25 Byte to nibble ................................................................................................................................ 26 Controlling the Motor ....................................................................................................................... 27 PWM_X ........................................................................................................................................ 28 PWM_Y ........................................................................................................................................ 28 Operators Control Panel .................................................................................................................. 29 Problems and Recommendations ...................................................................................................... 30 Conclusion ............................................................................................................................................ 31 Recommendations ................................................................................................................................. 31 Ball Balancing Project Page 4

Ball Balancing Project

Page 5

Introduction
For our final year of study we were to undertake a project in mechatronics lasting the semester. The project chosen was the Ball Balancing project. We were to design a system whereby we could balance a ball on a flat surface using actuators. This project was a great opportunity to gain knowledge in the field of mechatronics. The goal of the project is to build and implement a device that can balance a ball at any set point by tilting the flat surface allowing the ball to roll. The surface is tilted by actuators located below it. The mechanics by which the actuators transfer torque to the flat surface will have to be designed and built. The control system will have to drive the motors to make the ball move to the allocated position. In addition a feedback system will need to be implemented so the balls current position can be known at all times.

Ball Balancing Project

Page 6

Project overview
Block schematic of the system
Below is a block schematic of the entire system.

X, Y

PC (LabVIEW)

Motor

Construction + Touch Screen

Touch Screen Interface

Description of Individual Blocks PC: The controllers are implemented on a Personal Computer using National Instruments LabVIEW. The system must be running Windows XP or higher with a RS 232 COM port and PCI cards installed. - The COM port is required to input current position of the ball via Touch Screen Interface. A USB to RS232 converter maybe used where no COM port is available. - A PCI card is required to connect the National Instruments Adapter BNC 2110. Motors: The existing servo motors will be used for movement on each axis. The servo motors used are BMS620MG from Blue Bird Technology. They have following specifications: Weight: 50 grams Dimensions: 40.5 X 20 X 42 mm Torque at 4.8V: 9.1 kg-cm Torque at 6.0V: 10.6 kg-cm Speed at 4.8V: 0.15 sec/ 60 deg at no load Speed at 6.0V: 0.13 sec/60 deg at no load Touchscreen: The Touch Screen used for the project is a Five-Wire Analog Touch Panel from Higgstec Company. Major features and specifications of this device are noted below: Input Mode: Stylus or Finger Cable: FFC (Flat Flexible Cable) Frame Size: 248.920.30 X 186.690.30 mm View Area: 219.900.20 X 167.830.20 mm Active Area: 215.900.20 X 163.830.20 mm` Total Thickness: 2.200.20 mm Tail Length: 2056.00 mm Ball Balancing Project Page 7

Operational Temperature: -100C to +700C Loop Resistance: X: 20 to 500

Y: 20 to 500

Figure 1 5-wire resistive touch screen concept

Touch Screen Controller: As we intended to build a control system for our project, we need feedback from the touchscreen to know the current exact location of the ball. However the touch screen described above gives us only analogue values from different locations and our controller will be implemented in LabVIEW inside a PC (digital form). Additionally, these analogue signals from the screen need further calculation to be read as X & Y positions of the ball. For these reasons, and also to save time, we intend to use a dedicated touchscreen controller with USB interface to PC (USB-R5W-HT580-R) from Higgstec Company (same as Touch screen manufacturer).

Figure 2 touch screen controller

Power required: +5VDC (Max. 150mA, 50mV peak to peak max ripple) Protocol: COM: 9600 BPS baudrate 8 Data Bits USB: USB1.1 full speed Resolution: Sample 1024 X 1024 (12 Bits) Report Rate: COM: Min. 63 Points Per Second (PPS) USB: Min. 86 PPS Response Time: Max 20 ms Requirements: Resistance 30 to 500

Ball Balancing Project

Page 8

Construction
Concept
The figure below shows the construction concept for the balancing ball project.

Figure 3 construction concept sketch

The main parts: The main parts described below can be found in the concept sketch above. LINKAGE JOINTS Located either side of the linkage bars, providing connections between the motor and the backing plate. U-JOINT- Allows the screen plane to move in X and Y directions only. ALUMINIUM BRACE Provides a means for the linkage bars to be connected to the backing plate. TOUCHPAD SENSOR Resistive touch screen used for position information. BACKING PLATE - Provides added strength and a supporting base for the glass touch screen. GAURDRAILS Keeps the ball on the touch screen. GROUND PLATE Provides a stable base for the whole construction. TRANSLATION BAR Connects motor shaft to the linkage bar.

Ball Balancing Project

Page 9

After some thought we decided this would be the best construction for our project. Reasons for choosing this construction: Axes are independent. This gives us the advantage of being able to develop and test each axis separately; because a single motor works on each axis. Firm and stable if built correctly. Project implementation time is reduced using a simpler axes concept, whereby the motors are not coupled. Modelling and controller development are less complex with independent axes.

Construction components
However some of the parts such as the aluminium brace and translation arms would have to be fabricated out of aluminium from scratch. The linkage bars would need to be threaded both ends to fit into the rod end bearings as well as building the whole supporting structure. All in all there was quite a lot of work to be done in the mechanical engineering labs. The parts are described below in more detail. Aluminium Brace The aluminium brace is fabricated from a single piece of aluminium and is located underneath the perspex plane. Two rod-end bearings are located either side, fixed in place with pins. At the centre of the brace there is an extrusion for the universal joint to fit in. The aluminium brace provides a means to transfer torque to the plane.

Figure 4 aluminium brace (CAD view)

Ball Balancing Project

Page 10

Figure 5 aluminium brace dimensions

Aluminium Translation Arms The translation arms are connected to each motor.

Figure 6 Translation arm (CAD view)

Ball Balancing Project

Page 11

Figure 7 translation arm dimensions

Universal Joint Huco universal with brass joint. The universal joint was required to stop the whole upper part of the construction from rotating when the axis moved either up or down.

Figure 8 universal joint (CAD)

Ball Balancing Project

Page 12

Figure 9 HUCO universal joint dimensions

Rod-end Bearing Type 1: IGUS rod-end bearings (EBRM-05)

Figure 10 Rod-end bearing (CAD)

Ball Balancing Project

Page 13

Figure 11 IGUS rod-end bearing (EBRM-05) dimensions

The Final Construction


CAD Model The final CAD model has motion just like the real construction. Each axis can be moved independently and an animation for the working principal can hence be created.

Figure 12 Construction CAD model

Ball Balancing Project

Page 14

Construction implemented in reality The images below are taken of the real construction.

Figure 13 Final Construction (real image)

Ball Balancing Project

Page 15

Modelling Section
Our system model is divided into 2 sub models: The motors + the construction: input is the duty cycle of the PWM signal controlling the motor and output is the angle of the plate: H(s) The ball on a plate with an angle: input is the angle of the plate and output is the position of the ball: G(s) PWM duty H(s) Angle G(s) Position

Ball and plate

Figure 14 Ball on plate model concept

The angle of the plate will create force acting on the ball which then again result in a change of the ball position. The inclination is considered the x-coordinate. Let acceleration of the ball be denoted as

d 2x x' ' dt 2

The force due to translational motion is then Ftx = mx Rotational kinetic energy of the ball is: Krot = Prot = Tr* = =

Tr J
Ball Balancing Project

d (v b / R ) d d 2 x / R J J J x' ' dt dt R dt 2
Page 16

Where: J = moment of inertia (for solid ball defined by J=2/5*mR2) b=angular velocity of the ball Vb= speed of the ball along x axis The equation is arranged such that the final result is expressed solely in terms of position or its derivatives as well as variables associated with the ball. We now obtain the rotational force by dividing torque of the ball by its radius

Frx

Tr

R2

x' '

substituting the moment of inertia into the equation we get

Frx 2 / 5mR

R2

x' ' 2 mx' ' 5

In order to make the system independent of the mass of the ball we further express the above equations as

Frx Ftx mg sin 2 mx' ' mx' ' mg sin 5 2 x' ' x' ' g sin 5
Rearranging for x gives

5 g sin x' ' 7


We utilize approximation sin , since the angle of the plate will not exceed 5-10 degree inclination. This means that in radians, sine of the angle is approximately the angle itself, so the equation is further approximated as

5 g x' ' 7
Taking Laplace transform of position with respect to angle (details omitted) gives

5 g X (s) G( s) 72 (s) s
Taking g = 9.81 m/s2 we have:

G(s)

X ( s) 7.007 2 ( s) s

Ball Balancing Project

Page 17

Motors and construction

As a servo has internal feedback and control, it would take a lot of time and effort to dismantle the motor and model it correctly. To simplify our motor model through observation of the motor behaviour, we will just assume the model as a 1st order transfer function. The only value we will have to determine in this case is the time constant tau. In order to obtain this, we will put a load on the motor that is similar to our construction. Then a step input of the PWM duty cycle (D) will be apply to the motor and we will measure the output angle over time to find the time constant. After measuring the time required to get from a position zero to a 45 degree position, one can determine the motor constant m which can then be added to the Matlab system model. The motor will be attached to a potentiometer, and with a one shot logger, we can measure the voltage over the potentiometer (which is then proportional to the motor angle) and then determine the time constant of the motor + construction.

Figure 15 Motor time constant measurement circuit

Motor torques: On the motor with long shaft:

TLong

3 1 1 M Screen LBARHorri M Hinge LBARHorri M BARHorri LBARHorri M BARVert LBARHorri 4 4 2

On the motor with short shaft:

TShort

1 1 1 M Screen LBARHorri M HingeLBARHorri M BARHorri LBARHorri M BARVert LBARHorri 2 4 2


Page 18

Ball Balancing Project

mscreen = 564g mhinge = 96 + 2*24 = 144g mhoribar = 53.5g mverbar = 4.5g Base on the formula and data above, we can calculate the load weight use to replace the construction for the motor with short shaft is 349.25g and one with long shaft is 490.25g. With the time constant measured as 16ms, we can determine the transfer function of the motor and the construction:

As the time constant is 16ms, the angle reaches the wanted position after 5 times of = 80ms.

Ball Balancing Project

Page 19

Simulation results
A simulation with the 2 models combined show the following result: With a 0.005 duty cycle step input:

Angle

Distance

Potential energy

Ball Balancing Project

Page 20

Translation kinetic energy

Rotational kinetic energy

As we can see from the simulation result, the change of the potential energy is always equal to the sum of changes of 2 types of kinetic energy (law of conservation of energy). The system is then connected to a PID controller which gives the following closed loop response:

Distance

Ball Balancing Project

Page 21

Angle With the help of the PID controller, the ball reached the desired position after approximately 10 seconds. After the ball reached the desired position, the angle of the plate is fluctuating around. This is an expected behaviour as the plate should change angle to compensate any change in position of the ball away from the desired position.

Ball Balancing Project

Page 22

Implementation in LabVIEW
Connection Diagram

5 Wire Touch Screen

Touch Screen Controller [COM Mode]

USB Serial Converter

USB/COM Port [FTDI drivers]

Counter -0
X Motor

PC with LabVIEW
PCI 6024E card [NI DAQ drivers]

BNC 2110 Connector


Y- Motor

Counter -1

Figure 16 System Connections

As shown in the above diagram, the controlling of the ball position with LabVIEW is mostly defined by the interfacing between: (a)The Touch Screen Controller [via Serial COM Port in PC > 5 wire resistive Touch Screen] (b) The NI PCI 6024E - Card [via BNC-2110 > Motors [counter 1 and counter 0]] (see below)

Ball Balancing Project

Page 23

The program layout is such that we read the current position of the ball on the screen and send PWM signals to the respective motors to bring the ball towards center position. In short, we will read from the TS controller in Serial mode [COM3 in this case]; condition the signals via PID Controller and generate PWM signals [Dev1/Ctr0 and Dev2/Ctr1]. These three input and output processes must be done at the fastest possible rate; for which we will use 3 parallel while loops: One for reading from the touch screen One for generating PWM signals based on PID controlled variable for X Motor One for generating PWM signals based on PID controlled variable for Y Motor

For this purpose, following 7 VIs have been generated:

Reading from Touch Screen

Reading from the Touch screen involves following processes: Configuring and opening port Read 5 bytes at a time The bytes come in following order o Byte 1: A0 this value is prefixed every time with the coordinates, so it is easy to interpret, validate and convert. o Byte 2 and 3 X Coordinates o Byte 4 and 5 Y Coordinates Initially, the Read Buffer is filled with : o Byte 1 : A0 o Byte 2 : 08 o Byte 3: 00 o Byte 4: 08 o Byte 5: 00 The conversion of 08 00 gives 512 (described later). Since the touch screen co-ordinates are (1024, 1024) we always start with (512,512) the center of screen.

Ball Balancing Project

Page 24

VISA Open

These are the settings to open the COM Port where the Touch Screen Controller is connected. By installing the Virtual COM Port drivers from FTDI, the USB ports are now accessible serially. The Touch Screen Controllers datasheet specifies: o Baud Rate: 9600 Bps o RTS [Request To Send] set to HIGH The rest are general settings for a serial transmission. Validate Data

The coordinates are prefixed with A0, so we search the array for value A0 (=160 decimal) and take 4 consecutive bytes out of that and convert them to X and Y positions (integers). Byte to (x, y)

Ball Balancing Project

Page 25

For each axis, the controller gives 2 bytes. During the conversion process, each nibble in hexadecimal system is converted as follows: If received bytes = 08 and 00 then x-position = 0X163 + 8X162 + 0X161 + 0X160 = 512 So there is a byte to nibble conversion required because computers can only represent 8-bit data. We ignored the MSB value because it is always 0. Byte to nibble

This VI splits the byte to 8bit array and takes only last 4 bits (nibble) and converts it to a number again. Then the X and Y Values are displayed by configuring the Display Graph accordingly.

Ball Balancing Project

Page 26

Controlling the Motor


The loop controlling the motor is as shown below:

This loop interacts with the motor via PCI 6024E card installed inside the CPU and connected via a BNC2011 connection toolbox. By using the National Instruments Measurement & Automation Explorer program, one can see that this device is installed as Device 1 and it has 2 counters Ctr0 and Ctr1. We will generate PWM signals via these counters and drive the motors on each axis. From the left side the blocks are described as below: DAQmx Create Virtual Channel: Create and initialize a output channel [Dev1/ctr0]. The most important parameters are: o Frequency: we use 50Hz by default, so the duration is 20ms standard. o Starting Duty cycle: 0.06 DAQmx Timing:The second block is about timing. The Implicit timing is used when no sampling time is needed and continuous samples are taken. DAQmx Start Task: The DAQMx VI block initiates the pulse generation. Then firstly, for each variable PWM controlled variable is determined. We take the input (a local variable from Touch Screen Readers X value). DAQmx Write: This sends the actual pulse trends to the hardware. Since the duty cycle changes with the position of the ball, the duty cycle has to change dynamically. So, the local variable has been introduced and new values are processed with a CASE STRUCTURE . A delay [50ms] higher than the pulse width of PWM [20ms] is required for efficient operation

Ball Balancing Project

Page 27

PWM_X The duty cycle required for the motor is a controlled variable with PID Controller. For the PID Controller:

The set-point is 512, the center position. The process variable is the current ball position. The gains are and output range are real-time adjustable from front panel. Time constant = 0.2ms

But in this case we brought down the values by decade because the contact surface of the ball never reached 512 and it kept oscillating. The final control was not fully accurate but the results were improved. So the value would be floating around 510 ~ 519. Here are the PID parameters we used: P = 2.5 I = 0.2 D=0 Output range: High = 0.0015, Low = -0.0035

PWM_Y

Ball Balancing Project

Page 28

Similar to X, but since the motors are aligned in opposite directions, the duty cycle has to be negated. The dt for X is 0.2ms and 0.5ms for Y that is because X is longer than Y, so the ball needs a larger push in X direction. The parameters used are: P = 2.5 I = 0.2 D=0 Output Range: HIGH = 0.0013 LOW = -0.0025

Operators Control Panel

This is the operators control panel with indicators and controls. The PID gains for X and Y shown and output range for X and Y are default values which we choose. The red dot in the graph shows the current ball position in touch screen.

Ball Balancing Project

Page 29

Problems and Recommendations


The system is mechanically stable and well controllable. In LabVIEW, by using a better implementation of PID Controller, a stable end result could be obtained. There is a problem with PWM generation. The problem says that it cannot update the pulse trend fast enough. The solution is to keep a delay greater than the width of the PWM. In our case the PWM was 50Hz signal (= 20ms) and the while loop had a 50ms, but it still didnt fix the problem. More detailed study is required here. The two counters must be synchronized for stable operation which we could not implement due to time shortage. This will be the best educational project for both for mechanically building and controlling the system.

Ball Balancing Project

Page 30

Conclusion
Although this project was a challenge our group succeeded in creating a working system. The ball does not settle at the desired position but instead moves near or around it with close proximity. Further fine tuning of controllers as well as construction improvements can improve this. The modelling of the system helped group members to understand but did not help in controlling and testing the system as we model the process in continuous time, but the actual system works with digital (discrete) signal.

Recommendations

Improvements to the construction to reduce play between joints. Servo motors with higher position accuracy (improved construction may also contribute to this). Adding springs to the construction to dampen certain oscillations. A MIMO and/or digital control system would work better. The current system could be enhanced by introducing a profile that the ball could follow as opposed to a single point.

Ball Balancing Project

Page 31

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