0% found this document useful (0 votes)
2 views14 pages

Tutorial

The document presents a numerical solution for a control system using Mathcad, including the formulation of the transfer function, response to input signals, and various plots such as Bode, Nyquist, and Root-Locus. It details the system's parameters and equations, demonstrating the use of MATLAB for analysis and visualization of the control system's behavior. Additionally, it explores the effects of varying the controller gain on system response and stability.

Uploaded by

yeciwo5599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views14 pages

Tutorial

The document presents a numerical solution for a control system using Mathcad, including the formulation of the transfer function, response to input signals, and various plots such as Bode, Nyquist, and Root-Locus. It details the system's parameters and equations, demonstrating the use of MATLAB for analysis and visualization of the control system's behavior. Additionally, it explores the effects of varying the controller gain on system response and stability.

Uploaded by

yeciwo5599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Mathcad for Controls 1 of 14

M := 0.001 d := 0.001 k := 1000 ω := 800

______________________________________________________

tfinal := 0.1 steps := 1000 v ( t) := sin ( ω ⋅ t)


______________________________________________________
Numerical Solution:
Given

d2 d
M⋅ y ( t) + d ⋅ y ( t) + k ⋅ y ( t) = v ( t)
2 dt
dt
y ( 0) = 0

y' ( 0) = 0

(
y := Odesolve t , tfinal , steps )
( )
y tfinal = −1.685 × 10 − 3

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 2 of 14

tfinal
t := 0 , .. tfinal
steps

0.005

y ( t) 0

0.005
0 0.02 0.04 0.06 0.08 0.1
t

d
v ( t) := y ( t)
dt

v ( t)
0 0.02 0.04 0.06 0.08 0.1

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 3 of 14

Transfer Function (Plant):


1
Gp ( s) :=
2
M⋅ s + d⋅ s + k
______________________________________________________
Denominator Coefficients, b:

⎛ 1000 ⎞ k
b := denom ( Gp ( s) ) coeffs , s → ⎜ .1e-2 ⎟ d
⎜ ⎟
⎝ .1e-2 ⎠ M
______________________________________________________
Zeros (none) and Poles: (polyroots can handle large polynomials)

⎛ −0.5 − 1000i ⎞
X := polyroots ( b) X= ⎜ ⎟
⎝ − 0.5 + 1000i ⎠
______________________________________________________

Pole-Zero Map:

1000

Im ( X) 0

1000
0.6 0.5 0.4
Re ( X)

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 4 of 14

Unit Step Response:


1
U ( s) :=
s

1
Y ( s) := Gp ( s) ⋅ U ( s) →
(.1e-2 ⋅ s2 + .1e-2 ⋅ s + 1000) ⋅ s

