Ejemplo n.º 1
0
def main():
    dt = 0.1
    T = np.arange(0, 6, dt)

    plt.figure(1)
    plt.xticks(np.arange(min(T), max(T) + 1, 1.0))
    plt.xlabel("Time (s)")
    plt.ylabel("Step response")
    tf = ct.TransferFunction(1, [1, -0.6], dt)
    sim(tf, T, "Single pole in RHP")
    tf = ct.TransferFunction(1, [1, 0.6], dt)
    sim(tf, T, "Single pole in LHP")
    if "--noninteractive" in sys.argv:
        latex.savefig("z_oscillations_1p")

    plt.figure(2)
    plt.xlabel("Time (s)")
    plt.ylabel("Step response")
    den = [np.real(x) for x in conv([1, 0.6 + 0.6j], [1, 0.6 - 0.6j])]
    tf = ct.TransferFunction(1, den, dt)
    sim(tf, T, "Complex conjugate poles in LHP")
    den = [np.real(x) for x in conv([1, -0.6 + 0.6j], [1, -0.6 - 0.6j])]
    tf = ct.TransferFunction(1, den, dt)
    sim(tf, T, "Complex conjugate poles in RHP")
    if "--noninteractive" in sys.argv:
        latex.savefig("z_oscillations_2p")
    else:
        plt.show()
Ejemplo n.º 2
0
def main():
    #        (s - 9 + 9i)(s - 9 - 9i)
    # G(s) = ------------------------
    #               s(s + 10)
    G = cnt.tf(conv([1, -9 + 9j], [1, -9 - 9j]), conv([1, 0], [1, 10]))
    cnt.root_locus(G, grid=True)

    # Show plot
    plt.title("Root Locus")
    plt.xlabel("Real Axis (seconds$^{-1}$)")
    plt.ylabel("Imaginary Axis (seconds$^{-1}$)")
    plt.gca().set_aspect("equal")
    if "--noninteractive" in sys.argv:
        latexutils.savefig("rlocus_zeroes")
    else:
        plt.show()
def main():
    dt = 0.0001
    T = np.arange(0, 6, dt)

    plt.xlabel("Time ($s$)")
    plt.ylabel("Position ($m$)")

    # Make plant
    G = ct.TransferFunction(1, conv([1, 5], [1, 0]))

    sim(ct.TransferFunction(1, 1), T, "Setpoint")

    K = ct.TransferFunction(120, 1)
    Gcl = ct.feedback(G, K)
    sim(Gcl, T, "Underdamped")

    K = ct.TransferFunction(3, 1)
    Gcl = ct.feedback(G, K)
    sim(Gcl, T, "Overdamped")

    K = ct.TransferFunction(6.268, 1)
    Gcl = ct.feedback(G, K)
    sim(Gcl, T, "Critically damped")

    if "--noninteractive" in sys.argv:
        latex.savefig("pid_responses")
    else:
        plt.show()
Ejemplo n.º 4
0
def main():
    dt = 0.1
    T = np.arange(0, 6, dt)

    plt.figure(1)
    plt.xticks(np.arange(min(T), max(T) + 1, 1.0))
    plt.xlabel("Time (s)")
    plt.ylabel("Step response")
    tf = cnt.TransferFunction(1, [1, -0.6], dt)
    sim(tf, T, "Single pole in RHP")
    tf = cnt.TransferFunction(1, [1, 0.6], dt)
    sim(tf, T, "Single pole in LHP")
    plt.savefig("z_oscillations_1p.svg")

    plt.figure(2)
    plt.xlabel("Time (s)")
    plt.ylabel("Step response")
    tf = cnt.TransferFunction(1, conv([1, 0.6 + 0.6j], [1, 0.6 - 0.6j]), dt)
    sim(tf, T, "Complex conjugate poles in LHP")
    tf = cnt.TransferFunction(1, conv([1, -0.6 + 0.6j], [1, -0.6 - 0.6j]), dt)
    sim(tf, T, "Complex conjugate poles in RHP")
    plt.savefig("z_oscillations_2p.svg")
def main():
    #              1
    # G(s) = --------------
    #        (s + 2)(s + 3)
    G = ct.tf(1, conv([1, 0], [1, 2], [1, 3]))
    ct.root_locus(G, grid=True)

    plt.title("Root Locus")
    plt.xlabel("Real Axis (seconds$^{-1}$)")
    plt.ylabel("Imaginary Axis (seconds$^{-1}$)")
    if "--noninteractive" in sys.argv:
        latex.savefig("rlocus_asymptotes")
    else:
        plt.show()
def main():
    dt = 0.0001
    T = np.arange(0, 6, dt)

    plt.xlabel("Time ($s$)")
    plt.ylabel("Position ($m$)")

    # Make plant
    G = cnt.TransferFunction(1, conv([1, 5], [1, 0]))

    sim(cnt.TransferFunction(1, 1), T, "Reference")
    Gcl = make_closed_loop_plant(G, 120)
    sim(Gcl, T, "Underdamped")
    Gcl = make_closed_loop_plant(G, 3)
    sim(Gcl, T, "Overdamped")
    Gcl = make_closed_loop_plant(G, 6.268)
    sim(Gcl, T, "Critically damped")

    plt.savefig("pid_responses.svg")
#!/usr/bin/env python3

import matplotlib as mpl
mpl.use("svg")
import control as cnt
from frccontrol import conv
import matplotlib.pyplot as plt

#        (s - 9 + 9i)(s - 9 - 9i)
# G(s) = ------------------------
#               s(s + 10)
G = cnt.tf(conv([1, -9 + 9j], [1, -9 - 9j]), conv([1, 0], [1, 10]))
cnt.root_locus(G)

# Show plot
plt.title("Root Locus")
plt.xlabel("Real Axis (seconds$^{-1}$)")
plt.ylabel("Imaginary Axis (seconds$^{-1}$)")
plt.gca().set_aspect("equal")
plt.savefig("rlocus_zeroes.svg")
#!/usr/bin/env python3

import matplotlib as mpl
mpl.use("svg")
import control as cnt
from frccontrol import conv
import matplotlib.pyplot as plt

#              1
# G(s) = --------------
#        (s + 2)(s + 3)
G = cnt.tf(1, conv([1, 0], [1, 2], [1, 3]))
cnt.root_locus(G)

plt.title("Root Locus")
plt.xlabel("Real Axis (seconds$^{-1}$)")
plt.ylabel("Imaginary Axis (seconds$^{-1}$)")
plt.savefig("rlocus_asymptotes.svg")