SYSTEMS I MAE 3723
Popular in Course
Popular in Mechanical and Aerospace Engineering
This 0 page Class Notes was uploaded by Felipe McLaughlin on Sunday November 1, 2015. The Class Notes belongs to MAE 3723 at Oklahoma State University taught by Staff in Fall. Since its upload, it has received 9 views. For similar materials see /class/232795/mae-3723-oklahoma-state-university in Mechanical and Aerospace Engineering at Oklahoma State University.
Reviews for SYSTEMS I
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 11/01/15
Optimal Control 5413 Project Ball and Beam Optimal Control Charles O Neill 7 May 2004 1 Introduction This design project simulates and controls a beam and ball system A ball rolls on a pivoting beam see Figure 1 The beam is connected through DC motor through a linkage arm The objective is to create an output feedback control system Figure 1 Ball Beam Layout The physical system consists of coupled linkages and a free to roll ball The linkage motion is non linearly coupled to the gear angle The beam has a length of 1 meter The gear arm has a radius of 003 meters and the linking arm has a length of 02 me ters The ball is steel with a radius of 15 millimeters The system has 2 energy storage components beam inertia and ball inertia System control is allowed through a voltage input into the DC motor which provides a torque applied at the gear arm The gear arm motion is harmonic the gear can go past top dead center in the straight up and down positions 11 BeamLeverGear Angles This section describes the beam motion derivation Figure 2 was used for this derivation The beam lever gear connection constraint is dsin6 A1 cos Lsina 0 Solving for the beam angle a yields a arcsin sin6 1 cos gt The lever arm angle 6 is Asin d1 cos6 L1 cosa The general solution for a and is complicated with quot erIos a 1400956 Figure 2 Beam Lever Gear Connections respect to the input 6 The general non closed form solution to this 4 bar system is Freudensteinls equa tionl The general solution to these governing equations was tested It was noticed that the lever arm motion is a higher order term in the overall beam angle be cause the gear arm length d is small Also noticing that the 6 term is a weak function of the beam angle 1 allows for a closed form a expression 3 m arcsin 7 cost9gt The beam angles and derivatives as functions of the input gear angle 9 are d 4 cos 9 a arcsin sint9gt d L 2 17s1n2t9 d Zsint arcsin 7 cost9gt For small dL ratios as given in this problem7 the derivative denominator terms can be ignored 12 BeamLeverGear Dynamics 121 Beam The primary function of the beam is to allow a at rolling surface for the ball A sizing study based on deflection7 inertia7 and availability was performed to size the beam 116 inch wall thickness 1 inch by 12 inch extruded aluminum tubing has suf cient me chanical properties and is readily available Bending at midbeam is about 110 mm The 1 meter beam has a mass of 030 kg The beam rotates about the left end with an an gle a The beamls inertia is Jbeam 1 3 mL2 at the rotation point Substituting yields an inertia of 010 kg m2 122 Lever Arm A leverarm length of 02 m was chosen based on a study of leverarm motion versus leverarm length Shorter leverarms are lighter but causes larger 6 an gles The 02 meter arm uses the same material size as the beam and has a mass of 0060kg and an inertia of 80 10 4 kg m2 123 Gear The gear arm has a length of 003 m as speci ed in the problem statement The gear is assumed to be a single lever similar to the leverarm The gear has a mass of 0009kg and an inertia of 27 10 6 kg m2 The drive motors inertia is considered separately 1717cost92 124 Overall Beam Dynamics The overall beamlever gear governing equation was derived through Lagrangels equation27 which is based on Hamiltonian kinetic and potential energy mini mization theory After some algebra the governing equation in terms of the input gear angle 9 is 42 JT Slnlt26gt62 7 JLE JT 2 JL d2 2 7 s1n2t9t9 s1n2t9t9 7gcost9 ltMTd MLd L 2 Tt J95 sin2t992 Mgd 2 gt The lumped inertia term J9 is d2 J9 JM JG JT cos2t9 JLE sin2t9 Also7 JT is 2 JT JJbMr2MLL2 7 d 7 L2 The above governing equation contains both dynamic inertial terms and static force terms By inspection7 the zeroinput ItTest condition due to gravity occurs at 97gn27r 13 Ball Dynamics The governing differential equation for the ball dy namics was given in the project statement However7 the coordinate system for the differential equation and the corresponding gure in the handout do not match The correction consists of moving the balls 7r7 origin to the beams pivot end Conceptually7 the d2 term should indicate that the ball accelerates away from the pivot point when the beam rotates The governing differential equation is Mgt Mgsina7Mrd20 lt J One practical complication exists if the ball slips instead of rolls For smooth beam surfaces7 balls with large rotational inertias7 and large beam angles7 slip ping is certain For this project7 any nonlinear ball beam slipping behavior is neglected rolling is linearly coupled with translation Calculus of Variations is everywhere 14 DC Motor The motor is a DC motor Figure 3 shows a schematic of the motor model The overall torque is TkM ltV7Rkewgt Figure 3 Motor Schematic Adding a gearbox changes the effective torque and rotational constants by the gear ratio G The effective torque constant is kM kMo 39 G 39 77 The effective backemf constant is k kEO G 141 Selection The motor is a DC motor Early on intuitionlr sug gested that a geared motor would be needed 9 has an effective operating range of in so small output motions and large torques are needed An initial mo tor size was estimated from quasisteady motion For an input angular velocity of 1 revs7 the maximum torque of 05 Nm occurs at 9 0 Maximum power is estimated to be below 75 W The Maxon RE max 21 250020 motor was se lected The continuous rated output7 6W is probably higher than needed but this allows for extra robust ness Also the motor series comes with reduction gear drives and encoders The Maxon GP 22 531 reduction gear 134163 was selected The motor gear7 and encoder speci cation sheets are attached in the appendix 14 2 Motor Validation The motor model was validated by disconnecting the linkages and starting the motor with a step input to lVeri ed with the project7s problem statement its rated input voltage7 4 Volt The spec sheet claims a 21 millisecond startup time constant and a no load rotational velocity of 11500 rpm Figure 4 shows the model s response 11800 rpm and approximately a 20 millisecond startup time The model does not include motor friction7 which accounts for the slightly high no load velocity i l H um um um um nus EIEIE um Elna Elna n1 ik l H um um um um EIEIE um Elna Elna n1 u as Time s Figure 4 Motor Validation 143 Concerns The motor model has some critical concerns First7 the gearbox losses are idealized as a torque ef ciency 60 This ef ciency probably overestimates the losses at low rpms Second the planetary gearbox certainly has unmodeled nonlinear behavior For typical static torques caused by gravity the gearbox will probably lockup because of the high 511 gear ratio Third7 the control system can act as a gener ator which implies shorted motor leads for the open loop responsel 15 Simulink Model The above ballbeam motor system was implemented in Simulink The simulink model is shown in Figure 5 There are three parts ifrom top to bottomi of the model plant controller and observer Also the left side includes the inputs signals the right side exports the states and animation 16 Animation An animation routine was created based on the sup plied Matlab sfunction The animation shows ball location beam lever arm and gear angles and the ball tracking point Figure 6 diagrams the pieces The animation sfunction bbanimate is attached Ball H9 Beam Pivot Point BallTracking LeverArm Point Gear Figure 6 Animation Diagram in Appendix C2 17 Open Loop Response The open loop response is simulated and plotted in Figures 7 and 8 Torques caused by beam ball and lever arm weights cause a nonzero beam an gle of 9 77r2 The linkage system reaches its 90 equilibrium position in approximately 23 sec ond however the ball continues to roll never reach ing equilibrium and eventually falls off the beams free frighti end The gear equilibrium point is 9 7157 as predicted Signi cantly heavier beams will slightly cause a further small negative gear ro tation due to the lever angle 6 at equilibrium The open loop stablebeam and unstableball response is as expected Keeping the beam level requires an offset input voltage uo Trimming the control input voltage with the bbtrim Matlab script Appendix C6 determines uo The trim voltage increases as the r increases which indicates an increasing ball s moment arm For the mid beam ball position r05 m the trim volt age is 069 Volt Next the system is simulated open loop with an Time s 00 02 05 Figure 7 Open Loop Animation offset input voltage uo of 0688 Volt Figure 9 shows the response The system is unstable because the balls weight moment changes and also because the effective linkage arm gear ratio77 changes From the gure the trim voltage is slightly low The ball ac celerates away from the pivot point which increases the required trim voltage Eventually the ball falls off removing the balls weight which causes the gear to accelerate past topdead center t9 7r2 a mm mm Figure 8 Open Loop States aam Figure 9 Open Loop With lnput Offset 2 Linear Model This section develops a linear model based on the nonlinear simulink model The linear model is cre ated about an operating point so a perturbation rep resentation must be formed first The entire ball beam system has 4 states 99T739x For an assumed linearization point run the system response is 1 z 7 11m and I 1 Ilin Also the input to the linear model needs a lineariza tion point 1 u 7 ulin and u u ulz n The linear offset ulin is determined from equilibrium With the bbtrim Matlab script Appendix C16 21 Linearization With linmod A linear state space model was created from the sysidmode1md1 simulink model With Matlab7s linmod commandl Sysidmode1md1 Fig 10 is an exact inputoutput representation of the ballbeam model used in the full simulink system Fig 5 The linmod routine outputs a system in the form iAzBu and yCzDu The linearization requires linearization values for the states and the input For a trimmed system uo 0687 With the ball at midbeam With a level beam r0l5 t9 0 the state matrices are 0 1 0 0 0 7902 71482 0 B7 5291 0 0 0 1 7 A 7021 0 0 0 0 Figure 10 Linearization Model 1 0 0 0 0 0 1 0 0 0 C 0 0 1 0 D 0 0 0 0 1 0 The eigenvalues of the plant matrix A are 70VS40v63i 70347063139 790 As seen in the openloop nonlinear simulation sec tion the system is unstable As expected and seen the unstable mode is the beam angle 3 0168 The input B matrix has a positive term in the row as expected 22 Simulation and Comparison A comparison of the linear and nonlinear open loop response With the input offset is shown in Figure 11 The dark line is the linear response The simulation runs to 17 seconds Which is When the ball falls off the beam for the nonlinear simulation The linear re us u ens arm Figure 11 Nonlinear vs Linear Open loop Compari son sponse remains at zero the nonlinear response drifts with the notquiteperfect input offset This particu lar linear simulation wrongly indicates that the sys tem is stab e A better comparison simulates the response to a step in input voltage For this simulation the input offset voltage was reduced by 00 volts the gear an gle should decrease and the ball should roll off the beams far end Figure 12 shows the nonlinear and linear responses The dark line is the linear response This simulation shows that the linear and nonlinear u a 705 mm ll 1 2 3 a 5 5 Figure 12 Nonlinear vs Linear Open loop Step Com parison models are indistinguishable for small perturbations iup to about 1 second When the ball moves toward the beams end the beam angle 1 increases which in creases the ball7s acceleration The linear model pre dicts less linkage inertia As expected both the non linear and linear simulations predict the ball rolling off the beams en 3 State Variable Feedback A state variable feedback controller is designed based on the steady state linear quadratic regulator3gt4 The cost function is J ITRlz puTRgu dt 0 The control signal based on the state vector x is 10 7R BT P m where P is the solution to the corresponding Riccati equation R1 7 PERngTP PA ATP 0 This formulation requires specifying the performance index matrices R1 and R2 The state covariance for an input noise w is A2 EAT BSwBT 0 31 Design Iteration Here the cost function design has a choice By in spection minimizing r deviations means leveling the beam It is expected that only penalizing r will create a goodenough controller however the linear control may cause past topdeadcenter gear angles which are completely unwantedl Penalizing both ball dis tance r and gear angle 9 should give a better con troller 311 Cost Ball and Control This design only penalizes ball location r The cost function is simple because the only tradeoff is be tween ball position and control input ITRlz 7 2 and uTRgu pu2 Thus the penalty matrices are 0000 0000 R10010 R2 0000 The expected best ratio of R1 and R2 is estimated from the maximum magnitudes of the r state and the u input r is restricted to be less than 10 m and u must be less than 4 Volt This ratio yields 2 E m L m 006 R1 42 Figure 13 shows a the time response for a sweep of p 10l0010001 with a unit step in desired ball displacement from 05 m to 04 m The linear system is linearized about 05 m The resulting con trol scheme doesn7t work very well For large con trol penalties the ball converges too slowly When switching to larger displacements AI gt 01m or to the nonlinear model the control scheme tends to force the gear angle past topdead center The ronly cost function is rejected 312 Cost Ball7 Gear angle7 and Control Adding the gear angle creates a cost function as ITRlz 7 2 92 and uTRgu pu2 am am Figure 13 r LQR Step Response Now ratios of 9 and r must be considered After some experimenting an error of 14 degree in 9 is considered equivalent to 3 mm in ball location This gives a Tt ratio of 215 Also the maximum allowable values of r and 9 are 1 m and 7r2 radians This gives a ratio of 247 A ratio of 22 was chosen Thus the penalty matrices are 10 00 00 00 R1 0 0 22 0 RZ 00 00 Figure 14 shows a the time response for a sweep of p 101001 with a unit step in desired ball dis placement from 02 m to 08 m The linear system is linearized about 05 m The overall performance has arm Figure 14 r 9 LQR Step Response Tt 22 signi cantly improved compared to the ronly cost function No over center behavior occurs because the cost function includes 9 However the ball position appears to be converging slowly and always over shoots Decreasing the ball tolerance in R1 should help For an error of 2 mm in r the Tt cost ratio is 4 Figure 15 shows the system response Increasing the Tt ratio helps The limitation now lies with the mo aam arm Figure 15 r 9 LQR Step Response Tt 40 tor supply voltage For this case the input cost p is limited to 01 because of the motor limit of 4 Volts Overloading the motor doesn7t seem to improve the system response appreciably especially when con sidering motor life degradation e nal best control law for the r and 9 cost func tion is with a Tt of 4 Figure 16 shows the compari son between the states and control for the linear and nonlinear models for two separate step responses 05 to 06 and 02 to 08 mm Figure 16 LinearNonlinear State Comparison The state error between the linear and nonlinear model are shown in Figure 17 for their respective sim ulations The linear model has a maximum ball lo M Figure 17 LinearNonlinear Error Comparison cation error of 2 cm at the highest ball velocity near 25 seconds 313 Controller Stochastic The steady state covariance matrix for the state vec tor is determined from the Lyapunov equation AEEATBSwBT0 where 51 is the equivalent white noise intensity of the plant input w The motor disturbance is assumed to be white noise with a standard deviation as a per centage of the rated motor torque For a 1 standard deviation based on the rated motor torque of 146 which corresponds to a voltage of 004 Volts the state covariance matrix is 6210 4 00000 1710 5 00000 E 00000 011 0 0000 13104 1710 5 00000 9110 6 00000 00000 1310 4 00000 3610 6 So 67 of the time the ball location should be within 3mm of the desired location and the angle 19 is within 14 degrees Simulation inside simulink requires spec ifying a band limited white noise model The inten sity is 02 The sample time should be small enought to approximate white noise From the linear system the maximum eigenvalue with control ABK is ap proximately 10 rads So an approximate system sample t1me 1s 27f At m fmax A ratio of system to noise sample time should be at least 101 The simulink model is simulated with a 1001 ratio of noise to system time and a 1 motor a Figure 18 shows the state time history with the nonlinear system model The experimental covariance matrix Figure 18 Controller Noise 1 based on the nonlinear systems states is 5 2 104 72810 5 sax106 74810 7 E 7 72810 5 0097 1410 7 1010 4 8 1106 1 4 107 20106 1510 7 74 810 7 1 0 104 1510 7 20106 The interesting difference between the covariance ma trices is that the nonlinear experimental covariance has stronger offdiagonal terms The diagonal covari ance terms are slightly lower for the nonlinear simu lation For 10 motor torque noise in the nonlinear model the standard deviations for r and 19 are 16 cm and 13 degrees The control voltage variance is 1 Volt This much noise in the output is severely degrading performance The control system is working at its limit as seen in Figure 19 routinely reaching a 4 Volt control input 314 Comments 1 Switching to the time varying Riccati based gain would improve the convergence rate Reducing the input penalty R2 exceeds the motor volt age for the initial startup so varying the gain near the desired tracking point would certainly be bene cial E0 The linear model works reasonably well for this controls system even away from its linearization point The closed loop linear system match with the nonlinear system is better than the corre sponding open loop comparison arm Figure 19 Controller Noise 10 9 Constraining the control gain by adding addi tional state penalties helped prevent overshoot and past topdeadcenter behavior 4 Output Feedback Output feedback creates a control signal based on measurable outputs This requires estimating states based on outputs that may not be clean signals A state observer is needed The Kalman observer gov erning equation is 3gt4 3 AiBuK0yici Where the gain is K SOT 51 Where E is found from the corresponding steady state Riccati equation A2 EAT Bu 5 B5 7 2019302 0 The outputs and measurements have White noise in tensities of 51 and SD The corresponding stochastic linear system is z39 A1 B u w y or Du v Where W is the control noise and v is the measurement noise 41 Measurement Equipment Measurement equipment for this project needs to be chosen and characterized This ballbeam system has 4 states 2 second order systems The measurement equipment needs to measure ball motion and gear motion From the problem statement7 the outputs are ball position r7 and gear angle 9 411 Gear Angle The gear angle 9 is measured With a rotary encoder on the DC motor The selected encoder is a Maxon MR type M 201937 Appendix D7 Which is a factory supported option for the Maxon motor The encoder gives 512 counts per turn at a sampling rate up to 320 kHz The encoderls angle error probability function is assumed to be at With a symmetric Width of revcount 7r512 With this assumption7 the vari ance is 2 2 7V2 av fd Where c is the number of counts So7 012 125510 5 The covariance function is assumed to be a symmetric triangle With height a2 and a encoder sampling time Width The encoder is capable of 320 kHz7 but for this project 100 Hz At 001 Will be used The White noise approximation intensity 1s 00 5v 0 03 At 700 So7 the White noise intensity is SD 126 10 7 412 Ball Position The ball location r is measured With an ultrasonic timeUf ight sensor as suggested The selected sen sor is a SICK UM 3013113 Data sheets are given in Appendix D Selecting a suitable ultrasonic sen sor was slightly troublesome for range and response time The selected sensor claims a 036mm resolu tion but With a 110 ms response time It is suggested to look in more depth for a better sensor technology for this ballbeam system Some laser sensors were especially tempting However7 the distance measur ing sensor for this project will be the above SICK ultrasonic sensor The process of converting the position measure ment system errors to a White noise is similar to the rotary encoderls The sensor claims a resolution of 000036 m7 but also states an accuracy of S 2 The noise estimation Will use a 1 resolution ibased on beam lengthi With a sampling time of 01 seconds so a2 gm 8310 6 and S1 8310 7 42 Validation Simulation The observer gains were calculated with the observerm script The noise intensities are those calculated above The observer gain is 10056 7000105 K 7 50559 7007408 07 700069 04042 70211 00816 For a step in ball location from 05 to 08 the ob server estimated the following states Figure 20 The measurements are noisy based on the resolution of the measurement systemi The observer appears to be working correctly arm Figure 20 Observer Step Output feedback with measurement and control noise is simulated in Figure 21 No large visible dif ferences could be seen between the output and state control laws The output feedback is more robust because it considers measurement and output noisesi 5 Conclusions The ballbeam system was investigated in this project A linear system state feedback control law and a output feedback control law were developed Both control laws stabilied the systemi The output feedback gives similar performance but is more ro busti Figure 21 Observer Step Comparison References l Erdman Al and Sandor Gr Mechanism De sign Analysis and Synthesis PrenticeHall Up per Saddle River NJ 3rd ed 1997 2 Moretti Pi Mi Modern Vibrations Primer CRC Press Boca Raton FL lst ed 2000 3 Burl Jr Linear Optimal Control Addison Wesley Longman Menlo Park CA lst ed 1999 4 Hagan Mi 5413 Optimal Control Notes77 Still water OK Spring 2004 eggs 9 if H E0 g APPENDICES Nomenclature Ball Mass 011 kg Ball Radius 0015 m Ball Rotational Inertia 999 10 6 kg m2 Ball Position from Beam Pivot m Beam Length 1 m Beam Mass kg Beam Inertia kg m2 Beam Angle Tad Lever Arm Length m Lever Arm Mass kg LeverArm Inertia kg m LeverArm Angle Tad 2 Gear Length 003 m Gear Mass kg Gear Arm Inertia kg m2 Servo Gear Angle Tad Gearbox Ratio Motor Torque N m Motor Inertia kg m2 Motor Ef ciency Gravitational Acceleration 981 m 3 1 Instructions for Simulating the BallBeam System Setup the simulation parameters execute the bbsetupm Matlab script The bbsetup le con tains the linkage motor and sensor speci ca tions Load the Simulink model load bbmd1 Trim the system with bbtrimm The control voltage offset is found by trimming the system at the particular initial conditions speci ed in the bbsetup le Linearize the system with 1inearizem This routine requires the sysidmodelmd1 simulink 533 007 to model which is an exact replication of the non linear model in bbmd1 The linearization is per formed about the set point speci ed in the bb setup le Linear state space matrices are stored in Alinear Blinear Warning The linear ma trices in the bbsetup le are not automatically changed when 1inearizem is run Set Simulink model switches All simulations are made with the same Simulink model Switches turn on or off the tracking signal controller noise and observer Start the Simulink model The animation auto matically brings up a new window Plot the state variables with plotterc m Synthesize a LQR controller with bblqr The linear system is speci ed in the bbsetup le The control penalty multiplier p must rst be speci ed at the command line Control gains are au tomatically loaded when the simulink model is run again Sythesize an observer with observer m Plot the observer states with plottero m C Matlab Programs This project used the Matlab codes given belowl C1 Setup le bbsetupm Setup Ball and Beam Clear all global g global RM J global L Mb Jb global A ML JL global cl MG JG global km ke RM JM GR eta global Kcontrol Initial Condition X00l0 0 0 0 5 0 0 theta thetadot r rdot Xlinoffset0l0 0 0 0 5 0 0 Xlin0X07Xlinoffset Linear System in H 0 1 0 0p 0 790169 714818 0g 0 0 0 1p 7020967 0 0 0g 7 Blin 0p 52 913gl 0p 0p l Clin l 0 0 Ogl 0 l 0 0g 0 0 1 0g 0 0 0 lg 7 Dlin0000 Control System Uoffset0l68772 Kcontrol3l5229 023233 766108 714586 SW0lOl4A2 Motor noise power SWtime0l006 Observer QuanAngle2l0pi512l0 QuanDist 0l361000l0 Kobserver 10056 700010507 59 70074048 700069212 04042 70211 0 081691 l C llTLZCll TUPET 268 Gravity g9i81 Ball Properties Gear Properties d0i03 MG9i020156E73 JG2i70605E760i002 Motor Properties Maxon REmax 21 GR53i0 Gear Ratio JMGEARBOX041000A0100i0100i0A71 kg m5 WOIOR2481000i0100i0100i0A71 kg m5 JMdMGEARBOXJMlViUIORGR MotorGearbox Inertia km3i211i01000i0GR Nmamp lt77 7062E75 oziinamp ke2970i0A71i0GR 60 02i0pi V srad lt77 2pi609610E75 mVrpm RM0 883 Ohms eta0i60 MotoriGearbox Torque Efficiency C2 Animation bbanimatem Animation Function for BalliBeam Project in 5415 Opt Control function sys7 x07 stir7 tsanimdemot7 x7 u7 flag7L7A7R7d7x0 Rewritten by Charles O Neill This file is based on aF ANZMDEYWO Sifunction animation demo for ECENAME 3725 Written by Jason Horn 113403 Revised 33104 7 F Declare global variable global Xbeam ybeam Xball yball Vball xgear ygear Xlever ylever XballWish Global variables for handles of drawings global beam ball gear lever spindle ballWish Global variable for the handle of the animation figure global AnimDemoFigure Set variables str and ts according to function specifications Strl tstime between samples start time Decreasing time between samples will slow the simulation down it runs too fast ts0110005 0 Ball Velocity due to gravity 777 off the beam Vball0 Check the value of flag if flag2 Update the actual angles from the states thetaul thetadotu2 thetadotdot0 alpha 7alphaclot 7betabetaclotfourbarJnotiontheta 7 thetaclot ru3 XballWishu5 Make sure correct figure is selected and bring it to the front if anyget07Chilcl1ren7 AnimDemoFigure set 07 7Cu1r1rentl3 irgu1re77 AnimDemoFigure if anygetgca7 7Chilcl1ren earn Calculate new coordinates for each figure Beam Xbeam ybeam 0 LCosalpha 0 Lsinalpha Ball if rlt0 rgt1 VballVbal17918ltsl Xballr yball nax71yballvball ts else Xballr yballrsinalphaRCosa1pha end Gear xgear17d17ddcostheta ygear70 2 70 2dsintheta Lever Arm Xleverxgear 2 Xbeam2 yleverygear 2 ybeam2 Set new coordinates for each figure and redraw Note Damper in Stretch was drawn as two pieces so each piece must be set Draw figures as one piece whenever possible to simplify set beam 7XData Xbeam 7YDateW ybeam setba11 7XData Xball 7YDateW yball setballwish 7XData Xballwish 7YData 70 03 setgear 7XData xgear 7YDateW ygear setlever 7XData Xlever 7YData ylever drawnow end end Specify sys according to sifunction specifications sysl elseif flag0 Initialization 7 setup figure create and draw base shapes alphaa1phadot betabetadotfourbarmotionX01 X02 Check for existing figure fig flagfigf1ag7AnimationDemoFigure7 0 If figure exists clear it if flag AnimDemoFigurefi g Cla reset If not create new figure AnimDemoFigurefigure end Set title of figure set AnimDemoFigure 7Name7 7BalliBeamcAnimation7 7NumberTitle7 7off H 7 Set properties and limits of the axes setgca7 7Visible 7 7off7 H 7D1raWMode777fast 7 7 XLim 702 1 2 7YLim 7 7104 Beam Xbeam0 139 ybeam0 039 Ball Xball X03 yball x03sinx01Rcosx01 Ball Wish XballwishX0 3 Gear Xgear17d 1 ygear70 2 702 angle0pi202pi xspindledcosanglexgear1 yspindledsinangleygear1 Lever Arm Xleverxgear 2 7Xbeam2 yleverygear 2 7ybeam2 Draw base shapes at initial positions hold on ba11plotxball 7 yball 7 7107 ballwishplotXballvvish7 7003 77 beamplotXbeam7 ybeam7 7k7 gearplotXgear7 ygear7 717 leverplotxlever7 ylever7 k7 7 spindleplotxspindle 7yspindle7 717 Draw Misc Visual Support Shapes plot 0770027 7197 Beam Rotation point Define sys and 960 according to Sifunction specification sys0 0 0 of inputs 0 0 1 sys0 0 0 5 0 01 KO end C3 Beam Motion fourbarm0ti0nm Motion Terms for a 4 bar function alpha 7alphadot 7beta 7 betadotfourbarmotiontheta 7 thetadot global A cl L Displacements alphaasindLsintheta betaasindAlicostheta Velocities alphadotdLcosthetathetadot7 betadotqlAsinthetathetadot7 return C4 Ball Governing Equation ddotrm function outputddotrtheta7 thetadot7 r7 rdot7 motor global g Jb L JMR cl alpha 7 alphadot 7beta 7 betadotfourbarmotion theta 7 thetadot 7 ifrltl ampamp rgt0 outputllr alphaclotA27M9 g9 SinalphaJRA2 M else output0 end return C5 Beam Governing Equation ddotthetam function thetadotdotddotthetatheta7 thetadot7 r7 rdot7 voltage global g global R global L global A global cl global km ke RM JM eta ifrgtl rlt0 alpha 7 alphadot 7beta 7 betadotf0urbarmotion theta 7 thetadot 7 Dynamic Terms JTJJbMrA2ML9 LA2dA2LA27 JTHETAJMJGJTC0SthetaA2JLdA2AA2sintheta A2 thetadotdoth96 sin 2 theta thetadot AZJTHE I AiJL96dA2AA296sin 2 theta thetadot AZJTHETAisiI Static Gravity Terms thetadotdotthetadotdoticosthetaMrdLd2MdMGd2gJTHETA7 Motor Terms ifvoltage 390 torquekmvoltageike96thetadotRMeta7 thetadotdotthetadotdottorqueJTHETA7 end return C6 Trim trimm Trim the system control voltage for gravity offset Trim X 0707075707 u 07 y 000 50 ix Don t fix any of the states iu Don t fix the input iy 17273747 Fix both output 1 and output 2 X7u7y7dx trim7sysidmodel77x7u7y7ix7iu7iy C7 Linearize linearizem Linearize o bbsetup uUoffset X0p07070o5707 Alinear 7 Blinear 7Clinear 7 Dlinearlinmod 7sysiclmoclel 7 7X0p7u C8 StateControl Plotter plottercm rows5 colsl subplotrows7cols 71 hold on plottime 7 states I 71 ylabel theta subplotrows7cols 72 hold on plottime 7 states I 72 ylabel dthetadt subplotrows7cols 73 hold on plottime 7 states I 73 ylabelCr subplotrows7cols 74 hold on plottime 7 states I 74 ylabelCdrdt subplotrows7cols 75 hold on plot time 7 control I 71 ylabelCV C9 Control Law Sythesis bblqrm LQR routine States Control R2rho QR Koontrol 7SS7EElq1r Alin 7Blin 7R17R2 C10 Control Law controllawm function voltagecont1rollawtheta7 thetadot7 1r7 Idol7 voltage global g global R global L global A global cl global km ke RM JM global Kcontrol voltage7Kcontroltheta thetadot r rdot 7 7 return C11 Control Law Sythesis observerm bblyap Control noise W W Measurement Ceffective10 0 0 0 0 1 0 l RR1l26E77 0 0 8 3E77 7 Control QQzBlinSWBlin 7 QR Kobserver 7SSS7EEElq1rAlin 7 7Ceffective 7 7QQ7RR Kobse1rve1rKobserver7 D Equipment Data Sheets
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'