invlaplace , s , t ( − .50000) ⋅ t
y ( t) := Y ( s) → .10000e-2 − .10000e-2 ⋅ e ⋅ cos ( 10
float , 5

0.002

y ( t) 0.001

0
0 0.02 0.04 0.06 0.08 0.1
t

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 5 of 14

Response to v(t): t := t

v ( t) := sin ( ω ⋅ t)
800
V ( s) := v ( t) laplace , t , s →
2
s + 640000

800
Y ( s) := Gp ( s) ⋅ V ( s) →
(.1e-2 ⋅ s2 + .1e-2 ⋅ s + 1000) ⋅ (s2 + 640000)

invlaplace , s , t

y ( t) := Y ( s) expand , s → .61728e-5 ⋅ e
( − .50000) ⋅ t
⋅ cos ( 1000.0 ⋅ t) − .2
simplify
float , 5

0.005

y ( t) 0

0.005
0 0.02 0.04 0.06 0.08 0.1
t

( )
y tfinal = −1.685 × 10 − 3

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 6 of 14

Bode Plot: ORIGIN := 1


|
n := 1001 |
\|/
(
ω := logspace 10 2 , 10 6 , n ) ω1 = 100 ωn = 1 × 10 6

k := 1 .. n

0 1000

50

( (
20 ⋅ log Gp ω k ⋅ j )) 100

150

200
1 .10 1 .10 1 .10 1 .10
3 4 5 6
100
ωk

0 1000

50

⎛ 360 ⎞
( (
arg Gp ω k ⋅ j ⋅ ⎜ )) ⎟ 100
⎝ 2⋅ π ⎠
150

200
1 .10 1 .10 1 .10 1 .10
3 4 5 6
100
ωk

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 7 of 14

Nyquist Plot:
1
Gp ( s) →
2
.1e-2 ⋅ s + .1e-2 ⋅ s + 1000

( ( )
ω := stack −logspace 10 6 , 10 2 , 200000 , logspace 10 2 , 10 6 , 200000 ( ))
k := 1 .. rows ( ω )

1
1

2

0.5

( (
Im Gp ω k ⋅ j )) 1 0.5 0 0.5 1

0.5

( (
Re Gp ω k ⋅ j ))

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 8 of 14

Define Feedback Loop with Derivative Controller:

1
Gp ( s) →
2
.1e-2 ⋅ s + .1e-2 ⋅ s + 1000

Ki
( )
Gc s , Ki := 1 +
s
+ 0.001 ⋅ s

H ( s) := 1
______________________________________________________

Gp ( s) ⋅ Gc s , Ki ( )
(
G s , Ki :=) ( )
1 + Gp ( s) ⋅ Gc s , Ki ⋅ H ( s) (
G s , Ki )

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 9 of 14

Unit response, varying Ki:


2
1000. ⋅ s + 1000. ⋅ Ki + s
( ) ( )
Y s , Ki := G s , Ki ⋅ U ( s) simplify →
(3 2
s ⋅ s + 2. ⋅ s + 1001000. ⋅ s + 1000. ⋅ Ki )
convert , parfrac , s ⎛ 1000 ⋅ s + 1000 ⋅ K

( )
y t , Ki := Y s , Ki( ) invlaplace , s , t
→ invlaplace
⎜ s 4 + 2 ⋅ s 3 + 1001000 ⋅ s 2

__________________________________________________________

⎛ 1000. ⋅ Ki ⎞
⎜ ⎟
( )
a Ki := numer Y s , Ki ( ( )) coeffs , s → ⎜ 1000. ⎟
⎜ ⎟
⎝ 1 ⎠

⎛ 0 ⎞
⎜ ⎟
⎜ 1000. ⋅ Ki ⎟
( )
b Ki := denom Y s , Ki ( ( )) coeffs , s → ⎜ 1001000. ⎟
⎜ ⎟
⎜ 2. ⎟
⎜ ⎟
⎝ 1 ⎠
__________________________________________________________

( )
O Ki := polyroots a Ki ( ( )) O := O

( )
X Ki := polyroots b Ki ( ( )) X := X

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 10 of 14

⎛ a ( Ki) 3 ⎞ k =
∏ (s − O (Ki)k) O
Y ( s , Ki) := ⎜
1
⎟⋅ 4 convert , parfrac , s →
b ( Ki) 5 ⎡⎣( −X ( Ki) 4)
⎝ ⎠
∏ (s − X (Ki)k)
k= 1

( ) ( ) ( ) ( )
−⎡O Ki 1 ⋅ X Ki 1 − O Ki 1 ⋅ O Ki 2 −

( ) ( )
y t , Ki := Y s , Ki invlaplace , s , t →
( ( )) ( ) ( ( ))
⎡⎣ −X Ki 4 + X Ki 1⎤⎦ ⋅ ⎡⎣ −X Ki 3 + X

t1 := 0 , 0.0001 .. 0.1 t2 := 0 , 0.01 .. 10

0.1 1

y ( t1 , 1) 0.05 y ( t2 , 1) 0.5
y ( t1 , 500) y ( t2 , 500)
y ( t1 , 1000) y ( t2 , 1000)
0 0.05 0.1 0 5 10

0.05 0.5

t1 t2

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 11 of 14

Bode Plot, varying Ki:

n := 1001

(
ω := logspace 10 − 4 , 10 4 , n )
k := 1 .. n

( (
20 ⋅ log G ω k ⋅ j , 1 )) 20

20 ⋅ log ( G ( ω k ⋅ j , 500) ) 40
20 ⋅ log ( G ( ω k ⋅ j , 1000) )
60

80
1 .10 1 .10 0.01 100 1 .10 1 .10
4 3 3 4
0.1 1 10
ωk

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 12 of 14

Nyquist Plot:

2
expand , s 1000. ⋅ s + 1000. ⋅ Ki + s
(
G s , Ki ) simplify

3 2
s + 2. ⋅ s + 1001000. ⋅ s + 1000. ⋅ Ki

( ( )
ω := stack −logspace 10 4 , 10 − 1 , 50000 , logspace 10 − 1 , 10 4 , 50000( ))
k := 1 .. rows ( ω )

− 0.5 1

0.5
( (
Im G ω k ⋅ j , 1 ))
Im ( G ( ω k ⋅ j , 500) )
1 0.5 0 0.5 1
Im ( G ( ω k ⋅ j , 1000) )

0.5

( ( )) ( ( )) ( ( ))
Re G ω k ⋅ j , 1 , Re G ω k ⋅ j , 500 , Re G ω k ⋅ j , 1000

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 13 of 14

MATLAB-produced Nyquist Plot:

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)
Mathcad for Controls 14 of 14

Root-Locus Plot:

Ki := 1 , 11 .. 1001

1500

1000
( ( ))
Im O Ki 1

Im ( O ( Ki) 2)
500
Im ( X ( Ki) 1)

Im ( X ( Ki) 2)
1000 900 800 700 600 500 400 300 200 100
Im ( X ( Ki) 3)

Im ( X ( Ki) 4) 500

1000

1500

( ( )) ( ( )) ( ( )) ( ( )) ( ( ))
Re O Ki 1 , Re O Ki 2 , Re X Ki 1 , Re X Ki 2 , Re X Ki 3 , Re X (

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)

You might also like