9
04/02/2018 transfer_functions http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 1/9 In [ ]: % Matlab setup clear all cd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block Circuit Simulation Using Simulink Transfer Function Block Transfer Functions for Circuits When doing circuit analysis with components defined in the complex frequency domain, the ratio of the output voltage ro the input voltage under zero initial conditions is of great interest. This ratio is known as the voltage transfer function denoted : Similarly, the ratio of the output current to the input current under zero initial conditions, is called the cuurent transfer function denoted : In practice, the current transfer function is rarely used, so we will use the voltage transfer function denoted: Example 6 Derive an expression for the transfer function for the circuit below. In this circuit represents the internal resistance of the applied (voltage) source , and represents the resistance of the load that consists of , and .

Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

  • Upload
    others

  • View
    25

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

04/02/2018 transfer_functions

http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 1/9

In [ ]:

% Matlab setup clear all cd matlab pwd

Transfer Functions

Second Hour's AgendaTransfer Functions

A Couple of Examples

Circuit Analysis Using MATLAB LTI Transfer Function Block

Circuit Simulation Using Simulink Transfer Function Block

Transfer Functions for CircuitsWhen doing circuit analysis with components defined in the complex frequency domain, the ratio of theoutput voltage ro the input voltage under zero initial conditions is of great interest. This ratio isknown as the voltage transfer function denoted :

Similarly, the ratio of the output current to the input current under zero initial conditions, iscalled the cuurent transfer function denoted :

In practice, the current transfer function is rarely used, so we will use the voltage transfer function denoted:

Example 6Derive an expression for the transfer function for the circuit below. In this circuit represents theinternal resistance of the applied (voltage) source , and represents the resistance of the load thatconsists of , and .

(s)Vout (s)Vin

(s)Gv

(s) =Gv

(s)Vout

(s)Vin

(s)Iout (s)Iin(s)Gi

(s) =Gi

(s)Iout

(s)Iin

G(s) =(s)Vout

(s)Vin

G(s) Rg

vs RL

RL L C

Page 2: Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

04/02/2018 transfer_functions

http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 2/9

Sketch of SolutionReplace , , , and by their transformed (complex frequency) equivalents: , , , and Use the Voltage Divider Rule to determine as a function of Form by writing down the ratio

Worked solution.Pencast: ex6.pdf (worked%20examples/ex6.pdf) - open in Adobe Acrobat Reader.

Answer

(t)vs Rg RL L C (s)Vs Rg RL

sL 1/(sC)

(s)Vout (s)Vs

G(s) (s)/ (s)Vout Vs

G(s) = = .(s)Vout

(s)Vs

+ sL + 1/sCRL

+ + sL + 1/sCRg RL

Page 3: Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

04/02/2018 transfer_functions

http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 3/9

Example 7Compute the transfer function for the op-amp circuit shown below in terms of the circuit constants , ,

, and . Then replace the complex variable with , and the circuit constants with their numericalvalues and plot the magnitude versus radian frequency .

R1 R2

R3 C1 C2 s jω

|G(s)| = | (s)/ (s)|Vout Vin ω

Page 4: Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

04/02/2018 transfer_functions

http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 4/9

Sketch of SolutionReplace the components and voltages in the circuit diagram with their complex frequencyequivalentsUse nodal analysis to determine the voltages at the nodes either side of the 50K resistor Note that the voltage at the input to the op-amp is a virtual groundSolve for as a function of Form the reciprocal Use MATLAB to calculate the component values, then replace by .Plot on log-linear "paper"

Worked solution.Pencast: ex7.pdf (worked%20examples/ex7.pdf) - open in Adobe Acrobat Reader.

Answer

The Matlab BitSee attached script: solution7.m (matlab/solution7.m).

Week 3: Solution 7

In [1]:

syms s;

In [2]:

R1 = 200*10^3; R2 = 40*10^3; R3 = 50*10^3;

C1 = 25*10^(-9); C2 = 10*10^(-9);

