ME461_Lab8-old - ME 461 Laboratory #8 System Identification...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ME 461 Laboratory #8 System Identification and Model-Based Control Design Goals: 1. 2. 3. 4. Perform data‐based system identification on the robot using least‐squares estimation. Use a discrete transfer function model of the robot to design and simulate a controller. Implement decoupled controllers on both motors on the robot. Implement a coupled controller to steer the robot. NOTE: From this point forward, you will be using 60% of the friction compensation you developed in Lab 7. This means you will need to identify the system and design and implement the controller while supplementing the control effort with 60% of the nominal value necessary to eliminate friction. Exercise 1: (20 points) In this exercise, you are going to perform system identification on one of the robots. The three‐ wheeled robots with friction compensation can be modeled as (linear) first‐order systems. In the continuous time domain, the transfer function that relates wheel velocity to control input is where τ is the time constant of the robot and K is the DC gain. We can discretize this system by assuming a piecewise constant input signal formed through zero‐order‐hold of a discrete‐time signal. This approach amounts to taking the z‐transform of the sampled unit pulse response of the continuous system. The formula for converting from a continuous transfer function to a discrete transfer function through ideal sampling and zero‐order‐hold D/A is G z 1 – z ‐1 Z { } ‐1 If we apply this result to the first‐order system above, we obtain the discrete transfer function of the robot. The corresponding difference equation is where and . We will now identify the two parameters c1 and c2 using least‐squares estimation. We write the difference equation as where and N is the number of measurements. Then, the least‐squares estimate for is given by We are going to excite the robot with a step input and record the resulting velocity trajectory in order to compute the unknown parameters. Modify your program from the previous lab to send the motors a step input. Once again, use a sample rate of 50ms and compute the average velocity of the robot at each step. Send the average velocity to the PC by calling UART_send at each sample. Wait several seconds after power‐up, and then send a command of 2.5 to both motors and begin sending the velocity to the PC. When 50 samples have been sent, send a command of 0 to both motors. Build and download your program. Start the VB serial application, choose File → Collect Data, and choose a storage directory and filename. The VB application should pend on the data from the microcontroller until 50 samples have been collected. Then the program will write the data to the text file you chose. Place your robot on the floor and turn it on. The robot should move for a few seconds and then stop. Check to see that the data file you specified has been created and that it contains the velocity data you sent. Show your TA. Use the partial code located on the course website to read the contents of the text file in MATLAB. Fill in the missing parts of the function to create the Φ matrix and the V vector. Use the fact that you know the control input was 2.5 from the first time instant recorded. Then, use Matlab’s backslash (\) operator to compute the least‐squares estimate. Type doc mldivide at the command line for help. When you have computed the unknown parameters, record them below. c1 = __________ c2 = __________ Also, fill in the code for generating the transfer function corresponding to these coefficients. View the theoretical and measured step responses that are produced. Check with your TA. Exercise 2: (30 points) Use MATLAB’s root locus tool to design a discrete PI controller for the robot. The controller will be of the form where e is the error signal and u is the control effort. Use the parameters that were determined in exercise 1 to write the discrete transfer function of the robot. Create the transfer function in MATLAB and call rltool with this transfer function as the argument. You should now see the root locus view of the SISO design tool. Complete the following to customize the tool for our task. 1. Choose “SISO Tool Preferences” from the “Edit” menu. Then, under the “Options” tab, choose a zero‐pole‐gain parameterization for the compensator. 2. View the “Architecture” tab of the “Control and Estimation Tools Manager” window. The compensator (red ‘C’ block) should be in the forward path as in the figure below. 3. Choose the “Compensator Editor” tab and add an integrator (real pole at z = 1) and real zero to the compensator by right‐clicking in the “Dynamics” pane. 4. In the “Analysis Plots” tab, choose “Step” for both Plot 1 and 2, and choose “Closed loop r to y” for plot 1 and “Closed loop r to u” for plot 2. We will use the step response characteristics and input magnitude to choose our gains Kp and Ki. You should know from homework 8 that we have freedom to move the compensator zero along the real axis in addition to tuning the loop gain. Iteratively move the compensator zero and the closed‐loop poles to achieve the following design objectives. • • • • Rise time (10%‐90%) of no more than 0.5 seconds Overshoot of no more than 5% Settling time (5%) not more than 1 second Magnitude of control effort does not exceed 2.5 When you are satisfied with the design of your controller, make note of the zero location and the loop gain. Use these values to determine Kp and Ki. Record them here: Kp = __________ Ki = __________ Exercise 3: (30 points) Implement the controller you designed on both motors of the robot. Use the following difference equations to form your control algorithm. (Tustin Rule) where for some reference signal r and wheel speed v. The block diagram for your system should resemble the following. e_1 Reference Velocity Kp left motor u_1 v_1 Friction Comp K T s (z+1) Ki 2(z-1) Integrator e_2 Kp right motor u_2 v_2 Friction Comp Ki K Ts (z+1) 2(z-1) Integrator Decoupled PI controller diagram The general algorithm will be: Set reference signal r Measure wheel speed v Compute error e = r – v Increment integral by Ts(e + eold)/2 Compute control effort u = Kp e + Ki i Store eold = e Implement the controller and check to see that the speed matches various setpoints in the range of ‐1.7 to 1.7 ft/sec. Demonstrate to your TA. It is necessary to note that integrators have “memory”, which means they are affected by past behavior. Give the robot a setpoint of 5 rad/s, then hold one of the wheels for a few seconds and release. Note the behavior. The wheel spins faster than the setpoint to “burn off” the extra integrated error accumulated while the wheel was being held. Such saturation of the control input causes what is called integral windup. To prevent this behavior we must implement an anti‐windup controller. One approach is to multiply the integral by a constant less than unity (e.g. 0.95) when the input is saturated to force a decay of the integral. As an alternative, we may implement the anti‐windup scheme depicted in the block diagram below. This scheme reduces the integral term based on the difference between the desired control input and the actual control input. The feedback approach is desirable because it trims the integral based on how much the input is saturated. The open‐loop approach may have less desirable transient behavior due to the fact that it doesn’t use the magnitude of the control input in the way it reduces the integral. e_1 u Kp Reference Velocity Friction Comp u_sat left motor v_1 Saturation K Ts (z+1) Ki 2(z-1) Integrator Ka Feedback anti‐windup scheme Implement one of these schemes on your robot. In your code, check to see whether the control input is saturated (has a magnitude greater than 10). If it does, trim the integral using one of the methods described above. Test the anti‐windup scheme by holding and releasing one of the wheels. The wheel speed should now match the setpoint after it is released without as much overshoot. Demonstrate to your TA. Exercise 4: (20 points) Implement a steering controller by coupling the motor control loops. Introduce a turn setpoint tref and form the turn error signal eturn = tref – (v2 – v1). You can see from this equation that the turn setpoint controls the amount by which one motor’s speed exceeds the other’s. Multiply the turn error by a gain Kturn and adjust the overall error signals as follows: The approach is depicted in the block diagram below. e_1 Reference Velocity Kp left motor u_1 v_1 Friction Comp K T s (z+1) Ki 2(z-1) Integrator Kp_turn e_turn Turn Command e_2 Kp right motor u_2 v _2 Friction Comp Ki K Ts (z+1) 2(z-1) Integrator Coupled PI control structure If we assume the steady‐state error goes to zero (due to the integrators), we arrive at the following conclusions: So the steering controller ensures that the average velocity tracks the reference and the turn command injects a difference in wheel speeds that is symmetric about the average velocity. Test your steering controller with several velocity and turn commands. Demonstrate to your TA. Extra material for the interested: (optional) Another possible control topology is shown below. This approach has the advantage of having fewer controller parameters (no Kturn) and a simpler overall structure. e_vel Reference Velocity u_vel Kp left motor v_1 .5 K Ts (z+1) Ki 2(z-1) Integrator e_turn Turn Command u_turn Kp Ki right motor v_2 K Ts (z+1) 2(z-1) Integrator Alternative steering controller We have defined two new state variables, the average velocity (v1 + v2)/ 2 and the difference in wheel speeds v2 – v1. Now we control these two variables directly with the velocity and turn commands. One disadvantage is that it is no longer obvious how to deal with integral windup due to the fact that each motor is affected by both integrators. Can you think of a scheme for limiting the values of the integrals under saturation conditions? Implement this controller and test the results. ...
View Full Document

Ask a homework question - tutors are online