python-control: stability_margins doesn't find gain=1 crossover frequency correctly for DT systems
stability_margins doesn’t find gain=1 crossover frequency correctly for DT systems, but it seems to mostly do so for CT systems. I think the probelm may be in how margins.poly_z_mag1_crossing
is finding roots, but there were a few steps in that function I couldn’t follow, e.g. why H(z)*H(1/z)=1 implies |H(z)| = 1.
Example:
import control as ct
omegan = 2*np.pi
zeta = 0.2
plant = 1.1*ct.tf(omegan**2, [1, 2*zeta*omegan, omegan**2])
Ts = .05
plantdisc = ct.c2d(plant,Ts,'zoh')
#_ = ct.bode_plot(plant, margins=True) # gives correct gain=1 crossover freq
_ = ct.bode_plot(plantdisc, margins=True) # no gain=1/no phase margin given

As an example of what it should look like, here is Matlab:
omegan = 2*pi;
zeta = 0.2;
plant = 1.1*tf(omegan^2, [1, 2*zeta*omegan, omegan^2])
Ts = .05;
plantdisc = c2d(plant,Ts,'zoh')
margin(plantdisc)

About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (15 by maintainers)
Commits related to this issue
- fix #523: finding z for |H(z)|=1 computed the wrong polynomials — committed to bnavigator/python-control by bnavigator 3 years ago
- Merge pull request #525 from bnavigator/fix-523 fix #523: finding z for |H(z)|=1 computed the wrong polynomials — committed to python-control/python-control by bnavigator 3 years ago
- add the second example from #523 to the tests — committed to bnavigator/python-control by bnavigator 3 years ago
- merge the second example from #523 into test_stability_margins_discrete — committed to bnavigator/python-control by bnavigator 3 years ago
If we can get this sorted out before ~22 March, we can do a 0.9.0 release that week to make it easy for students to install.
In any case there should be a check, whether the current results are accurate enough and give a warning if not.
(am hoping to have something working in place for 0.9 for the discrete-time controls class I’m teaching starting March 29. The students will appreciate a working DT margin calculation! : )