0
\$\begingroup\$

I have been reading about stability and feedback systems, and a very silly issue has appeared. We can describe a negative feedback system as what can be seen in the following picture:

negative feedback system

Image source: Electronics Tutorials - Negative Feedback Systems

So here we will have that Vout = (Vin-B*Vout)*G

We can find the transfer function as Vout/Vin = G/(1+B*G)

The issue is... I know for a fact that a system with negative feedback should be stable, regardless of AB>1 or AB<1. But I've tried to simulate that in Python, and my signal oscillates and tends to infinity. The loop is running correctly, meaning if you perform the calculations by hand it gives those results.

enter image description here

For the Python simulation, I assumed an input of vin = 1, an initial state of vout=0, and G=105 and B = 0.01, which is over unity. At this point I tried to do some calculations to find how can I make the system not oscillate (and thus avoid positive feedback), but I obtained a result saying that GB<1, which I know for a fact isn't a requirement. I'll leave the calculations:

enter image description here

(This also includes the image, copied from Electronics Tutorials - Negative Feedback Systems)

I know I'm making a mistake somewhere, because if a perform the simulation in Matlab Simulink I get the results that I expect to obtain. For example, in the following image, you have first a system with positive feedback with GB>1 (which should be stable), secondly a positive feedback system with AB>1 (which should be unstable), and finally a positive feedback system with GB<1 (which should be stable). The results are attached and are exactly what I expected.

enter image description here

enter image description here

The question remains... Where is my mistake? Why isn't my Python script correct?

\$\endgroup\$
2
  • \$\begingroup\$ Simulink diagram has $$1/s$$. Where is it in the python code? Is $$G=105/s$$ or $$G=105$$. Both are different. \$\endgroup\$
    – AJN
    Commented Mar 29 at 16:41
  • \$\begingroup\$ I didn't check the link in the question, but I hope you are familiar with the topics of complex numbers, representation of signals and (linear, time invariant) systems, Laplace transforms, continuous time and discrete time systems before taking a dive into feedback systems. There are other, better, criteria for stability than AB<=>1 . \$\endgroup\$
    – AJN
    Commented Mar 29 at 16:54

1 Answer 1

1
\$\begingroup\$

The Python code, the handwritten notes, and the body of the question say that $$G=105$$. But Simulink diagram says that $$G=105 \cdot \frac{1}{s}$$.

Moreover, the Python actually does not implement either of the above situation. It appears to implement $$ x_n = vin_n - B \cdot vout_{n-1}\\ vout_{n} = x_n \cdot G = G \cdot vin_n - G \cdot B \cdot vout_{n-1}\\ $$ where n represents sample number or (discrete) time variable.

Tf = G/(1+GB) only if it was implemented as $$ x_n = vin_n - B \cdot vout_{\color{red}{n}}\\ vout_{n} = x_n \cdot G = G \cdot vin_n - G \cdot B \cdot vout_{\color{red}{n}}\\ \implies \left(1 + G \cdot B\right) vout_{n} = G \cdot vin_{n}\\ \implies \frac{vout_n}{vin_n} = \frac{G}{1 + G \cdot B} $$

i.e. simultaneous equations.

\$\endgroup\$
1
  • \$\begingroup\$ I agree with you. I believe the issue is that the Python script is using vout_{n-1} instead of vout_{n}. (Sorry for the formatting). I'll try to find a solution to that in Python, but basically I do believe you are right and my algorithm isn't implementing the correct procedure. Thank you. \$\endgroup\$ Commented Mar 29 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.