# Bubba Oscillator - Smooth sine curve generation

I am trying to simulate Bubba Oscillator using MATLAB, so far i have had success getting both sinusoidal and cosine curves from below circuit : I have used finite gain op-amp with gain = 100000; and rest of the values are marked in the circuit.

The results that i got were :  My questions are :

1.) How can i make the graphs more smoothers, instead of that peaky shape that they follow?

2.) How can i make the graphs with reference y point as 0 i.e symmetry about x-axis?

3.) How can i make the amplitude to -1 <--> +1?

Any help would be appreciated. Thanks in advance...

## 3 Answers

The issue is to do with displaying and something call refinement (more of an issue for variable timestep algorithms) under simulation -> model config -> data import/export ... there is an "additional parameters" expand. In there is "refine factor" which defaults to 1. Change this number  • +1, @JonRB Thanks , once again.. What about the other two of my questions? How do i make my amplitude +-1 & symmetry around x-axis? – Dravidian Oct 4 '17 at 8:33
• Can i manipulate something in my circuit to give the desired result??? – Dravidian Oct 4 '17 at 8:39
• To make it symmetrical use a blocking capacitor. To make it +-1V use a final gain stage (or change the internal gain of the oscilator) – JonRB Oct 4 '17 at 9:01

1) not sure of how ml works, but spice simulators are smart and regulate the time step depending on how confident they are of the solution they found. With (co)sinusoids they usually are very confident and you can see 4 or 5 points per period, connected by straight lines (linear interpolation). Solution: force Matlab to use your timestep, set it to 1/10 of the period or less.

2) either post process the data, subtracting the average calculated on a single whole period or on a large (100ish) number of periods, or AC couple your voltage probes. Since you are doing circuit simulation I would go with AC coupling. Put a big (some Fs) cap between the voltage probe and the node you wanna probe, and a big resistor (1G) to ground, on the voltage probe side.

3) This is not so easy. Try manually tuning the 1.4 M resistor and see if you can obtain reliable operation. If you want an automated circuit to do this for you, it is an entirely different question, search for Automatic Gain Control.

Well, no matter how small your time step will be, the circuit you are using is a phase shift oscillator and unless there is something in the circuit that limits the overall amplitude (like a non-linear device) the amplitude of the sine wave produced will tend to distort at the peaks as the op-amp output reaches saturation against the power rail.