# Sine generator - Bubba Oscillator

I am trying to simulate a Bubba Ocsillator on MATLAB, Simulink . The problem is that i am not able to generate the sinusoidal from the circuit.

This below is my circuit :

And this below is my result(Simulated for 10sec) :

Zoomed result(Simulated for 10sec) :

Where did i go wrong? How to achieve a pure sinusoidal waveform from this bubba oscillator...

• What happens after that..... – Trevor_G Oct 3 '17 at 18:57
• What you see is the oscilator starting. Set more time for the simulation. – Martin Petrei Oct 3 '17 at 19:01
• After setting 100 sec as simulation time, the amplitude goes to infinity and at around 51 sec, Derivative of state at time 51.62098161663971 is not finite. The simulation will be stopped. This is the error message. – Dravidian Oct 3 '17 at 19:03

You have created an ideal (infinite bandwidth OPAMP, infinite output voltage etc...) model which is conditionally stable & executed it.

look at your y-axis, it has reach 1.5x$10^{59}$ HUGE!. This is what is causing an exception... its run out of resolution to represent this unstable "oscilator"

IF a closer to reality OPAMP is used (+-15V, gain limited to 100,000) it behaves

• +1, Thanks a lot mate, can you please show me the values that u have used in your circuit... Thanks once again – Dravidian Oct 3 '17 at 20:23
• uuur... exactly the same as yours (just simulink is rubbish at displaying them ...) I have the design file I can upload. NOTE: you will need Simscape-Electronics if you want a band-limited OPAMP – JonRB Oct 3 '17 at 20:25
• ufile.io/fp62o – JonRB Oct 3 '17 at 20:26
• So sorry to bug you, i am using MATLAB 2015 b, can you upload the file in previous version if thats not much trouble, if not, never mind.. thanks for the help though...*File>Export Model to>Previous Version*, in any case whats the amplitude gain that you used in your op-amps? – Dravidian Oct 3 '17 at 20:31
• ufile.io/lyvkj – JonRB Oct 3 '17 at 21:59

It does oscillate, you can see that it does on the right side of the plot. If you zoom in on the left side you should also see the oscillation but at a much smaller amplitude.

Your misconception comes from the fact that you first have to understand the theory of operation of oscillators.

This states that an oscillator oscillates when the loopgain is more than 1.

For the Bubba oscillator this is the case.

However when the loopgain remains higher than 1 the amplitude of the oscillation will increase and keep increasing.

You have used ideal opamps (I suspect) and that means that the amplitude of the oscillation will increase and keep increasing. That's what your plot shows.

In the article about the Bubba oscillator the author uses real opamps. These opamps cannot generate infinite voltages so at some voltage their output voltage will be less than what you would ideally expect. And that means the loopgain becomes smaller. Such an oscillator with real opamps will stabilise its signal amplitude on the point where the loopgain is precisely one.

And that will result in a stable amplitude.

So the solution to your problem is: use (models of) less ideal opamps.

• By real op-amps, do you mean finite gain op-amp? Sorry, i am quite new at electronics... – Dravidian Oct 3 '17 at 19:13
• +1 So what y'all is saying is real op-amps is like Bubba's poorer cousin.... ;) – Trevor_G Oct 3 '17 at 19:13
• No I do mean finite gain opamps, but try it and see if it helps, it won't. What is needed is a limitation on the output voltage. In a real opamp it will be the output transistors running out of current/voltage. This is not that easy to model (I know, I have tried). You could put a hard limit on the output voltage of the opamps like -10 < Vout < +10. But this will probably result in a distorted sinewave. Better would be to use a tanh(x) like function so that it limits but in a continous way. – Bimpelrekkie Oct 3 '17 at 19:22
• @Trevor Yeah, strangely enough this oscillator relies on the non-ideal properties of the opamps. – Bimpelrekkie Oct 3 '17 at 19:23
• Bimpelrekkie - that is not the case. The only property which is important is an amplitude limitation due to the power supply rails. Surprisingly, such a "hard-limiting" will cause only a slight distortion because the loop will adjust itself to a loop gain of unity. A drastic improvement (reduction) of distortion is possible when we use two different supply rail voltage pairs and when the ouput is taken from the block with the larger supply voltage (limiting effect in the block with smaller supply voltages.) This effect cannot be found in the literature. – LvW Oct 4 '17 at 12:12

It has started to oscillate. The amplitude grows exponentially. Simulation is stopped when some current, voltage or internal variable reaches the limit of the available number range.

Take a couple of zener diodes connected in series having the anodes against each other. Insert that limiting circuit in parallel with one of the capacitors. The amplitude does not grow any more to infinity.

This is not a good solution if you need low distortion sinewave. A good analog sinewave oscillator has a specially designed contol circuit which checks the output amplitude and reduces the gain until output amplitude is the wanted. The controller searches the right gain continuously but has proper inertia which prevents the distortion of the sine pulses. In control theory they call it PI controller. It needs a voltage contolled component which has variable gain, attenuation or resistance. I have seen in practical circuits even a NTC resistor used here.

In Simulink you can take a rectifier, feed it from your sinewave, pump it's output to a long timeconstant RC integrator and replace one of your voltage followers with a circuit that has normally gain=1, but reduces the gain with a steep slope as soon as the voltage in the RC integrator exceeds a certain limit.

Unfortunately I havent Matlab nor Simulink, only washy low-cost imitations, but it works there.

Just to add yet another post on this. Here's a circuit that should actually work, using a quad LT1631 and a single power supply rail:

simulate this circuit – Schematic created using CircuitLab

The output frequency should be close to about $\frac{1}{2\pi R C}$ or near $15.9\:\textrm{kHz}$ for the given values of $R=1\:\textrm{k}\Omega$ and $C=10\:\textrm{nF}$ shown in the above schematic.

Here's the output from LTSpice:

You should be able to replicate similar results in your own simulator.

(For a cheaper arrangement, try the TI LMV324IPWR quad package device, instead.)