Skip to content

Documentation for margin command is incorrect #195

Description

@padraic00

The wiki specifies the output of margin to be gm,pm,Wcg,Wcp. This doesn't appear to be accurate. Varying proportional gains of my system should change Wcg and not Wcp.

Activity

  1. murrayrm commented on Feb 24, 2018

    @murrayrm
    Member

    Changing the gain of your system will affect both the gain margin (by exactly the inverse of the change in gain) and the phase margin (because you shift the frequency at which the gain crosses unity and it is the phase at unity gain(s) that determines the phase margin).

  2. padraic00 commented on Feb 24, 2018

    @padraic00
    Author

    You misunderstand the issue. I'm not talking about the actual margins. I'm talking frequencies.

    The order of the frequencies returned by the function margin disagree with the order specified on the wiki.

    Edit: I've attached a code snippet demonstrating the issue. The print function is in accordance to what the wiki specifies the function returns:
    image

    Notice how Wcp changes... (it shouldn't)

  3. murrayrm commented on Feb 24, 2018

    @murrayrm
    Member

    Thanks for the extra info. You are right that I misunderstood the issue you were pointing out, and you are correct that the documentation for the control.margin() function is incorrect.

    Just for posterity, here is what is going on in a bit more detail:

    • In python-control, according to the documentation for control.margins(), Wcg is the gain crossover frequency (corresponding to phase margin) and Wcp is the phase crossover frequency (corresponding to gain margin). What the documentation says is the order of the return values is:

      • gm = Gain margin
      • pm = Phase margin (in degrees)
      • Wcg = Gain crossover frequency (corresponding to phase margin)
      • Wcp = Phase crossover frequency (corresponding to gain margin) (in rad/sec)
    • What is actually returned is a subset of the return values in the order of the control.stability_margins() function, which is

      • gm = Gain margin
      • pm = Phase margin
      • sm = Stability margin, the minimum distance from the Nyquist plot to -1
      • wg = Gain margin crossover frequency (where phase crosses -180 degrees)
      • wp = Phase margin crossover frequency (where gain crosses 0 dB)
      • ws = Stability margin frequency (where Nyquist plot is closest to -1)
    • In MATLAB, the relevant function call is [Gm,Pm,Wgm,Wpm] = margin(sys) where Wgm is 'the frequency where the gain margin is measured' (from MATLAB documentation) and Wpm is 'the frequency where the phase margin is measured'. This is the same as control.stability_margins().

    So the problem is that the documentation for control.margin is incorrect.

    Since I'm doing a bit of work on the code today, I'll try to post a PR to fix this soon. @repagh and @blinkminster: I think one or both of you worked on this in the past, so if you happen to be online and I am missing something in terms of what is going on, let me know.

  4. changed the title [-]output of margin in wrong order[/-] [+]Documentation for margin command is incorrect[/+] on Feb 24, 2018
  5. added this to the 0.8.0 milestone on Feb 24, 2018
  6. self-assigned this
    on Feb 24, 2018
  7. added a commit that references this issue on Jul 2, 2018
  8. murrayrm commented on Jul 2, 2018

    @murrayrm
    Member

    Fixed in PR #198.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions