I am working on a speed controller for a robot and it's for when the robot is balancing on its wheels. I am designing the controller as part of a project in a linear control design course. However, the controller has to be implemented on a robot and in software delivered by my instructor, so I don't have infinite room of freedom. The way I implement my controller can be seen here:-
As you can see, I can add a gain \$K_p \$, an integrator and post-integrator, a lead/lag-term in both forward and feedback path, a prefilter and a feed-forward. And that's it. I can't change what feedback I'm receiving, I can only add and adjust terms of the controller.
Edit - Finding the new transfer function
Doing what AJN suggests gives me a much nicer bode plot:-
The bode plot is much nicer, but I still have some trouble. I want to smooth out the hill in the phase plot, but I am not sure how to do so.
The new transfer function:
num = [0 0 0 -3.5113e+07 -3.7165e+10 -2.0902e+12 -3.8701e+13 -1.5402e+14 2.5341e+15 2.2109e+16 3.3405e+16];
den = [1 2.4731e+03 1.4491e+06 2.5930e+08 1.2622e+10 9.9503e+10 -1.8488e+12 -1.0302e+13 0 0 0];
G2 = tf(num,den);
Earlier form of the question containing some outdated info
num = [0 0 0 0 -2.3409e+07 -2.4777e+10 -1.3935e+12 -2.5801e+13 -1.0268e+14 1.6894e+15 1.4740e+16 2.2270e+16];
den = [1 2.4738e+03 1.4508e+06 2.6223e+08 1.5442e+10 6.8736e+11 2.6563e+13 5.2944e+14 4.0900e+15 8.1300e+15 3.7708e+15 1.1220e+13];
G2 = tf(num,den);
The open and closed loop bode plot for the transfer function is here:-
As you can see in the closed loop bode plot, there is a big valley in the phase, and this causes the system to be unstable (I think), and I don't want that.
My inital idea was to add a lag-term to the forward path. A lag-term removes phase, so if I place it right where the valley is the peak should get smaller. My lag-term looks like this:-
But even after adding the lag-term the phase still looks very weird. Here is the new closed loop bode plot:-
Is there a way to remove this phase valley and get a proper stable system?
-G(s)H(s)
now. Simulink doesn't know that it has to ignore the-ve
sign in the summing junction when opening a loop (At least older simulink version didn't; I think). The positive shape of the phase plot makes me believe that to be the case. Be cautious. \$\endgroup\$