PID Project 2

docx

School

University of Massachusetts, Lowell *

*We aren’t endorsed by this school

Course

3230

Subject

Mechanical Engineering

Date

Oct 30, 2023

Type

docx

Pages

12

Uploaded by SargentSalmon3364

Report
Project 2: The Inverted Pendulum The main purpose of this project was to be able to tune a system that is made up of a small robotic puck with two wheels and a balanced inverted pendulum. The given parameters consist of the mass of the pendulum (m = 50 g), the length of the pendulum (l = 0.08 m), and the mass of the e-puck robot (M = 160 g). It is also known that the robot encounters an ever increasing pulsed force every 5 seconds and must stabilize in order to keep the pendulum upright. The project is broken down into four parts in order to derive the equations of motion for the system, set up the transfer function in Simulink, tune the PID in Simulink for the system, and test the simulated PID results by means of using the Robot Benchmark tool. In order to begin the setup of the equations of motion, a proper analysis of the system must be performed (Figure 1). From the FBD, the forces and variables were derived for each part of the system, allowing for the creation of the force equations for the e-Puck robot and the inverted pendulum. Equations were then combined, and the proper assumptions and substitutions were made for the approximations, resulting in EQs 10 and 11. Next came the transfer function of the system, which was found from converting the previously derived equations. Once again, more equations were derived, allowing for the substitution of previously unknown variables. After canceling the pole and the zero at the origin, the equations were found for both the pendulum and the e-Puck robot, which then needed to be implemented into MATLAB. The MATLAB code for the transfer function and for the state-space representation was derived, keeping in mind the given parameters (Appendix). Once the MATLAB code was set up, Simulink was used to model the system, keeping in mind that the goal is 0. The closed loop control block diagram (Figure 2) of the inverted pendulum robot was formulated (including the addition of a disturbance force to properly test the model), which mainly served to simulate output responses based on the implemented equations and parameters for Kp, Ki, and Kd. A value of 0.1 N/m/s was used for the coefficient of friction for the e-Puck robot and a value of 0.006 kg.m^2 was used for the mass moment of inertia of the pendulum. Many different combinations were tested to properly observe, analyze, and understand the entire trend of system stability. Now the PID for the system needed to be tuned using the previously designed model. Slight adjustments were made to the model, allowing for the implementation of the PID controller. Again, the main goal was to zero out the derivatives and analyze any graphs produced until a desired outcome is reached. Most of the codes were tested in regular MATLAB, producing graphs that ultimately showed the responses of the pendulum position to an impulse disturbance under PID control for different Kp, Ki, and Kd values (Figures 3, 4, and 5). From Figure 3, it can be observed that the response isn’t stable. This would require modification of the response, so the proportional gain was increased (Kp = 100) to see what would happen. From Figure 4, it can be observed that an improved graph was produced due to the change of the proportional gain. The setting time turned out to be less than the required time. It can also be confirmed that the steady-state error approaches zero in a very efficient and fast manner. Therefore, the 1
Kp value works out for the system, meaning that an additional integral action is unnecessary. However, the peak response still needed an adjustment since it turned out to be far larger than the required amount. This can be reduced by adjusting the derivative gain. From there, more trial and error took place in order to produce improved response results. It was found that the derivative gain needed to be increased (Kd = 20). From Figure 5, it can be noted that the reduction was successful, seeing as the peak response is far less than what it was before. Upon inspecting the design requirements, it can be concluded that they have been achieved, meaning that no other change needs to be made for the values of Kp, Ki, and Kd for the pendulum. The analysis of the e-Puck robot still needed to be performed. More codes were tested in MATLAB (similar to what was done for the pendulum) in order to produce the most accurate graph that ultimately showed the responses of the e-Puck robot position to an impulse disturbance under PID control for the same Kp, Ki, and Kd values as the pendulum (Figure 6). From Figure 6, it can be observed that the e-Puck robot’s position changes, moving in the negative direction while maintaining a constant velocity. From this, it can also be noted that the pendulum angle is stabilized due to the PID controller. With the given parameters and with all other requirements met, the system can be simulated. The Simulink models were updated to portray the nonlinear closed-loop system with reference input of pendulum position and a disturbance force applied to the e-Puck robot. Upon starting the simulation, the response was produced (Figure 7), detailing a very smooth plot. From this, it can be confirmed the values for the PID controller are fairly accurate and work for the inverted pendulum, where Kp = 100, Ki = 0, and Kd = 20. After completing the simulation for the PID in MATLAB, values were to be implemented and tested using the Robot Benchmark tool. This tool mainly serves to represent the situation similar to what was found in MATLAB. In order to achieve this, however, certain values need to be specified and certain gains need to be iterated in order to obtain satisfactory results. Upon attempting to start up the Robot Benchmark, the website failed to work. Despite giving it time to be fixed, the website was still down even after a few days. Unfortunately, this would mean that no results could be obtained from the Robot Benchmark tool for the PID. In conclusion, based on the data obtained from MATLAB Simulink, the PID values for Kp (100), Ki (0), and Kd (20) were accurate to the inverted pendulum situation. Unlike MATLAB, the Robot Benchmark tool was unable to be used to test the PID simulation. Luckily, this doesn’t mess with anything in terms of data since the tool only served as a way to visualize what was developed in MATLAB, so it was supposed to be used as a check. Even without the tool, it can still be concluded that the results of the PID are satisfactory since the data it portrays represents the situation quite well. The only parts of the problem that would’ve been pretty essential to visualize were the many forces that are involved within the inverted pendulum system. Results can definitely be more accurate if these forces and other factors were more properly analyzed and visualized. 2
Appendix The inverted pendulum problem is a classic model used in control theory to demonstrate how a system can use a simple controller to handle complex dynamics. For many early controls engineers this is a fundamental benchmark for your skills in stabilizing a system, and the tuning and control of such a system is a great way of demonstrating mastery in controller design. The system we are going to use for this class is the Robot Benchmark tool developed for WeBots. The system you are tuning consists of a small robotic puck (A mouse robot with two wheels) and a balanced inverted pendulum with the following characteristics: mass of the pendulum: m=50 gm=50 g length of the pendulum: l=0.08 ml=0.08 m mass of the e-puck robot: M=160 g Figure 1: e-Puck Robot and Inverted Pendulum Every 5 seconds the robot encounters an ever increasing pulsed forced and must stabilize to keep the pendulum upright. You must do the following. 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Figure 1: FBD of e-Puck robot and inverted pendulum system. 1. Create the equations of motion for this system. Sum of forces of the e-Puck robot (Horizontal Direction): EQ 1: Mẍ + bẋ + N = F Sum of forces of the pendulum (Horizontal Direction): EQ 2: N = mẍ + ml cos 𝜃 - ml sin 𝜃 Substituting into EQ 1: EQ 3 : (M + m)ẍ + bẋ + ml cos 𝜃 - ml sin 𝜃 = F Sum of forces that are perpendicular to the pendulum: EQ 4: Psin 𝜃 + Ncos 𝜃 – mgsin 𝜃 = ml + mẍcos 𝜃 Upon summing the Moments about the Centroid: EQ 5: -Plsin 𝜃 – Nlcos 𝜃 = I Combining EQ 4 and 5: EQ 6 : (I + ml 2 ) + mglsin 𝜃 = -mlẍcos 𝜃 4
From equilibrium, presuming a small deviation (ɸ): EQ 7: cos 𝜃 = cos( π + ɸ) -1 EQ 8: sin 𝜃 = sin( π + ɸ) EQ 9: = 0 After substituting the approximated values into the nonlinear governing EQ’s and substituting F for u: EQ 10: (I + ml 2 ) - mglɸ = mlẍ EQ 11: (M + m)ẍ + bẋ - ml = u 5
2. Convert these equations of motion to a transfer function and model this system in Simulink (Remember the goal is 0 not a step!). You will need to include a disturbance force to test your model. EQ 12: (I + ml 2 ) (s)s 2 - mgl (s) = mlX(s)s 2 EQ 13: (M + m)X(s)s 2 + bX(s)s - ml (s)s 2 = U(s) Solving for X(s): EQ 14: X(s) = [ I + ml 2 ml g s 2 ] (s) Substituting into EQ 13: EQ 15: (M + m) [ I + ml 2 ml g s 2 ] (s)s 2 + b [ I + ml 2 ml g s 2 ] (s)s - ml (s)s 2 = U(s) EQ 16: EQ 17: q = [(M + m)(I + ml 2 ) - (ml) 2 ] Upon canceling the pole and the zero at the origin: EQ 18: P pend (s) = [rad/N] The transfer function with X(s) can be derived in a similar manner: EQ 19: P ePuck (s) = X ( s ) U ( s ) = ( I + m l 2 ) s 2 gml q s 4 + b ( I + m l 2 ) q s 3 ( M + m ) mgl q s 2 bmgl q s [m/N] 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
MATLAB: Transfer Function: M = .160; m = 0.050; b = 0.1; I = 0.006; g = 9.8; l = 0.08 q = (M+m)*(I+m*l^2)-(m*l)^2; s = tf( 's' ); P_ePuck = (((I+m*l^2)/q)*s^2 - (m*g*l/q))/(s^4 + (b*(I + m*l^2))*s^3/q - ((M + m)*m*g*l)*s^2/q - b*m*g*l*s/q); P_pend = (m*l*s/q)/(s^3 + (b*(I + m*l^2))*s^2/q - ((M + m)*m*g*l)*s/q - b*m*g*l/q); sys_tf = [P_ePuck ; P_pend]; inputs = { 'u' }; outputs = { 'x' ; 'phi' }; set(sys_tf, 'InputName' ,inputs) set(sys_tf, 'OutputName' ,outputs) sys_tf State-Space: M = .160; 7
m = 0.050; b = 0.1; I = 0.006; g = 9.8; l = 0.08; p = I*(M+m)+M*m*l^2; %denominator for the A and B matrices A = [0 1 0 0; 0 -(I+m*l^2)*b/p (m^2*g*l^2)/p 0; 0 0 0 1; 0 -(m*l*b)/p m*g*l*(M+m)/p 0]; B = [ 0; (I+m*l^2)/p; 0; m*l/p]; C = [1 0 0 0; 0 0 1 0]; D = [0; 0]; states = { 'x' 'x_dot' 'phi' 'phi_dot' }; inputs = { 'u' }; outputs = { 'x' ; 'phi' }; sys_ss = ss(A,B,C,D, 'statename' ,states, 'inputname' ,inputs, 'outputname' ,outputs) State-Space Model in Transfer Function Form: sys_tf = tf(sys_ss) 8
Figure 2: Simulink Model for the System. 9
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
3. Using the model, you designed in Simulink, attempt to tune the PID for this system. Figure 3: Pendulum Position Response to Impulse Disturbance for PID values (Kp = 0, Ki = 0, Kd = 0). Figure 4: Pendulum Position Response to Impulse Disturbance for PID values (Kp = 100, Ki = 0, Kd = 0). 10
Figure 5: Pendulum Position Response to Impulse Disturbance for PID values (Kp = 100, Ki = 0, Kd = 20). Figure 6: e-Puck Position Response to Impulse Disturbance for PID values (Kp = 100, Ki = 0, Kd = 20). 11
Figure 7: Final results for the closed-loop response of the Inverted Pendulum PID controller (for 2.5 seconds). 4. Using the Robot Benchmark tool test your simulated PID. As a note, forces that are not known to you are present in this model. You may need to iterate on your gains to obtain satisfactory results. Website was down upon attempting to use it. No visualization data could be obtained. 5. Prepare a short (2 pages without appendix) report detailing both each of these steps as well as the values for your P I and D controller (and the response in both simulation and in the benchmark tool) (See at the beginning of the document). 12
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: Find all solutions of the equation in the interval [0, 2π). (Enter your answers as a comma-separated…
Q: b. f(x) = x¹ + x² +1, a = −2
Q: "The less we allow ourselves to be touched by life's full array of experiences, the less life…
Q: Which areas of the body are the most sensitive to touch? Least? Relate the size of the two-point…
Q: An observer at a fixed distance from a light bulb measures the light intensity at her location to be…
Q: What amount of liquid is in this graduated cylinder? 9 ) 1.25 ml b) 8.7 ml c) 8.75 ml d) 9.25 ml…
Q: A random variable is not normally distributed, but it is mound shaped. It has a mean of 15 and a…
Q: Find an equation of the tangent plane to the given surface at the specified point. z = 6(x − 1)2 +…
Q: "One similarity in the leadership of Latin Americas Jose de San Martin, Toussaint l Ouverture,…
Q: The following data is provided for Garcon Company and Pepper Company for the year ended December 31.…
Q: 22.) Determine if the graph of the relations below are symmetric w/ respect to a) the x-axis, b.)…
Q: A baseball player has a batting average of 0.36. What is the probability that he has exactly 4 hits…
Q: A car rental company only offers executive and standard cars. An executive car is priced at $130…
Q: During one shift, the express lane clerk recorded how many times customers violated the "10 items or…
Q: which methods have you seen used effectively by teachers in your own school career?
Q: nge in inventories. an unplanned
Q: Find the average value fave of the function f on the given interval. f(x) = 3x2 + 8x,    [−1, 5]
Q: Let f(x) be given by f(x) = x + sin x which is defined on [0,2π]. a. Find all exact values of x for…
Q: A proton, traveling with a velocity of 6.3 x 10° m/s due east, experiences a magnetic force that has…
Q: 17. If the following equations are not balanced, please balance them: Br₂ ( a. K b. CaBr₂ + + Cl₂…
Q: Verify that Strokes' Theorem is true for the given vector field F and surface S. F(x, y, z) = yi +…
Q: About the area under the curve of the standard normal distribution is between z = 1.34 and z = 1.34…