Hi Muhammad,
I understand that you are observing negative gain and phase margins in the Bode plot of your identified plant model, even though the overall closed-loop system behaves as expected in simulation with a PI controller or an MPC.
From the Bode plot and model parameters, it appears that the estimated plant 'tfsys' is open-loop unstable, which is why MATLAB’s 'margin' function reports negative margins. However, this does not indicate that the closed-loop system is unstable rather, the 'margin' analysis applies to the plant alone, assuming unity feedback without any controller. Once the loop is closed using a PI or MPC controller, the system can indeed be stabilized.
Designing Controllers for Open-Loop Unstable Systems:
Both PI and MPC controllers are capable of stabilizing open-loop unstable systems, assuming the plant is controllable and the controller is tuned appropriately.
- PI Controller: You can use the pidtune function with your estimated transfer function to redesign or validate your PI controller:
C = pidtune(tfsys, 'PI');
margin(feedback(C*tfsys, 1));
- Model Predictive Control (MPC): If the system has multiple inputs/outputs or requires handling of input/state constraints, MPC is a good option. You can use the mpc object with the converted state-space model to design a controller:
(ss_model = tf2ss(tfsys));
mpcobj = mpc(ss_model, Ts);
For more information on adopting a MPC workflow in a control system, you can refer to the following documentation link:
Observer-Based Control:
If you’re using a Kalman filter in conjunction with MPC, it’s important to note that the Kalman filter estimates states and does not stabilize the system on its own.
MPC uses these estimates to compute the optimal control action, which can stabilize the system, even if it's open-loop unstable.
The observer should be designed such that unstable modes are detectable and that the combined observer-controller loop is stable.
Here are some steps you can follow to optimize the current workflow:
- Validate that your identified model 'tfsys' accurately captures the plant dynamics by comparing simulated and measured data.
- Wrap your controller (PI or MPC) around the estimated plant and verify closed-loop stability using 'margin' or 'pole(feedback(...))' functions.
- If you're using Simulink, you can consider using the PID Controller or MPC Controller block along with the State-Space block for implementation.
- Optionally, you can use 'looptune' if you're considering robust controller design with stability guarantees.
For more information regarding various functions mentioned in the above code snippet, you can refer to the following documentation links: