EE-371 CONTROL SYSTEMS LABORATORY Assignent 9 Ball and Bea Design Project Purpose The objectives of this project are: To obtain a atheatical odel and a linearized odel of the ball and bea syste. Design two controllers to control the position of the ball along the track ake it follow a coanded input. Build a Siulink odel of the plant and siulate off line Build the WinCon application, ipleent, test and analyze the syste on the real-tie hardware To use the reote sensor for aking the Ball on the bea follow the Ball on the reote sensor for operation in aster / slave tracking ode. Introduction The purpose of the design is to control the position of the ball along the track by anipulating the angular position of the servo. The syste is often used as a bench ark proble for any different control schees such as the control odel in the rocket toppling control syste, where a feedback syste is used to prevent rockets to topple out of balance during launch by forces and oents that could perturb the vertical otion. The Ball and Bea syste is driven by the servootor as shown in Figure 9.1. The bea consists of a steel rod in parallel with a nickel-chroiu wire-wound resistor foring a track upon which a etal ball is free to roll. One end of the beas is coupled to the servootor through a lever ar and gears and the other end is fixed. The wire-wound resistor is biased and when the ball rolls along the track it acts as wiper siilar to a potentioeter. The position of the ball along the track is obtained by easuring the voltage at the steel rod. Figure 9.1: Ball and bea odule coupled to the servo plant. 9.1
An optional reote sensor is also available for operation in aster / slave tracking ode. This sensor is used, as the input to the Ball & Bea desired position, aking the Ball on the bea follow the ball on the reote sensor. The first step in the design of a control syste is the atheatical odeling of the physical syste as follows 1. Matheatical Modeling 1.1 Ball and bea Model The paraeters of the ball and bea odule shown in Figure 9. are defined as follows: x L Ball α Lever ar r θ Output Gear Figure 9. Siplified ball and bea scheatic L Bea length ( L 16.7 c) r Lever ar offset ( r 1 in) α Bea angle coordinate θ Servo gear angle Mass of Ball R Radius of the ball J Ball s oent of inertia ( J R ) g Gravitational acceleration ( g 9.8 /s ) Consider the free-body diagra shown in Figure 9.3. Neglecting frictional force, two forces influencing the otion of the ball are F tx F rx Force due to translational otion Force due to ball rotation 9.
d x Denoting the acceleration dt x Ftx along x as x, force due to translational otion is Torque due to the ball rotation is dωb d( vb / R) d ( x/ R) J Tr FrxR J J J x dt dt dt R or g sinα x α g F rx F tx g cosα α Figure 9.3 Rolling ball free-body diagra J Frx x R Substituting for the oent of inertia of the ball (Sphere J Frx x Applying the Newton s second law for forces along the inclination, we have R ), we get or Frx + Ftx gsin α x + x gsinα x g sin α (9.1) 7 We use the above nonlinear equation in the Siulink odel. We also linearized the above equation to obtain a transfer function of the ball and bea controller design. For sall angle, sinα α, and (9.1) becoes x gα (9.) 7 9.3
Taking the Laplace transfor of (9.), we find X () s (/7) g α() s s (9.3) Equating the arc distance traversed by the gear at radius r with the arc distance traversed by the bea at radius L, we have rθ Lα or r α θ (9.4) L The Siulink block diagra for the rolling ball dynaic as given by the nonlinear equation (9.1) is as shown in Figure 9.4. Nonlinear Ball and Bea Model alpha Sin Trigonoetric Function ( / 7)*9.8 Gain x'' 1 x' 1 x s s Integ 1 Integ Figure 9.4 Siulink block diagra for the rolling ball odel. Create a subsyste with α as inport and x as the outport in radians. To do this, enclose the blocks within a bounding box as shown in Figure 9.4. Choose Create Subsyste fro the Edit enu. Edit in1 an out1 ports as alpha and x and renae the subsyste as Rolling Ball Model, and obtain the subsyste shown in Figure 9.. alpha x 1. Servootor Model Rolling Ball Model Figure 9. Siulink Subsyste for the rolling ball odel. In the position control experient (Lab ) the otor-load transfer function with position as output was found to be ηk K or θo() s RJ a eq Vi () s Beq ηkkg s s+ + Jeq Ra J eq g (9.) 9.4
θo() s a Vi() s s( s+ b) Where ηk K B ηk K a, b + R J J R J g eq g a eq eq a eq In this project the servootor is arranged for the high gear ratio as shown in Figure 9.6. For this configuration the gear ratio is K g (14)(). (9.6) (9.7) Figure 9.6 High gear ratio configurations The syste paraeters are as follows: Arature resistance, R a.6 Ω Motor voltage constant, K 0.00767 V-s/rad Motor torque constant, K τ 0.00767 N-/A Arature inertia, J Tachoeter inertia, 3.87 10 Kg J tach High gear ratio, K g (14)() 7 0.7 10 Kg 7 Equivalent viscous friction referred to the secondary gear Motor efficiency due to rotational loss ηr 0.87 Gearbox efficiency, ηgb 0.8 η η η (0.87)(0.8) 0.739 r gb B K B + B 4 10 3 eq g L N/(rad/s) Gear inertia: J 10 4.183 10 Kg J 7.443 10 Kg 6 J 4 1.0081 10 Kg 7 Load inertia, J J + ( J ) + J.83 10 Kg L 10 7 4 - J K ( J + J ) + J (14 ) (3.87 + 0.70) 10 +.83 10 0.003 Kg 7 eq g tach L 9.
Control syste strategy and controller design Te ball and bea odule provides two easureents: the encoder provides the servootor output θ o ( t ), and the bea sensor provides the ball s displaceent x() t. The control syste design requires two feedback loops; one inner loop for the otor angle control, which actuates the bea and an outer loop for ball position control. In this project a proportional gain and a rate gain is to be designed for each feedback loops. Therefore two controllers are to be designed. The objective of the servo controller is to ake the servootor output θ ( t ) follow the input angle, o θ () t. The objective of the ball and bea controller is to ake the ball position x ( t ) follow the i reference position xi ( t ). If the servootor controller is ade to respond sufficiently faster than the ball and bea controller, these controllers can be designed independently.. Pre Laboratory Assignent.1 Servootor controller Design Evaluate a, and b of the plant transfer function as given by (9.7) and obtain the plant transfer function. In this project, the high gear ratio is used, i.e., K (14)(), and N/(rad/s). Therefore, a, and b are different fro those evaluated in Lab. g B eq o 4 10 As in position control (Lab ) we use a rate feedback and a position feedback given by V() s K [ θ () s θ ()] s K Ω () s (9.8) i P i o D o This feedback loop is shown in Figure 9.7. The purpose of this syste is to have the output angle, θo( t) follow the input angle, θ i ( t). Design this controller to eet the following tiedoain specifications: Step response daping ratio ζ 0.8 Step response peak tie t 0.1 second p 3 θ i () s K P Vi () s a s+ b Ω o() s 1 s θ o() s K D Figure 9.7 Position Control using position and rate feedback. Applying the Mason s gain forula, the overall transfer function becoes 9.6
θ () s K a θ s s + K a + b s+ K a o P i() D ( ) P Substitute for a, and b, and obtain the closed loop transfer function in ters of the nuerical values. θo () s θi () s The second-order response peak tie, is given by t p ω n t p (9.9) π (9.10) 1 ζ The servo otor transfer function has the sae for as the standard second-order transfer function θo() s ωn (9.11) θi() s s + ζωns+ ω n Coparing the plant characteristic equation given in (9.9) with the standard second-order characteristic equation in (9.11), find two equations for K and K in ters of a, b, ζ, and ω n. Substitute for the paraeters and obtain the values of K P, and K D for the above design specifications. K P, D P D K (9.1) The SIMULINK siulation diagra naed Lab9_Si.dl is constructed as shown in Figure 9.8. In the Siulink block diagra you can replace a, b, KP, and KD with their values. Alternatively, you can place equations (9.7), and (9.1) in a script -file to copute a, b, KP, and KD which is sent to the MATLAB Workspace, then siulate the Siulink diagra. Fro the Siulink/Siulation Paraeters select the Solver page and for Solver option Type select Fixed-step and ode4 (Runge-Kutta) and set the fixed step size to 0.001. 1 Degrees 0.1Hz Square Signal Generator Theta_i Servo Plant Transfer Fcn a 1 pi/180 + KP + s + b s 180/pi Theta_o Deg-Rad Integrator Rad-Deg Scope KD Derivative Feedback Position Feedback Figure 9.8 Siulink diagra for the servo plant position control. Obtain the response to a square input of aplitude 1 and frequency 0.1 Hz. 9.7
Create a subsyste with θi and θ o in radians. To do this, enclose the blocks within a bounding box as shown. Choose Create Subsyste fro the Edit enu. Edit in an out port as Theta_o and Thetha_o and renae the subsyste as Copensated Servootor as shown in Figure 9.9. theta_i theta_o. Ball and bea controller Design Copensated Servootor Figure 9.9 Copensated Servo plant position subsyste The outer loop controls the ball position using the sae feedback law. α K ( x x ) K x (9.13) bp i o bd o The purpose of this syste is to have the ball position xo ( t ) follow the reference position xi ( t ). Design this controller to eet the following tie-doain specifications: Step response daping ratio ζ 0.707 Step response peak tie t 1.8 second p Taking the Laplace transfor of (9.13), we have α () s KbP[ Xi () s Xo()] s KbDsXo () s (9.14) Fro (9.3) 7s s α () s Xo() s Xo() (9.8) 7 s (9.1) Substituting for α () s fro (9.1) into (9.14) results in the following closed loop transfer function Xo() s 7KbP X i() s s + 7KbDs+ 7K bp The second-order response peak tie t p ω bn π 1 ζ b t p, is given by (9.16) (9.17) The servo otor transfer function has the sae for as the standard second-order transfer function given by Xo() s ωbn Xi() s s + ζωbns+ ω bn (9.18) Fro (9.16) and (9.18), we have ωbn ζω bn K bp rad/, K bd 7 7 rad-s/ (9.19) 9.8
Coparing the plant characteristic equation given in (9.16) with the standard second-order characteristic equation in (9.18), find two equations for K and K in ters of a, b, ζ, and bp bd b ω bn. Substitute for the paraeters and obtain the values of KbP in deg/c, and KbD in degsec/c for the above design specifications K bp K bd.3 Digital Siulation Utilizing the ball placeent feedback equation (9.14), equation (9.4), copensated servo plant subsyste (Figure 9.9), equation (9.4), and rolling ball odel (Figure 9.) construct a Siulink diagra siilar to the one shown in Figure 9.10. Apply a unit square wave of 0.1Hz and a gain of say c for the ball aplitude displaceent. The oveent of the servo gear is constraint to a axiu value of ± 6. Therefore ake sure that you place a liiter and set the upper and lower liits to no ore than ± 0. Mux 1 0.1 Hz Signal Generator Gain Derivative Feedback alpha KbD theta_o Deg ±0 + KbP + 16.7/1 pi/180 x_i c KbP L/r Liiter Deg to Rad x_o c Derivative KbD du/dt theta_o Rad theta_i theta_o 1/16.7 alpha x 100 Copensated Servootor r/l 180/pi Rolling Ball Model Ball Position to c x_o c Position Feedback Rad to Deg theta_o Figure 9.10 Ball and bea Siulink diagra with controllers for servo plant and ball and bea In Siulation paraeters dialog box set the Stop tie to 1, for the solver select Fixed-step, ode4 (Runge-Kutta), and 0.001 for step size. Obtain the response for the servootor angular position θ o( t ) and label as Figure 9.11. Also, obtain the response for the ball position and label as Figure 9.1. Coent on the ball position response and state if the ball position response eets the design specifications within the accuracy of the nuerical solution. All the prelab calculations, design and siulation ust be copleted prior to the laboratory session. The plants transfer function and the controller values ust be checked and verified by your instructor. 9.9
3. Laboratory Procedure When you have finished testing your odel in SIMULINK, it has to be prepared for ipleentation on the real-tie hardware. This eans the plant odel has to be replaced by the I/O coponents that for the interfaces to the real plant. 3.1 Wiring diagra Using the set of leads, universal power odule (UPM), SRV-0 DC-otor, and the connecting board of the MultiQ3 data acquisition board, coplete the wiring diagra shown in Figure 9.13 as follows: Fro To Cable Ball & bea sensor S1,S on UPM 6 pin ini Din to 6 pin ini Din Reote sensor S3 on UPM 6 pin ini Din to 6 pin ini Din Encoder on SRV0 MultiQ/Encoder 0 pin Din to pin Din Motor on SRV0 UPM/To Load 6Pin to 4 Pin Din, Gain 1 Cable D/A #0 on MultiQ UPM Fro D/A RCA to Pin Din A/D # 0, 1,, 3, on MultiQ UPM- TO A/D Din to 4xRCA MultiQ SRVO- Motor Encoder Fro D/A UPM S3 TO A/D Analog Output #0 D/A B RAnalog W Input Y A/D Bea sensor S1 To Load Encoder #0 Reote sensor Figure 9.13 Wiring diagra for servo otor position control syste. 3. Creating the Ipleentation odel The Encoder_Tach.dl subsyste, which was created in the position control experient shown in Figure 9.14(a). 9.10
Vel [rd/s] Tacho d(pos)/dt [rd/s] Vel (Encoder) (Pos [rd] Encoder and Tacho input Figure 9.14(a) Interface to the SRV0 Feedback Signals. If you double-click on the above subsyste it would display the underlying syste as shown in Figure 9.14(b). Quanser Consulting MQ3 ADC SRV0 Tach Input Channel 1000/1. 1/(14*) 0 s + 0 *pi/60 1 V to RPM RPM to [rd/s] 1/Gear ratio Low-pass filter Vel [rd/s] Thacho Quanser Consulting MQ3 ENC *pi/4090 0s s + 0 Differentiator d(pos)/dt [rd/s] Vel (Encoder) 3 Pos [rd] SRV0 Encoder Input Channel 0 Count to rd Figure 9.14(b) Content of the subsyste Encoder-Tach. Get a new odel in SIMULINK and begin to construct the ipleentation odel with the required I/O coponents that for the interfaces to the real plant. Load the above Encoder_Tach.dl subsyste (this was constructed in Lab). Get the Analog Output block fro the Quanser MultiQ3 and set the Channel Use to 0 as is in the wiring diagra. Add the position and velocity feedback gains to the signal coing fro the Motor Encoder, coplete the feedback loops and connect the resulting signal to the Quanser Analog output. Set the gains KP and KD to the values found in part.1. Get an analog input for getting the ball position signal fro the ball and bea sensor and the reote sensor. Double-click to open its dialog box and in the Channel to Use box enter [1,] in MATLAB array for. Get a Deux block fro the Signal & Syste library to separate the signals coing fro Channel 1 and of the sensor analog input. The bea length is (16.7)(.4) c, and the sensor voltage range is 10 V. Thus you need two Gain blocks to ultiply the incoing signals by the factor (16.7)(.4) /10 to easure the ball position in c. Get a Manual Switch fro the Nonlinear Library to connect the Signal generator and the Reote sensor to the Suing point block as shown. Add the position and velocity feedback gains to the signal coing fro bea sensor, coplete the feedback loop. Set the ball and bea controller gains KbP and KbD to the values found in part.. Coplete the reaining 9.11
blocks as in the SIMULINK siulation diagra. The oveent of the servo gear is constraint to approxiately ± 6. Therefore ake sure that you place a liiter and set the upper and lower liits to no ore than ± 0. When the servo gear is in the resting position, the servo angle is about 6 degrees. We start the controller fro the resting position as shown in Figure 9.16(a). Thus, In order to ensure that the servo is at the zero position when the coand is zero degrees, we coand the servo with a -6 degree offset fro the starting position. Use a Signal Generator with Aplitude 1, and Frequency 0.1 Hz and set the gain block value to. This gives a displaceent range of 10 c. Place as any Scopes as you like to onitor the ball position and the servootor angle. Your copleted odel should be the sae as shown in Figure 9.1. You y save the odel under the file nae say, Lab9_Ip.dl. 1 0.1Hz Aplitude Signal Generator Manual Switch + x_i KbP Kb_P alpha + 16.7/1 L/r Kb_D KbD Initial angle at start 6 Constant theta_i Degree ±0 Saturation 1s s + 1 + + pi/180 + Degree to Rad KP K_P + 1 Cable 1 Vel Rad/s K_D KD theta_o Quanser Consulting MQ3 DAC Analog Output to UPM driving SRV0 Vel [rd/s ] Tacho d(pos)/dt {rd/s], Vel (Encoder) x_o Bea sensor Analog input Channel 1 Pos [rd] Encoder and Tacho input Bouble-click on the switch to ove fro the signal generator input to reote sensor 16.7*.4/10 Bal Pos Reote sensor 16.7*.4/10 Bal Pos 1 Deux Quanser Consulting MQ3 ADC In the Channel to Usedialog box type [1,] Figure 9.1 SIMULINK Ipleentation diagra for Ball and Bea Project 9.1
Figure 9.16(a) Starting position (b) Zero position At this point turn the servo gear by hand holding it at zero position, then the lever ars should be vertical and the bea should be perfectly horizontal so as if you place the ball at idpoint of the track it should alost stay without rolling to the sides. You ay use proper tool to adjust the height of the support ar at the left hand side of the track, or siply raise end that would level the bea by placing few sheets of paper under it. If the bea is not perfectly horizontal when the servo angle is at zero position, there will be a steady state error that is a positive or negative offset depending on the bea tilting direction Before proceeding to the next part request the instructor to check your electrical connections and the ipleentation diagra. 3.3 Copiling the odel In order to run the ipleentation odel in real-tie, you ust first build the code for it. Turn on the UPM. Start WinCon, Click on the MATLAB icon in WinCon server. This launches MATLAB. In the Coand enu set the Current Directory to the path where your odel Lab9_Ip.dl is. Before building the odel, you ust set the siulation paraeters. Pull down the Siulation dialog box and select Paraeters. Set the Start tie to 0, the Stop tie to 16, for Solver Option use Fixed-step and ode4 (Runge-Kutta) ethod, set the Fixed-step size, i.e., the sapling rate to 0.001. In the Siulation drop down enu set the odel to External. Make sure all the controller gains are set. Start the WinCon Server on your laptop and then use Client Connect, in the dialog box type the proper Client workstation IP address. Generate the real-tie code corresponding to your diagra by selecting the Build option of the WinCon enu fro the Siulink window. The MATLAB window displays the progress of the code generation task. Wait until the copilation is coplete. The following essage then appears: ### Successful copletion of Real-Tie Workshop builds procedure for odel: Lab9_Ip. 9.13
3.4 Running the code Following the code generation, WinCon Server and WinCon Client are autoatically started. The generated code is autoatically downloaded to the Client and the syste is ready to run. Make sure the Manual Switch in Siulink ipleentation diagra is connected to the upper terinal coing fro the Signal generator. If not double-click on the switch. To start the controller to run in real-tie, click on the Start icon fro the WinCon Server window shown in Figure 9.17. It will turn red and display STOP. Clicking on the Stop icon will stop the real-tie code and return to the green button. Figure 9.17 WinCon Server If you hear a whining or buzzing in the otor you are feeding high frequency noise to the otor or otor is subjected to excessive voltage, iediately stop the otor. Ask the instructor to check the ipleentation diagra and the copensator gains before proceeding again. 3. Plotting Data You can now plot in real-tie any variables (e.g. angles, ball position) of your diagra by clicking on the Plot/New/Scope button (with the scope picture) in the WinCon Server window and selecting the variable you wish to visualize. Select x_o and click OK. This opens one realtie plot. To plot ore variables in that sae window, click on File/Variables fro the Scope window enu. The naes of all blocks in the Siulink odel diagra appear in a Multiple. Select Variable Tree. You can then select the variable(s) you want to plot. In this case, select, for exaple, x_o and x_i. In the Scope pull-down enu, select Buffer and set the Buffer Size to 1. Using Freeze you can freeze the plot. Fro the File enu you can Save and Print the graph. If you choose Save As M-File you save the plot as M-file. Now at the MATLAB propt if you type the file nae you can obtain the MATLAB Figure plot. You can type grid to place a grid on the graph or edit the Figure as you wish. You can also change the controller gains on the fly (i.e. while the controller is running in realtie). To do so, double click on the Siulink Ipleentation gain block, change to the desired new value, and select Apply, or OK. Note the changes in the real-tie plots. If the response is not close to the expected value the bea is not perfectly level when otor angle is at zero position. Raising or lowering the left support to level the bea will iprove the response. In the next part the reote sensor is used for operation in aster/slave tracking ode. This sensor is used, as the input to the Ball & Bea desired position for aking the Ball on the bea follow the ball on the reote sensor. Double-click on the Manual Switch in the Siulink 9.14
ipleentation diagra to connect to the Reote Sensor. Move the Ball on the reote sensor and observe the Ball on the bea tracking your oveent and obtain the response. In WinCon Server, use File Save, this saves the copiled controller including all plots as a.wpc (WinCon project) file. In case you want to run the experient again, fro WinCon Server use File/Open to reload this.wcp file, and run the project in real tie independent of MATLAB/Siulink. To prevent excessive wear to the otor and gearbox run the experient for a short tie. 4. Project Report Your report ust include the detailed servo plant and the ball and bea block diagra. Obtain forulas for the servootor controller gains and the ball and bea controller gains, and the design values to eet the design specifications. Include your final K P, K D, KbP, and KbD after fine-tuning, if it was required. Plot the final actual syste response. Discuss the assuption and approxiations ade in odeling the servootor. Explain why the control syste design was feasible through two independent controller loops. Coent on your results; how does experiental response copare to siulated responses. Discuss the reason for any deviation in the actual transient response and the siulated response. 9.1