Finding Transfer Function & Step Response with Matlab

Thread Starter

tquiva

Joined Oct 19, 2010
176
Could someone please help me with this problem?



I first started by finding the transfer function of the circuit.
I called the top node X, the + terminal of the op amp is Y, the - terminal is H, and the input is Vs and the output is Vs.
With nodal analysis at each node, I came with the following equations and value for H(s):



I obtained H with the following Matlab code:

Rich (BB code):
syms R1 R2 k R3 C1 C2 real; syms s;
mat = [ 0                   ((1/R3)+(1)/(k*R3))     -(1/R3);
        s*C1                -(s*C1-(1/R2))          1/R2;
        s*C2+s*C1+(1/R1)    -(s*C1)                 -(s*C2);];
vec = [0;
       0;
       1/R1;];
H=[0 0 1]*inv(mat)*vec,[n,d]=numden(H), p=solve(d,s),Rc=solve(p(1)-p(2),R)
pretty(H)
My transfer function seems rather long and large. But can someone please clarify that is it correct ?

Many thanks in advance.
 

steveb

Joined Jul 3, 2008
2,436
Could someone please help me with this problem?



I first started by finding the transfer function of the circuit.
I called the top node X, the + terminal of the op amp is Y, the - terminal is H, and the input is Vs and the output is Vs.
With nodal analysis at each node, I came with the following equations and value for H(s):



I obtained H with the following Matlab code:

Rich (BB code):
syms R1 R2 k R3 C1 C2 real; syms s;
mat = [ 0                   ((1/R3)+(1)/(k*R3))     -(1/R3);
        s*C1                -(s*C1-(1/R2))          1/R2;
        s*C2+s*C1+(1/R1)    -(s*C1)                 -(s*C2);];
vec = [0;
       0;
       1/R1;];
H=[0 0 1]*inv(mat)*vec,[n,d]=numden(H), p=solve(d,s),Rc=solve(p(1)-p(2),R)
pretty(H)
My transfer function seems rather long and large. But can someone please clarify that is it correct ?

Many thanks in advance.
The final answer doesn't look correct. Also, your second equation appears to have a sign error.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
Ok, I changed my 2nd equation:

My Matlab code is:
Rich (BB code):
%Transfer Function 
syms R1 R2 k R3 C1 C2 real; syms s;
mat = [ 0                   ((1/R3)+(1)/(k*R3))     -(1/R3);
        -(s*C1)             (1/R2)+(s*C1)           -(1/R2);
        s*C2+s*C1+(1/R1)    -(s*C1)                 -(s*C2);];
vec = [0;
       0;
       1/R1;];
H=[0 0 1]*inv(mat)*vec;
pretty(H)
and my value for H is:



Is this correct now?
 

steveb

Joined Jul 3, 2008
2,436
Ok, I changed my 2nd equation:

My Matlab code is:
Rich (BB code):
%Transfer Function 
syms R1 R2 k R3 C1 C2 real; syms s;
mat = [ 0                   ((1/R3)+(1)/(k*R3))     -(1/R3);
        -(s*C1)             (1/R2)+(s*C1)           -(1/R2);
        s*C2+s*C1+(1/R1)    -(s*C1)                 -(s*C2);];
vec = [0;
       0;
       1/R1;];
H=[0 0 1]*inv(mat)*vec;
pretty(H)
and my value for H is:



Is this correct now?
Without checking all details for sure, I'd say it looks correct.
 

t_n_k

Joined Mar 6, 2009
5,455
I have the following answer by an alternate method

\(H(s)=\frac{-(1+K)R_1R_2C_1s}{R_1R_2C_1C_2s^2+(R_1(C_1+C_2)-KR_2C_1)s+1}\)

The only difference seems to be in the overall sign and the additional R2 in the numerator. The denominator is the same.

I have my doubts about the R2 term really being there.
 
Last edited:

Thread Starter

tquiva

Joined Oct 19, 2010
176
I have the following answer by an alternate method

\(H(s)=\frac{-(1+K)R_1R_2C_1s}{R_1R_2C_1C_2s^2+(R_1(C_1+C_2)-KR_2C_1)s+1}\)

The only difference seems to be in the overall sign and the additional R2 in the numerator. The denominator is the same.
Does this mean my answer is incorrect?
 

t_n_k

Joined Mar 6, 2009
5,455
After another try I have

\(H(s)=\frac{-(1+k)R_2C_1s}{R_1R_2C_1C_2s^2+(R_1(C_1+C_2)-kR_2C_1)s+1}\)

