8. Modeling and Simulation

Instructions and Problems
1. Physical Device and Testing
The goal of this section is to verify that the device has been built properly and operates as expected.
Demonstrate the you have a safe, working device. Provide proof (photos, screenshots, or a link to a video) that the device has been assembled and has passed each of the 4 tests.
Using the default PID controller gains, plot the device’s response to a step input of 0° along with the drive signal on the same figure. What do you observe about the response and how might it be improved?
Notes: If doing the DIY option, provide proof that the device has been assembled and has passed your own tests to ensure all sensors, actuators, and logging works properly. If doing the DIY option, choose an initial guess of PID gains and plot the device’s response to a baseline reference signal that is analogous to an input of 0° for the T-RECS.
2. Dynamics Modeling
The goal of this section is to derive a mathematical model for the system that can be used to simulate the device’s response and be compared to the actual, physical response.

Notation:
The mass of the motor is given by, moment of inertia of the system is given by
The frictional coefficient on the lever arm is given by
The thrust produced by the propeller is given by, whereis the angular velocity of the propeller andis a proportional coefficient:
Assumptions:
is linearly proportional to the drive signal,
The lever arm’s mass is negligible
Derive the equation of motion for the system shown in Figure 1 above. Be sure to note the assumptions and notation provided with the figure. Your equation should includeand its derivatives, accounting for damping due to the friction of the lever arm, and the drive signal input, . As a note, this system is nonlinear (with squares, sine/cosine, etc.)
Simplify the equation of motion by reducing it to standard form and replacing each term with a single coefficient. (That is, all the state terms on the left-hand side and the input on the right-hand side of the equation)
Note: If doing the DIY option, please provide a free body diagram and the equation(s) of motion specific to your system, if applicable. Provide as much detail as possible. Complete steps (1) and (2) above for your model.
3. Model Approximation
The goal of this section is to experimentally approximate the system’s particular model in order to overcome the nonlinearities and computationally test its response for the controller in the following section.
Determine a numerical value for the coefficient of theterm. Consider conducting a “drop test” experiment to solve for the coefficient. What constraints will help you to simplify and solve?
Determine a numerical value for the coefficient of theterm. Consider conducting a “hover test” experiment to solve for the coefficient. What constraints will help you to simplify and solve?
Determine a numerical value for the coefficient of theterm. Consider applying MATLAB’s ode45 tool to approximate the coefficient by testing various values. You may wish to use the data from the previous two experiments to verify your coefficient’s value.
Note: If doing the DIY option, you must derive the coefficients for your model however you see fit. Please record the test procedure as you will need the procedure and test data for your report. Provide as much detail as possible. Answer all questions for steps (1)-(3).
4. PID Controller Tuning, Testing, and Analysis
The goal of this section is to examine different types of controllers and analyze the importance of feedback control on stabilizing the system.

