GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-control/examples/type2_type3.py at 0.9.2 · python-control/python-control

Expand file tree

/

type2_type3.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
48 lines (39 loc) · 1.64 KB
/

type2_type3.py

Copy path

File metadata and controls

48 lines (39 loc) · 1.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# type2_type3.py - demonstration for type2 versus type3 control comparing
# tracking and disturbance rejection for two proposed controllers
# Gunnar Ristroph, 15 January 2010
import os
import matplotlib.pyplot as plt # Grab MATLAB plotting functions
from control.matlab import * # MATLAB-like functions
from scipy import pi
integrator = tf([0, 1], [1, 0]) # 1/s
# Parameters defining the system
J = 1.0
b = 10.0
Kp = 110.
Ki = Kp/2.
Kii = Ki
# Plant transfer function from torque to rate
inertia = integrator*1/J
friction = b # transfer function from rate to torque
P = inertia # friction is modelled as a separate block
# Gyro transfer function from rate to rate
gyro = 1. # for now, our gyro is perfect
# Controller transfer function from rate error to torque
C_type2 = (1. + Ki*integrator)*Kp*1.5
C_type3 = (1. + Ki*integrator)*(1. + Kii*integrator)*Kp
# System Transfer Functions
# tricky because the disturbance (base motion) is coupled in by friction
closed_loop_type2 = feedback(C_type2*feedback(P, friction), gyro)
disturbance_rejection_type2 = P*friction/(1. + P*friction+P*C_type2)
closed_loop_type3 = feedback(C_type3*feedback(P, friction), gyro)
disturbance_rejection_type3 = P*friction/(1. + P*friction + P*C_type3)
# Bode plot for the system
plt.figure(1)
bode(closed_loop_type2, logspace(0, 2)*2*pi, dB=True, Hz=True) # blue
bode(closed_loop_type3, logspace(0, 2)*2*pi, dB=True, Hz=True) # green
plt.show(block=False)
plt.figure(2)
bode(disturbance_rejection_type2, logspace(0, 2)*2*pi, Hz=True) # blue
bode(disturbance_rejection_type3, logspace(0, 2)*2*pi, Hz=True) # green
if 'PYCONTROL_TEST_EXAMPLES' not in os.environ:
plt.show()
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.