# Two Mass Spring System PID Control

3 views (last 30 days)
J. van Delft on 12 Mar 2015
Commented: J. van Delft on 13 Mar 2015
I have a system consisting of two bodies (It and Ic) connected by a rotational spring (constant k). Control is placed on the second body Ic. The state vector consists of the angles and angular rates of the bodies wrt an inertial frame.
It = 1000;
Ic = 10;
k = 1;
A = [0 0 1 0;
0 0 0 1;
-k/It k/It 0 0;
k/Ic -k/Ic 0 0];
B = [0;0;0;1/Ic];
I want to control the angle between the two bodies (it has to be reduced to zero) using PID control. I have full state output available.
Now, the pid-function in Matlab only works on SISO systems. Would it be an idea to modify the output to be just a single output y = [1 -1 0 0]'? And feed this into the PID controller as the error? Or are there other options to make this multiple output system work with the pid controller function in Matlab?
(I want to avoid using Simulink)

Sebastian Castro on 13 Mar 2015
You could do many things to address this:
• As you said, use a different output matrix like [1 -1 0 0]. This may work depending on your system -- for example, in your case, you could control the relative positions of the two masses. I'm not sure how well this will work since your masses could technically accelerate in one direction forever, so long as the relative positions are the same.
• Create a more complicated PID controller structure where you have an inner loop which reads one of your outputs and an outer loop which uses the other output. This will be an iterative approach since you will likely have to do back-and-forth design with each PID loop. To do this, you could index into your system to get, for example, the system only from all inputs to output 1:
>> sys_output1 = sys(1,:)
• Automatically tune multi-loop structures as above with the Control System Tuner (if you have Robust Control Toolbox).
• Use MIMO control techniques like LQR and LQG.
Just some options...
- Sebastian
J. van Delft on 13 Mar 2015
Thanks Sebastian for you answer! The first option seems to give satisfactory results. I'll take a look at your other suggestion as well. I have never worked with the LQR and LQG but it could be worthwhile investing some time into it.