So I have R2 in place of your R1 in the numerator. I'll check by simulation to see if I can get a consistent answer & then come back.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
I just checked again also. That's the answer I got. I guess I may have typed R1 in place of R2 by mistake. Thanks so much!

Do you know how to find possible types of step responses for this?
Would I do this just by putting in different values for the resistors and capacitors?

So far, I have this for my matlab code:

Rich (BB code):
% Step Response 
R1=1; R2=1; C1=1; C2=1; k=1;
nH = [0                0                                           C1*R2*(k+1)];
dH = [C1*C2*R1*R2      C1*R1+C2*R1-k*C1*R2                         1];
subplot(221)
step(nH,dH),xlabel('t'),ylabel('step(t)'),title('Step Response for R=C')
 

t_n_k

Joined Mar 6, 2009
5,455
I guess the value of K in relation to other values will have a significant effect on the step response. The coefficient of the 's' term in the denominator can be made zero or even negative (for instance) by adjusting k in relation to other values, which will have a significant effect on the circuit stability.

One could make the damping zero by selecting values to make

\(R_1(C_1+C_2)= kR_2 C_1\)
 

steveb

Joined Jul 3, 2008
2,436
After another try I have

\(H(s)=\frac{-(1+k)R_2C_1s}{R_1R_2C_1C_2s^2+(R_1(C_1+C_2)-kR_2C_1)s+1}\)

So I have R2 in place of your R1 in the numerator. I'll check by simulation to see if I can get a consistent answer & then come back.
I agree about the R2. My eyes missed that typo. But the negative sign doesn't seem right because it's a noninverting configuration.
 

Georacer

Joined Nov 25, 2009
5,182
In order to find the step response \(Y(s)=H(s) \cdot \frac1s=\frac{-(1+k)R_2C_1}{R_1R_2C_1C_2s^2+(R_1(C_1+C_2)-kR_2C_1)s+1}\), you can factor the denominator by finding its roots. The roots are a function of k, which will determine if they will be real or imaginary. Of course that will describe the behaviour of the system.

Afterwards, break into simple fractions, using the residue calculation technique, and look up an inverse Laplace transformation table to find the response in the time-domain.
 

steveb

Joined Jul 3, 2008
2,436
... The roots are a function of k, which will determine if they will be real or imaginary. Of course that will describe the behaviour of the system.
Yes, and another key think about the factor "k" is that it controls the negative term in the denominator of H(s), and hence impacts stability. Stablity is indicated by whether the real part of the pole is positive or negative. Basically, any net negative coefficient for the polynomial in the denominator will indicate instability, as a quick rule of thumb test, and a full factorization of the roots will verify this. The value of "k" becomes an independent control on the stability. Clearly, this system has positve feedback (i.e. the negative term in the denominator) and sufficient negative feedback (controlled by "k") is needed to stabilize the system.

By the way, I'm still questioning the negative sign that has cropped up in the transfer function. I still say this is incorrect because this configuration has a classic non-inverting structure. If anybody disagrees about this, please explain why.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
In order to find the step response \(Y(s)=H(s) \cdot \frac1s=\frac{-(1+k)R_2C_1}{R_1R_2C_1C_2s^2+(R_1(C_1+C_2)-kR_2C_1)s+1}\), you can factor the denominator by finding its roots. The roots are a function of k, which will determine if they will be real or imaginary. Of course that will describe the behaviour of the system.

Afterwards, break into simple fractions, using the residue calculation technique, and look up an inverse Laplace transformation table to find the response in the time-domain.
When you say factor the denominator by finding its roots, do you mean setting the equation in the denominator to equal 0, then solving for s?
 

t_n_k

Joined Mar 6, 2009
5,455
I agree about the R2. My eyes missed that typo. But the negative sign doesn't seem right because it's a noninverting configuration.
Yes, that's somewhat distracting. I've checked my equations several times. I've also run simulations of the circuit with particular values and cross-checked with a bode plot of the straight transfer function. The results are consistent with there being a negative sign.
 

steveb

Joined Jul 3, 2008
2,436
Yes, that's somewhat distracting. I've checked my equations several times. I've also run simulations of the circuit with particular values and cross-checked with a bode plot of the straight transfer function. The results are consistent with there being a negative sign.
Yes, you are correct. I can see now that the neg sign in the term of the denominator will recover the noninverting amplifier function.

Simply set R1=C2=0 and take limit as R2 and C1 go to infinity and the noninverting amp formula is correctly obtained. Missed it again- thank you t_n_k.
 
Top