Write the equation for the error term,, in terms of the commanded signal,, and the current state,
4.1 Consider a Proportional Controller, or P Controller.
Write the equation for the input of the controller,, in terms of the proportional gain,, and error term,.
Choose a value for the controller gain and plot the simulated response using MATLAB’s ode45 function to a commanded signal of 0°.
Set the device’s gain to that value (make sure to set the integral and derivative gains to 0). Record the device’s response to a commanded signal of 0°. Plot this response on the same figure as the simulated response.
Repeat Steps 2) and 3) for two different values of the controller gain.
Was the system able to reach the desired signal in any of the three tests, why or why not?
What, if any, differences are there between the simulated response and the actual response? What factors may have caused this?
4.2 Consider a Proportional Derivative Controller, or PD Controller.
Write the equation for the input of the controller,, in terms of the proportional gain,, derivative gain,, and error term,.
Choose a value for each of the controller gains and plot the simulated response using MATLAB’s ode45 function to a commanded signal of 0°. Continue choosing values until the response has a nicely damped response.
Set the device’s gains to those values (make sure to set the integral gain to 0). Record the device’s response to a commanded signal of 0°. Plot this response on the same figure as the simulated response.
Repeat Steps 2) and 3) for two different sets of controller gains, aiming to improve upon the previous responses.
Was the system able to reach the desired signal in any of the three tests, why or why not?
What do you observe about the transient response? (That is, the portion between rest and stabilization).
4.3 Consider a Proportional Integral Derivative Controller, or PID Controller.
Write the equation for the input of the controller,, in terms of the proportional gain,, integral gain,, derivative gain,, and error term,.
Choose a value for each of the controller gains and plot the simulated response using MATLAB’s ode45 function to a commanded signal of 0°. Continue choosing values until the response has a smooth, short transient region and settles with low steady state error.
Choose a value for each of the controller gains and set the device’s gains to the appropriate values. Record the device’s response to a commanded signal of 0°. Plot this response on the same figure as the simulated response.
Repeat Steps 2) and 3) for two different sets of controller gains, aiming to improve upon the previous responses.
Was the system able to reach the desired signal in any of the three tests, why or why not?
Were you able to produce a set of gains that resulted in a response with minimal overshoot, quick rise time, quick settling time, and low steady state error? Why or why not?
4.4 Step Change Test.
Using the set of gains that produced the most satisfactory response, command the device to track a signal of 0°. After the device has stabilized, command it to track a signal of 15°. Record the response starting from when the device was hovering at 0°. (You do not need to plot a simulated response in MATLAB)
How is this response different from that of the previous section? Why is it different?
Note: If doing the DIY option, complete the same steps as above but with a baseline reference signal analogous to the 0° input for the T-RECS. For step 4.4, you should start the system at the baseline then move to another reference signal analogous to the 15° input for the T-RECS. Answer all questions for the steps above. Please provide as much detail as possible to explain how your answers and results for this section were obtained for your system.
5. Optimal Control using LQR
The goal of this section is to expose the students to one method of optimal control theory using a Linear Quadratic Regulator (LQR). Many complex control problems require the use of optimization to determine satisfactory gains and this section serves to introduce these advanced concepts.
5.1: Construct a state-space model of the system using the original model derived in Section 2, step 2. You will need to linearize the system aroundin order to simplify the result. Recall the structure of the state-space representation is:
The LQR algorithm is a process involving a state “weight” matrix, Q and an input “weight” matrix, R. We will begin by analyzing the LQR’s application to a PD controller. Since this system has 2 states:and, the Q matrix will be a 2x2 diagonal matrix with each component representing the “weight” or importance of the corresponding state. Since this system has 1 input,, the R matrix will be 1x1 (scalar) with the value representing the “weight” or importance of the input.
5.2: Begin with an identity matrix for each and use MATLAB’s lqr function to compute the optimum PD gains. Using those gains, plot the simulated and actual response to a commanded input of 0°. How did this controller compare to the gains you tested earlier?
Now we will move onto the LQR+I algorithm which applies the same idea to a PID controller by adding a new state,, which represents the integral of.
5.3: Modify your state-space model to include, which should only involve the addition of one more row to the A and B matrices.
5.4: Repeat the same procedure as in 5.2 except using the PID controller. How did this controller compare to the gains you tested earlier? Were you able to safely test the device using the computed PID gains?
Note: If doing the DIY option, complete the same steps as above but with a baseline reference signal analogous to the 0° input for the T-RECS. Answer all questions for the steps above. Please provide as much detail as possible to explain how your answers and results for this section were obtained for your system.
Extra Credit: Online Auto-Tuning of PID Controllers
The goal of this section is to provide the students with an opportunity to explore machine learning in control system applications to earn extra credit on their overall project. Many systems operate in unknown environments so it is crucial for the system to adapt in real time, or “online,” and this learning process can be incorporated into PID control.
Read through the attached paper, “Online Optimal Auto-Tuning of PID Controllers for Tracking in a Special Class of Linear Systems” by M. Miranda and K. Vamvoudakis.
Plan an approach to incorporating the methods introduced in the paper into your device. Briefly describe your approach as to how your device, model, and/or code will apply these methods. (This may include equations, citations from the paper, pseudocode, figures, etc.)
Prepare some evidence of these methods being applied on your device. (This may include plots, tables, videos, pictures, code snippets, etc.). Briefly discuss your results and findings.
Last updated
Was this helpful?