In [3]:

den = R1*((1/R1+ 1/R2 + 1/R3 + s*C1)*(s*R3*C2) + 1/R2); simplify(den)

Result is: 100*s*((7555786372591433*s)/302231454903657293676544 + 1/20000) + 5

R3

(s)Vout (s)Vin

G(s) = (s)/ (s)Vout Vin

s jω

G(jω)∣∣ ∣∣

G(s) = = .(s)Vout

(s)Vin

−1

((1/ + 1/ + 1/ + s ) (s ) + 1/ )R1 R1 R2 R3 C1 C2R3 R2

ans = 100*s*((7555786372591433*s)/302231454903657293676544 + 1/20000) + 5

Page 5: Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

04/02/2018 transfer_functions

http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 5/9

Simplify coefficients of s in denominator

In [4]:

format long denG = sym2poly(ans)

In [26]:

numG = -1;

Plot

For convenience, define coefficients and :

In [5]:

a = denG(1); b = denG(2);

In [7]:

w = 1:10:10000;

In [10]:

Gs = -1./(a*w.^2 - j.*b.*w + denG(3));

a b

G(jω) =−1

a − jbω + 5ω2

denG = 0.000002500000000 0.005000000000000 5.000000000000000

Page 6: Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

04/02/2018 transfer_functions

http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 6/9

In [11]:

semilogx(w, abs(Gs)) xlabel('Radian frequency w (rad/s') ylabel('|Vout/Vin|') title('Magnitude Vout/Vin vs. Radian Frequency') grid

Using Transfer Functions in Matlab for System AnalysisPlease use the file tf_matlab.m (matlab/tf_matlab.m) to explore the Transfer Function features provide byMatlab. Use the publish option to generate a nicely formatted document.

Using Transfer Functions in Simulink for System Simulation

The Simulink transfer function (Transfer Fcn) block shown above implements a transfer functionrepresenting a general input output function

that it is not specific nor restricted to circuit analysis. It can, however be used in modelling and simulationstudies.

G(s) =N(s)

D(s)

Page 7: Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

04/02/2018 transfer_functions

http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 7/9

ExampleRecast Example 7 as a MATLAB problem using the LTI Transfer Function block.

For simplicity use parameters , and .

Calculate the step response using the LTI functions.

Verify the result with Simulink.

The Matlab solution: example8.m (matlab/example8.m)

MATLAB Solution

From a previous analysis the transfer function is:

so substituting the component values we get:

We can find the step response by letting so that then

We can solve this by partial fraction expansion and inverse Laplace transform as is done in the text bookwith the help of Matlab's residue function.

Here, however we'll use the LTI block that was introduced in the lecture.

Define the circuit as a transfer function

In [18]:

G = tf([-1],[1 3 1])

step response is then:

In [ ]:

step(G)

Simples!

Simulink model

See example_8.slx (matlab/example_8.slx)

= = = 1 ΩR1 R2 R3 = = 1 FC1 C2

G(s) = =Vout

Vin

−1

[(1/ + 1/ + 1/ + s )(s ) + 1/ ]R1 R1 R2 R3 C1 R3C2 R2

G(s) = =Vout

Vin

−1

+ 3s + 1s2

(t) = (t)vin u0 (s) = 1/sVin

(s) = .Vout

−1

+ 3s + 1s2

1

s

G =

Page 8: Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

04/02/2018 transfer_functions

http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 8/9

In [ ]:

open example_8

Result

Let's go a bit further by finding the frequency response:

Page 9: Transfer Functions - GitHub Pagescd matlab pwd Transfer Functions Second Hour's Agenda Transfer Functions A Couple of Examples Circuit Analysis Using MATLAB LTI Transfer Function Block

04/02/2018 transfer_functions

http://localhost:8890/nbconvert/html/dev/EG-247-Resources/week3/transfer_functions.ipynb?download=false 9/9

In [17]:

bode(G)