# How to deal with "weird" phase plots in bode diagram when designing a controller

I am trying to design a balance controller for a robot. With MATLAB simulink I arrived at the transfer function between the input and the pitch angle for the robot. I have plotted the bode and Nyquist plot below. As you can see, the Nyquist plot looks very weird, and in the bode diagram the signals at low frequencies are attenuated. To fix this, I added a zero at the peak of the magnitude plot, so $$\omega_i=10 \text{rad}/s \Rightarrow \tau_i = \frac{1}{\omega_i}=0.1\text{s}$$

This results in an I-term which looks like this: $$C_i(s)= \frac{\tau_is+1}{\tau_is}=\frac{0.1s+1}{0.1s}$$

When I add this to the controller the bode plot now becomes. Now I also want to add a lead-term to prevent overshoots but the way I usually do that is to change the crossover frequency $$\omega_c$$ such that there is good phase margin, define some constant $$\alpha$$, and then find the lead term with the formula $$\tau_d = \frac{1}{\omega_c \sqrt{\alpha}}$$. Then I can make my lead-term with $$C_d = \frac{\tau_d s + 1}{\alpha \tau_d s + 1}$$

But when I look at the current phase plot, it all around looks like there is no trouble regarding the phase margin. The phase is never close to $$-180^{\circ}$$ so I am not sure how to proceed with such a weird looking phase plot.

So my question is, how do I find my lead-term when the phase plot looks like this? Is there another way to do than I have proposed?

## Edit

The open loop transfer function between the input and pitch angle is $$G(s) = \frac{ 5.893e05 s^4 + 7.71e08 s^3 + 1.435e11 s^2 + 2.566e12 s + 7.683e09}{s^7 + 2418 s^6 + 1.317e06 s^5 + 1.977e08 s^4 + 1.312e10 s^3 + 1.796e11 s^2 - 9.658e11 s - 1.525e13}$$ Using the "pole" command in MATLAB I noticed that there was a pole in the RHP which should cause some instability. • Is it possible to assess the stability of the open-loop plant? your high frequent behaviour looks like -60dB/dec, indicating 3 dominant poles. However, the phaseshift from +90 to -90 shows only 2 dominant poles. This can indicate the presence of an unstable pole Apr 14 at 13:50
• @Petrus1904 I have made an edit to the question. I am not quite sure what you mean with your first question, but as you can see in the edit there actually is a pole in the right half plane which would cause instability. The pole $0.0087 +0i$ is unstable, right?
– Carl
Apr 14 at 13:54
• I suspect you might have pole/zero cancellations in your transfer function, Maybe you should work with zpk instead of tf.
– Ben
Apr 14 at 14:37

Following your edit, the first challenge in creating a controller is the task to create a stabilizing controller. After that, performance can be tuned. In order to find if the created controller stabilizes the closed-loop, the nyquist plot can be used. The nyquist stability criterion states that the amount of encirclements of the point -1 (hereby are counter-clockwise encirclements negative) are equal to $$N = P-Z$$. $$P$$ represents the amount of RHP poles of the open loop system and $$Z$$ the amount of RHP poles of the closed loop system. Therefore, in order to stabilize the closed-loop knowing that $$P = 1$$, the amount of encirclements of the nyquist contour should be 1 (which implies that $$Z=0$$). To be sure, this means 1 clock-wise encirclement, or one more clock-wise encirclement that counter clock-wise encirclements.

Achieving stability can be as easy as using just the right feedback gain. a root locus plot might indicate that rlocus(sys). However, I went tested that myself, just a gain is not going to achieve it. In this case, it could even be an unstable controller is able to stabilize the system. Sadly, I cannot provide direct rule of thumbs that ensure stability. After the closed loop is stabilized, I am pretty certain the bode plot will have a proper phase and gain margin (as it practically must cross the -180 phase angle).

Happy tinkering!

I'm a bit puzzled with your Bode plot, here's what I get with your transfer function and Matlab 2019b. My phase starts at almost -180 degrees while yours start at 0 degree. Is it possible that you've made a mistake somewhere in your analysis? Your transfer function is a bit complex, you could simplify it by removing the fast poles and zeroes. For example, you have 2 fast poles at -1714 and -516 and a fast zero at -1088. You can remove the 2 fast poles and the fast zero to simplify your transfer function. This will make your analysis easier.

Secondly, I think the rule-of-thumb formulae you use for the cross-over frequency is only valid when your open loop system has a low-pass characteristic. Your system has a band-pass characteristic.

• The system he describes is flipped, the actual system is $-G(s)$. Apr 14 at 14:51