From aa73bc907e109ea1359c549e8fe96001534d826a Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 25 Jul 2020 23:27:08 -0400 Subject: [PATCH] Add simple analysis --- analysis/Simulation/TranslationalMass.py | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 analysis/Simulation/TranslationalMass.py diff --git a/analysis/Simulation/TranslationalMass.py b/analysis/Simulation/TranslationalMass.py new file mode 100644 index 00000000..3cb1a4aa --- /dev/null +++ b/analysis/Simulation/TranslationalMass.py @@ -0,0 +1,35 @@ +import os +import matplotlib.pyplot as plt +from control.matlab import * + +# Input: Current (A) +# Output: Torque (Nm) +# Params: Kt (Nm/A) +def motor(Kt): + return tf(Kt, 1) + +# Mass-Spring-Damper +# Input: Force +# Output: Position +# Params: m (kg) +# b +# k (N/m) +def mass(m, b, k): + A = [[0, 1.], [-k/m, -b/m]] + B = [[0], [1/m]] + C = [[1., 0]] + return ss(A, B, C, 0) + +# Input: Torque (Nm) +# Output: Force (N) +# Params: r (m) +def pulley(r): + return tf(r, 1) + +sys = series(motor(2.5), pulley(0.015), mass(0.10, 0, 0)) +yout, T, xout = step(sys, return_x=True) +print(yout) +# plt.plot(T, yout) +plt.plot(T, xout) +plt.legend(['Displacement', 'Velocity']) +plt.show() \ No newline at end of file