0138 Experiment #1 2-DOF Helicopter experiment: State space representation 1 Requirements Students are required to prepare the theoretical developments and to perform the necessary simulations before coming to the Lab. 2 Introduction The Two Rotor MIMO System (TRMS) sown in Figure 1 is a laboratory set-up designed for control experiments. In certain aspects its behaviour resembles that of a helicopter. From the control point of view it exemplifies a high order non-linear system with significant crosscouplings. Figure 1: TRMS apparatus 1 3 System Description The TRMS 33-007-PCI shown in Figure 1 and Figure 2 is an aero-dynamical system similar to a helicopter. At both ends of a beam, pivoting on its base, there are two propellers driven by DC-motors. The articulated joint allows the beam to rotate in such a way that its ends move on spherical surfaces. There is a counter-weight fixed to the beam and it determines a stable equilibrium position. The system is balanced in such a way, that when the motors are switched off, the main rotor end of beam is lowered. The TRMS 33-007-PCI is a Twin Rotor Multi-Input Multi-Output System manufactured by Feedback Inc. The TRMS consists of a beam that is free to rotate in two planes, with two rotors attached on each end, and is fixed to a tower that sits on a base, which houses the power routing and data processing units for the TRMS. The TRMS is a two- input-two output system. The two inputs are the input voltages to the two rotors. The two outputs are the two angular positions of the beam “pitch” and “yaw”. The pitch and yaw angles are sensed by two encoders attached to the tower and the pivot unit which holds the rotating beam. A counterweight beam is attached to the pivot unit, perpendicular to the rotating beam. A counterweight is attached to the counterweight beam, and its position is adjustable to configure the resting position of the TRMS. The system is equipped with two locking bolts to prevent the pitch or the yaw motion when needed. One is located on the pivot unit for locking the pitch motion, while the other is located on the tower for locking the yaw motion. Figure 2: TRMS Components 4 Data Processing and Controller Implementation The angles recorded by the encoders are converted to 16-bit words by an internal ADC of the TRMS. The converted signals are acquired by an Advantech PCI-1711 data acqui2 sition board (DAQ) at a sampling frequency of 1kHz. The data is sent to the DAQ over two 8 bit channels; therefore latching over two sampling periods is required to obtain the two 16-bit words for the pitch and yaw measurements, resulting in an actual sampling frequency of 500Hz. The 16-bit words are converted to binary and finally decimal values on a PC for controllers to use. The control signals generated by the controllers are also sent to the DAQ, which sends the signals to TRMS onboard DAC, which converts them to voltages and supplies them to the motors. In this experiment, the PC CPU is used as the real-time processor for the TRMS. A MATLAB toolbox called Real Time Windows Target includes the Real Time Kernel (RTK) protocol that allows the PC to run Simulink models in real-time. The controllers for the TRMS can be defined in Simulink and implemented directly through external mode simulations. This method simplifies the implementation of controllers, and removes the requirement of an onboard microcontroller for the TRMS. The software provided by the supplier (Feedback Inc.) includes Simulink models with blocks that handle the data communication and conversion procedures in conjunction with the RTK. The models are intended to work with MATLAB 2006b and later, and require Simulink and Real Time Windows Target toolbox. One block named Feedback Encoder hosts the latching protocols and the data conversion functions that are required to obtain measurement data from the TRMS. One block named Feedback DAC is responsible for commanding the DAQ to send out control signals to the DAC, and it contains saturation limit blocks to ensure that the control signals sent to the dc motors do not exceed the maximum voltages of 2.5V for the motors. The sensors are the encoders on the TRMS, the actuators are the motors, and the PC acts as the processing unit for implementing controllers. The overal closed loop architecture is shown in Figure 3 Figure 3: Overall Control Scheme and Signal Routing 5 Safety Considerations The rotor blades of the TRMS are guarded by rotor shields. However, the shields are hollow on the top and bottom. Care must be taken not to touch the rotors or the rotor 3 shields when the blades are spinning. Any person using the apparatus should stay within a safe range from the TRMS to avoid any contact with system in case something goes wrong. The electrical components of the TRMS are mostly encased, except the motors which have solder joints exposed. The input voltages to the motors are at max 2.5V and with a presumably very small nominal current. However, as a precaution measure, there should be no direct work to the motors or the rotors while the master power is on. This also prevents one from being injured by the rotor blade spinning unexpectedly. 6 Mathematical model As the beam pivot is fixed to the tower, the TRMS does not allow elevating motion. The beam is also locked such that there is no rolling motion, thus making the TRMS a 2DOF (degree-of-freedom) system. The system is inherently nonlinear, due to the nonlinearities in aerodynamics and rotational motion. The system also has significant coupling effects between the two degrees of freedom (pitch and yaw). Using the fundamental laws of dynamics, the DC-motors characteristics and the rotor aerodynamics, the nonlinear mathematical model of the TRMS is obtained and then linearized about the operating point θy = 0, θp = 0, θ̇y = 0, θ̇p = 0 to obtain the following linear (approximating) system: θ̈p = −0.2211θ̇p − 4.2171θp + 1.6348ωp + 0.0510ωy , (1) θ̈y = −0.3846θ̇y − 0.4846θy + 0.1467ωp + 0.8005ωy , where θp is the pitch angle and θy is the yaw angle. The angular velocities of the main rotor and the tail rotor are denoted, respectively, by ωp and ωy , and they are related to the motors voltage through the following differential equation: ω̇p = −0.8333ωp + 0.9167up, ω̇y = −1.2500ωy + 1.2500uy , (2) where the control inputs up and uy are the voltages applied, respectively, to the main and tail rotors. 7 State Space Representation The system inputs are up and uy , and the system outputs are θp and θy . Question 1: Obtain a state space representation of the system under consideration: ẋ(t) = Ax(t) + Bu(t), y(t) = Cx(t) + Du(t), 4 (3) where y = [θp , θy ]T , u = [up , uy ]T and x = [θp , θ̇p , θy , θ̇y , ωp , ωy ] Question 2: Check the controllability and observability of the system using Matlab commands. Question 3: Using the pole placement command in Matlab, design a state feedback controller plus integrator of the form u = [up , uy ]T = −Kx − KI eI with Rt d (θ − θ )dt p p eI = R0t d (θ − θy )dt 0 y such that the eigenvalues of the closed-loop system are: Ed = [−2; −2; −2.1; −2.1; −2.2; −2.2; −2.3; −2.3] Design Procedure: Form the following matrices: As = [A zeros(6, 2); −C zeros(2, 2)] and Bs = [B; zeros(2, 2)]. Let Ks = [K, KI ], where K is a 2 × 6 matrix and KI is a 2 × 2 matrix. Use the pole placement command in Matlab to design Ks such that the eigenvalues of As − Bs Ks are equal to the desired eigenvalues Ed . • Using the command “step” in Matlab, plot the step response of the following system: G(s) = (s + 2)2 (s 451.6475 + 2.1)2 (s + 2.2)2 (s + 2.3)2 • Noting that the poles of G(s) are actually the desired closed-loop eigenvalues, what settling time and overshoot we are aiming to achieve through this design? • Test your state feedback in Simulink. • Try different designs by modifying the desired closed loop eigenvalues Ed and simulate the resulting controller. Compare the different results in term of performance. • Build a Simulink block diagram that generates the control inputs [up , uy ]T = −Kx − KI eI , from the measurements θp and θy . The Lab instructor will provide you with input/output blocks for real-time implementation. Note that, in the real time implementation, the only state variables that are measured are θp and θy . The state variables θ̇p and θ̇y are obtained using filtered s s derivatives, i.e., θ̇p ≈ 0.01s+1 θp , and θ̇y ≈ 0.01s+1 θy . The state variables ωp and ωy 0.9167 1.25 uy . are obtained from (2) as follows: ωp = s+0.8333 up and ωy = s+1.25 5 • Implement your controllers in real-time on the Helicopter. Make sure to implement only the controllers that perform well in simulations. Question 4: Using the Linear Quadratic Regulator (LQR) approach, design a state feedback u = −Kx − KI eI . Use the “lqr” command in Matlab, i.e., Ks = lqr(As , Bs , Q, R). • Start with the following weighting matrices Q = eye(8) and R = eye(2). Design the state feedback gain Ks and test the controller by simulation. Implement the controller in real-time on the Helicopter. Conclusions? • Change the values of the weighting matrices Q and R, redesign Ks and simulate again. If the simulation results are satisfactory, implement the controller on the Helicopter. Repeat this procedure for different values of Q and R. • What are the closed loop eigenvalues, i.e., eigenvalues of (As − Bs Ks ), obtained with your best control gain Ks . What kind of performance (in terms of settling time and overshoot) is induced by the location of the obtained closed-loop eigenvalues? Is this performance achieved on the real experiment or not? What is your conclusion? Guidelines: If the response is fast, increase the elements of R to slow it down. If the response is slow, decrease the elements of R. Increasing the elements of Q will increase the speed of the system’s response. 6 0138 Experiment #2 State feedback control of an inverted pendulum on a cart 1 Requirements Students are required to prepare the theoretical developments (control design) and to perform the necessary simulations before coming to the Lab. 2 Introduction The aim of this Lab is to design and implement state feedback controllers for position and attitude control of an inverted pendulum on a cart. The control design will be performed using the pole placement method and the LQR approach. The designed controllers are first tested by simulation using MATLAB/SIMULINK and then applied to the physical system. 3 Equipments The system under consideration consists of an inverted pendulum (aluminum rod) mounted on a cart driven by a DC-motor on a linear track. The voltage applied to the DC-motor (u) will be the unique control input of the system. The linear position of the cart (x) and the angular position of the rod (θ) are the outputs to be controlled. These two outputs are measured using two potentiometers and fed-back to the ADC inputs of the data acquisition board ADIO 1600. At each sampling-time, the control software in your computer takes this values through a low pass digital filter to eliminate eventual measurement noise and evaluate numerically the time-derivatives of the two outputs ẋ and θ̇ to generate the complete state vector X = (θ, θ̇, x, ẋ)T . This state vector will be used to generate the control input u(t) = −KX(t) (the control gain K must be designed and introduced in the interfacing software). The control signal u(t) 1 is sent to the DAC output of the data acquisition board. This signal is then taken to a power operational amplifier with a unity gain (to generate the necessary current to drive the DC-motor) and the resulting signal is finally used to fed the DC-motor. 4 Mathematical model Figure 1: Inverted pendulum on a cart As demonstrated in class, the linearized model about the vertical position of the inverted pendulum is given by (M + m)ẍ + mlθ̈ = F, (1) (I + ml2 )θ̈ + mlẍ − mglθ = 0. (2) Where M is the mass of the cart, m is the mass of the rod, I is the moment of inertia of the rod with respect to its center of mass and l is the distance from each end of the 2 rod to the center of mass. In order to obtain the expression of the force F in terms of the voltage u applied to the motor we need the following equations: First, assuming negligible armature inductance, we have u = RA IA + Km ωm , (3) where RA is the armature resistance, IA the armature current, Km is the motor torque constant and ωm the motor speed. The torque produced at the motor shaft is given by τm = Km IA , (4) which after the built-in gearbox becomes the output torque τ = Kg τm = Km kg IA , (5) where Kg is the gear ratio. The motor speed ωm and the speed after the built-in gearbox ωg are related by ω m = Kg ω g . (6) Furthermore, we can relate the linear velocity ẋ to ωg and the radius r of the outside gear as follows ẋ (7) ωg = . r From (6) and (7), one has ẋ ω m = Kg . (8) r We know also that τ F = , (9) r From (5) and (9), one has Fr . (10) IA = K g Km Now, substituting (8) an (10) into (3) we obtain the expression of the force F applied to the cart as follows 2 Kg2 Km Kg K m u− 2 ẋ, (11) F = rRA r RA Substituting (11) into (1), we get 2 Kg2 Km Kg K m (M + m)ẍ + mlθ̈ + 2 ẋ = u. r RA rRA 3 (12) Now, taking X = (θ, θ̇, x, ẋ)T as a state vector and using equations (2) and (12), we obtain the following state space representation Ẋ = AX + Bu, y = CX (13) where A= 0 (M + m)gml (M + m)I + mMl2 0 −gm2 l2 (M + m)I + mMl2 1 0 0 2 Kg2 Km ml 0 0 2 r RA (MI + mI + mMl2 ) 0 0 1 2 2 −l2 mKg2 Km − IKg2 Km 0 0 2 r RA (MI + mI + mMl2 ) ml2 Kg Km r + Kg Km Ir −Kg Km ml , 0, B = 0, rRA (MI + mI + mMl2 ) r 2 RA (MI + mI + mMl2 ) C= 1 0 0 0 0 0 1 0 T . The parameters of our system are given by: M = 0.455 Kg, m = 0.210 kg, l = 0.305 m, r = 0.00645 m, Kg = 3.7, Km = 0.00767, RA = 2.6 Ω, g = 9.81 and I ≈ 0.0065 Kgm2 . Using the previous parameters we get 0 31.628 A= 0 −3.046 1 0 0 0 0 0 0 36.098 0 1 0 −14.673 and B = [0, −8.204, 0, 3.335]T 5 Simulation and experimental work 1. We would like to stabilize the pendulum at θ = 0 and the cart at x = xd using the control law Z t u(t) = −KX(t) + KI (xd (τ ) − x(τ ))dτ. 0 4 a) Design the state feedback gain K and the integration gain KI , using the pole placement and LQR methods. For the LQR approach, take different values for R and Q. Start with R = 0.01 and Q= 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 b) Simulate your controllers on SIMULINK using the nonlinear model of the pendulum starting from an angle close to zero and a cart-position close to the desired position. Introduce a small vanishing disturbance on the angular position and plot the time-evolution of your outputs. Discuss your results and provide the plots of your simulations. c) Turn ON the power supply and select “State Space Controller” in your software. Select your best controllers and implement your gains K and KI on the real system. Move your cart to the desired position and put the rod at the vertical position (refer to the software animation for the initial positioning of your system). The software will turn ON your controller once the angle θ and the cart-position error (xd − x) are small enough. Since the mathematical model does not perfectly describe the physical system (e.g., the frictions are neglected) you might have to tune a little bit your theoretical parameters to improve the performance of your real system. Once the pendulum stabilized at the vertical position, you can introduce a small angular disturbance by pushing the rod. You can also modify the position set-point in real-time from your interfacing software. In your final report, give the best set of your control parameters with regards to stability, disturbance rejection, steady state error and tracking performance. 2. a) Determine the discrete-time state space representation for the system under consideration with a sampling period of 2ms. b) Design a state feedback controller of the form u(k) = −KX(k) using the LQR method, to stabilize the system at θ = 0 and x = 0. c) Test your controller by simulation. d) Implement your controller on the real-time system. In your final report, provide simulation and experimental plots. 5