0% found this document useful (0 votes)
219 views

Mathcad For Controls

This document discusses using Mathcad for controls engineering applications. It presents the numerical solution to a second order differential equation modeling a plant. Transfer functions are derived for the plant and a feedback loop with a derivative controller is defined. Unit step and sinusoidal responses are analyzed. Bode, Nyquist, and root locus plots are generated for varying controller gain.

Uploaded by

SHD053
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)
219 views

Mathcad For Controls

This document discusses using Mathcad for controls engineering applications. It presents the numerical solution to a second order differential equation modeling a plant. Transfer functions are derived for the plant and a feedback loop with a derivative controller is defined. Unit step and sinusoidal responses are analyzed. Bode, Nyquist, and root locus plots are generated for varying controller gain.

Uploaded by

SHD053
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
M

d2
dt

y ( t) + d

d
y ( t) + k y ( t) = v ( t)
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

t := 0 ,

tfinal
steps

2 of 14

.. tfinal

0.005

y ( t)

0.005

0.02

0.04

0.06

0.08

0.1

v ( t) :=

d
y ( t)
dt
5

v ( t)

0.02

0.04

0.06

5
t

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)

0.08

0.1

Mathcad for Controls

3 of 14

Transfer Function (Plant):


1

Gp ( s) :=

M s + d s + k

______________________________________________________
Denominator Coefficients, b:

1000
b := denom ( Gp ( s) ) coeffs , s .1e-2

.1e-2

k
d
M

______________________________________________________
Zeros (none) and Poles:

(polyroots can handle large polynomials)

0.5 1000i
X=

0.5
+
1000i

X := polyroots ( b)

______________________________________________________
Pole-Zero Map:

1000
Im ( X)

0
1000
0.6

0.5
Re ( X)

0.4

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)

Mathcad for Controls

4 of 14

Unit Step Response:


U ( s) :=

1
s

Y ( s) := Gp ( s) U ( s)

y ( t) := Y ( s)

(.1e-2 s2 + .1e-2 s + 1000) s

invlaplace , s , t
( .50000) t
.10000e-2 .10000e-2 e
cos ( 10
float , 5

0.002

y ( t)

0.001

0.02

0.04

0.06

0.08

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)

0.1

Mathcad for Controls

5 of 14

t := t

Response to v(t):
v ( t) := sin ( t)
V ( s) := v ( t) laplace , t , s

800
2

s + 640000

Y ( s) := Gp ( s) V ( s)

800

(.1e-2 s2 + .1e-2 s + 1000) (s2 + 640000)

invlaplace , s , t
expand , s

y ( t) := Y ( s)

.61728e-5 e

( .50000) t

cos ( 1000.0 t) .2

simplify
float , 5
0.005

y ( t)

0.005

0.02

0.04

0.06
t

y tfinal = 1.685 10 3

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)

0.08

0.1

Mathcad for Controls

6 of 14

ORIGIN := 1
|
|
\|/

Bode Plot:
n := 1001

:= logspace 10 2 , 10 6 , n

n = 1 10 6

1 = 100

k := 1 .. n
0

1000

50

20 log Gp k j

))

100
150
200
100

1 .10

1 .10

1 .10

1 .10

1000

50

360
arg Gp k j
100
2

( (

))

150
200
100

1 .10

1 .10

k
(Examples from MATLAB Mastery
- used with permission of
TechnicalMastery.com Corp.)

1 .10

1 .10

Mathcad for Controls

7 of 14

Nyquist Plot:
Gp ( s)

1
2

.1e-2 s + .1e-2 s + 1000

:= stack logspace 10 6 , 10 2 , 200000 , logspace 10 2 , 10 6 , 200000


k := 1 .. rows ( )

0.5

( (

Im Gp k j

))

0.5

0.5

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:

Gp ( s)

1
2

.1e-2 s + .1e-2 s + 1000

Ki
Gc s , Ki := 1 +
+ 0.001 s
s

H ( s) := 1
______________________________________________________

( )
( )

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

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)

G s , Ki

Mathcad for Controls

9 of 14

Unit response, varying Ki:

Y s , Ki := G s , Ki U ( s) simplify

y t , Ki := Y s , Ki

(3

1000. s + 1000. Ki + s

s s + 2. s + 1001000. s + 1000. Ki

1000 s + 1000 K
convert , parfrac , s

invlaplace
s 4 + 2 s 3 + 1001000 s 2
invlaplace , s , t

__________________________________________________________

( )

( (

a Ki := numer Y s , Ki

( )

( (

))

1000. Ki

coeffs , s 1000.

))

1000. Ki
coeffs , s 1001000.

2.

b Ki := denom Y s , Ki

__________________________________________________________

( )

( ( ))

O := O

( )

( ( ))

X := X

O Ki := polyroots a Ki
X Ki := polyroots b Ki

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)

Mathcad for Controls

10 of 14

(s O (Ki)k)

a ( Ki) 3 k =
Y ( s , Ki) :=
4
b ( Ki) 5

convert , parfrac , s

(s X (Ki)k)

( X ( Ki) 4)

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
y ( t1 , 1)

1
y ( t2 , 1)

0.05

y ( t1 , 500)

y ( t2 , 500)

y ( t1 , 1000)

y ( t2 , 1000)
0

0.05

0.5

0.1

0.05

0.5
t1

t2

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)

10

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 , 500) )
20 log ( G ( k j , 1000) )

20 log G k j , 1

20
40
60
80
4
3
1 .10 1 .10 0.01

0.1

1
k

(Examples from MATLAB Mastery


- used with permission of
TechnicalMastery.com Corp.)

10

100 1 .10 1 .10


3

Mathcad for Controls

12 of 14

Nyquist Plot:

G s , Ki

1000. s + 1000. Ki + s
expand , s

3
2
simplify
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

( (
))
Im ( G ( k j , 500) )
Im ( G ( k j , 1000) )

0.5

Im G k j , 1

0.5

0.5

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

( ( ))
Im ( O ( Ki) 2)
Im ( X ( Ki) 1)
Im ( X ( Ki) 2)
Im ( X ( Ki) 3)
Im ( X ( Ki) 4)

1000

Im O Ki 1

500

1000

900

800

700

600

500

400

300

200

100
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