My HP Prime Helper Functions for Control Systems Analysis
- Update your firmware.
- Drag the
*.hpprgminto Programs directory. - Rename the program by deleting the "Local" word in the filename.
DampingRatio(os)calculates the damping ratio zeta for a given overshoot percentage (expressed as a fraction of 1)Overshoot(zeta)calculates the overshoot (expressed as a fraction of 1) given a damping ratioPeakTime(zeta,omega)calculates the peak time of a second-order system given azetaandomegainput.RiseTime(zeta,omega)calculates the rise time of a second-order system given azetaandomegainput. Note the result is a third-order polynomial estimate due to the absence of a closed-form solution.SettlingTime(zeta,omega)calculates the settling time of a second-order system given azetaandomegainput.PeakMagnitude(zeta)calculates the peak magnitude of a second-order open-loop system givenzetainputPeakFrequency(zeta,omega)calcaultes the frequency at the peak magnitude of a second-order open-loop system givenzetaandomegainputBandwidth(zeta,omega)calculates the bandwidth of a second-order open-loop system givenzetaandomega.PhaseMargin(zeta)calculates the phase margin of a second-order open-loop system givenzeta.
-
rldamp(numerator, denominator, zeta, radius)calculates the total angle contributions of a critical point for an open-loop transfer function with polynomial coefficientsnumeratoranddenominatorto a point given by damping ratiozetaand polar radiusradius. This program is mainly used to check whether a given point in the complex plane lies on the root locus. The inputsnumeratoranddenominatorare row matrices consisting of the coefficients of the relevant polynomials in decreasing power, so [1 2 3] corresponds to the coefficients of the polynomial x^2 + 2x + 3. -
rlk(numerator, denominator, complex_point)calculates the required gain for the open-loop transfer function with polynomial coefficientsnumeratoranddenominatorto realize a pole ofcomplex_point, expressed asa+b*i. For example, after using rldamp to confirm the exist of a pole, its coordinates can be converted to Cartesian via:radius*cos(180-acos(zeta)) + radius*sin(180-acos(zeta))*i -
rlbreak(numerator, denominator)calculates breakaway and break-in points for the for an open-loop transfer function with polynomial coefficientsnumeratoranddenominator. It accomplishes this by solving for the zeros of dK/ds = d(-P(s)/Q(s))/ds, where T(s) = Q(s)/P(s).
ReImParts(expression)generates a list where the first entry is the real component and second entry is the imaginary component of any expression.Mag(expression)calculates the magnitude of a frequency response functionPhase(expression)calculates the phase of a frequency response functionFreqResponseEval(num, den, omega)evaluates the frequency response G(j*omega) of a transfer function withnum,denbeing the coefficients of its numerator and denominator respectivelyMagContrib(num, den, c)evaluates the magnitude of a frequency response given a complex pointcand transfer function coefficientsPhaseContrib(num, den, c)evaluates the phase of a frequency response given a complex pointcand transfer function coefficients
The following are mirrors of applications from the HP Developer website:
- Control Systems Application
- Routh Hurwitz
Consider the unity feedback loop with forward transfer function
K(s+1)(s+2)
G(s) = ------------
(s-1)(s-2)
Calculate the value of K that yields a stable system with a pair of second-order poles that have a damping ratio of 0.707. Where are the break-in and breakaway points?
To find the damping ratio of 0.707 and find the second-order poles. We
can search the line at angle pi - acos(0.707) for different values
of radius with the command
rldamp([1 3 2],[1 -3 2],0.707,sqrt(2)]
-180.0
This implies a radius of sqrt(2) is needed for the overshoot line of 0.707 zeta to intersect the root locus. The associated gain is
rlk([1 3 2],[1 -32],sqrt(2)*cos(180-acos(0.707))+sqrt(2)*sin(180-acos(0.707))*i)
4.9981
Finally, the breakaway and break-in points are
rlbreak([1 3 2],[1 -3 2])
[1.41421356237 -1.41421356237]
Consider the unity feedback system with the forward transfer function
6
G(s) = ---------------
(s^2+2s+2)(s+2)
Find the gain and phase margin.
To find the gain margin, we first find where the Nyquist diagram crosses the real axis for frequency between 0 and positive infinity.
We can do this by first evaluating the frequency response with a variable, converting it to complex form, and setting the imaginary part equal to zero and solving the the real part. We get a real part of -0.3. Thus K can be increased 3.33 before the real part becomes -1, and the gain margin Gm = 20 log 3.33 = 10.45 dB.
The phase margin can be found by searching positive frequencies that give a magnitude of unity. This frequency of 1.253 rad/s is then used to calculate the total phase contribution, which is -112.3 degrees. This results in a phase margin of -180 - (-112.3) = 67.7 degrees.



