Finding Transfer Function & Step Response with Matlab

Discussion in 'Homework Help' started by tquiva, Feb 20, 2011.

  1. tquiva

    Thread Starter Member

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

    [​IMG]

    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):

    [​IMG]

    I obtained H with the following Matlab code:

    Code ( (Unknown Language)):
    1. syms R1 R2 k R3 C1 C2 real; syms s;
    2. mat = [ 0                   ((1/R3)+(1)/(k*R3))     -(1/R3);
    3.         s*C1                -(s*C1-(1/R2))          1/R2;
    4.         s*C2+s*C1+(1/R1)    -(s*C1)                 -(s*C2);];
    5. vec = [0;
    6.        0;
    7.        1/R1;];
    8. H=[0 0 1]*inv(mat)*vec,[n,d]=numden(H), p=solve(d,s),Rc=solve(p(1)-p(2),R)
    9. pretty(H)
    10.  
    11.  
    My transfer function seems rather long and large. But can someone please clarify that is it correct ?

    Many thanks in advance.
     
  2. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    The final answer doesn't look correct. Also, your second equation appears to have a sign error.
     
  3. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    but is my Matlab code correct?
     
  4. tquiva

    Thread Starter Member

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

    My Matlab code is:
    Code ( (Unknown Language)):
    1. %Transfer Function
    2. syms R1 R2 k R3 C1 C2 real; syms s;
    3. mat = [ 0                   ((1/R3)+(1)/(k*R3))     -(1/R3);
    4.         -(s*C1)             (1/R2)+(s*C1)           -(1/R2);
    5.         s*C2+s*C1+(1/R1)    -(s*C1)                 -(s*C2);];
    6. vec = [0;
    7.        0;
    8.        1/R1;];
    9. H=[0 0 1]*inv(mat)*vec;
    10. pretty(H)
    and my value for H is:

    [​IMG]

    Is this correct now?
     
  5. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    Without checking all details for sure, I'd say it looks correct.
     
    tquiva likes this.
  6. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    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: Feb 21, 2011
  7. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    Thank you. Would you happen to know how I would go about finding possible type of step responses?
     
  8. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    Does this mean my answer is incorrect?
     
  9. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    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.
     
  10. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    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:

    Code ( (Unknown Language)):
    1. % Step Response
    2. R1=1; R2=1; C1=1; C2=1; k=1;
    3. nH = [0                0                                           C1*R2*(k+1)];
    4. dH = [C1*C2*R1*R2      C1*R1+C2*R1-k*C1*R2                         1];
    5. subplot(221)
    6. step(nH,dH),xlabel('t'),ylabel('step(t)'),title('Step Response for R=C')
     
  11. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    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
     
  12. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    So basically I would just have to try and find underdamped and damped cases?
     
  13. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    I agree about the R2. My eyes missed that typo. But the negative sign doesn't seem right because it's a noninverting configuration.
     
  14. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    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.
     
  15. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    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.
     
  16. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    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?
     
  17. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    I tried to find the roots and this was my result:
    Is it correct?

    [​IMG]
     
  18. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    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.
     
    tquiva likes this.
  19. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    Could someone please please clarify if my value for s is correct?
     
  20. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    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.
     
Loading...