Project - Position control of mass spring damper system
Objective:
Derive the transfer function for a system comprising a mass-spring-damper setup and incorporate it into the model.
Integrate a PID controller into the system to dynamically regulate the force acting on the mass, ensuring its position accurately tracks a given reference signal.
Consider the parameters: mass (m) = 3.6 kg, spring constant (k) = 400 N/m, and damping coefficient (c) = 100 Ns/m.
Refer to the accompanying figure to visualize the reference signal.
- MATLAB SCRIPT:
MATLAB Script Explanation:
This script initiates the position control for a mass-spring-damper system. Key system parameters, including mass (m), spring constant (k), and damping coefficient (c), are initially defined. The design of the control system employs pole placement.
To facilitate the pole placement design, the script computes the desired frequency (fn) and natural frequency (wn) based on the system parameters. The state-space matrices A and B are then formulated according to the system equations.
Design specifications are established, incorporating the desired damping ratio (zeta). The desired pole locations (p1 and p2) are subsequently computed using the desired frequency and damping ratio.
The place function is employed to determine the control gains (K) by leveraging the system matrices (A and B) and the desired pole locations (p). The resulting control gains are further analyzed to extract the proportional gain (Kp), derivative gain (Kd), and integral gain (Ki).
While the integral gain (Ki) is explicitly set to 0 in this script, the overall configuration establishes a position control system for the mass-spring-damper system using the calculated control gains.
SIMULINK MODEL:
SIMULINK BLOCK:
- gain
- sum
- integrator
- scope
- pulse generator
- transfer function
- pid controller
- manual switch
RESULT:
Observation:
The Simulink block illustrated above is constructed using the specified Simulink blocks, representing a mass, spring, and damper system incorporating a PID controller.
The provided MATLAB code establishes a mass-spring-damper system and formulates a position control system utilizing pole placement. Control gains, including proportional, derivative, and integral, are determined based on desired pole locations, damping ratio, and system parameters.
After running the code, the model is executed, and the results are observed. In Fig 4, the input is depicted as a pulse wave with a 50% pulse width, lasting for 10 seconds with an amplitude of 1 (highlighted in red). The results in Fig 4 indicate that at Ki=500 (after manual testing within a range of 0 to 10000), the output exhibits the optimal response resembling an underdamped behavior (zeta=0.5, marked in magenta).
Fig 5 showcases the best underdamped response, achieved through tuning the PID controller block displayed in Fig 6, where Kp=715.8736, Ki=4565.4258, and Kd=15.8360.
A notable difference between using a PID controller mathematically (utilizing sum and gain blocks) and employing the inbuilt PID Controller block from the library is that the latter derives gain values such as Kp, Ki, and Kd from the output to achieve the best response. In contrast, the former method, where Kp and Kd values are predefined in the MATLAB code, allows for tuning only the Ki value. While the mathematical approach is less accurate, the inbuilt PID Controller block provides a technically more precise adjustment as it dynamically derives gain values for optimal performance.