Gas station without pumps

2018 June 3

VCO (voltage-controlled oscillator)

Filed under: Circuits course — gasstationwithoutpumps @ 11:01
Tags: , , , ,

My students requested that I talk about voltage-controlled oscillators (VCO) and low-frequency oscillators (LFO) for audio work in my applied electronics course.  (We’re in the last week, and they have everything they need to know for the final EKG lab.)

I spent some time Friday night and this morning designing, building, and testing a couple of VCO circuits—one for which frequency is linear with voltage and one for which frequency is exponential with voltage.  Both can easily be turned into low-frequency oscillators by increasing the size of one capacitor.

The oscillators have two outputs: a square wave and a triangle wave. I chose a triangle-wave oscillator, because the design is simpler than for sine waves, and the students have all the concepts they need to understand the design.

The oscillator consists of two parts: an integrator to convert a constant current input into a constant slope: dV/dt = I/C, and a Schmitt trigger to change the current from positive to negative.  Rather than using a Schmitt-trigger inverter chip, I made the Schmitt trigger from an op amp (a comparator would give crisper transitions, but that is not important at the low speeds we’re dealing with).

This design has the frequency linear with the voltage.

The op amp in the upper-left corner is a unity-gain buffer to isolate the input from the rest of the circuit.  It isn’t really needed in this design, and it limits the input voltage range to the power-supply voltage (I used 3.3V).

The next op amp is the integrator, which turns an input current into a constant slope on the output voltage.  The current through the capacitor is 10nF dV/dt.

When the FET is turned off, the current flows through R6+R7, and I= (Vin/2 – Vin)/ (R6+R7), so dV/dt = – Vin/(2* 10nF * 6.6kΩ) = -Vin / 132µs.

When the FET is turned on, the current is the difference between the current through R8 and through R6+R7, and so is (Vin/2)/R8+(Vin/2 – Vin)/ (R6+R7), which simplifies to Vin/(2*6.6kΩ), and dV/dt = Vin/132µs.

The lower-right op amp is an inverting Schmitt trigger with thresholds at 1/3 and 2/3 of Vdd.  It turns on the nFET when the voltage of the triangle wave has dropped below the lower threshold and turns it off again when the voltage has risen above the upper threshold.

The upper-right op amp is just a unity-gain buffer to isolate the output from the oscillator.

My first attempt at this design used larger resistors for R6=R7=R8 and a smaller capacitor, but it had problems when the nFET turned off—the voltage continued to rise for a little while.  The problem was that the drain of the FET had to be charged through R6+R7 before the current through the capacitor was reversed, and this took too long.  Shrinking the resistors made the capacitance on the drain of the FET much less important.

This design has the frequency exponential with voltage (about one octave per 70mV).

The oscillator design is the same as for the linear one, but the diodes provide an exponential current from the input voltage. The input unity-gain buffer is now important, as it provides current limiting to prevent damage to the diodes.  To get double the current through the FET when it is turned on, the diodes are put in parallel on the lower leg (a series arrangement on the upper leg like for the resistors would not halve the current).

I tested both circuits and they seem to work ok, with duty cycles close to 50% for the square wave.  There are slight high-frequency glitches at the peaks of the triangle wave, so it may be worth replacing the output unity-gain buffer with a 40kHz low pass filter.

This is a fairly high frequency from the diode-controlled oscillator (15.431kHz) and the duty cycle is a bit off (59.36%), because the current has gotten large enough that the on-resistance of the nFET matters.

At 500mV, the frequency is 25.77Hz, the duty cycle is about 48%, and the glitches are not visible at this time scale.

I measured and plotted the frequency as a function of voltage for VCO with diodes:

The fit is done here omitting the lowest and highest points. I believe that the highest point has hit the current limits of the input unity-gain buffer, and so is not on the straight line.

The frequency scaling of the diode-based VCO could be changed by replacing the input unity-gain buffer with an amplifier with a different gain.

(2018 June 23: I feel compelled to point out that this circuit does not have any thermal compensation, and the exponential conversion of voltage to current in the diode junctions is highly temperature sensitive.  I’ll try this summer to redesign the circuit to have temperature compensation, though the use of 3 diodes here makes that difficult—a sawtooth oscillator, with only diode would be somewhat easier.)


2013 March 23

Triangle-wave oscillator

Filed under: Circuits course — gasstationwithoutpumps @ 23:09
Tags: , , ,

One of the student suggestions from the “bar exam” was to design a protoboard for the class D amplifier, so that they could keep it as a permanent object (a more useful one than the pressure-sensor amplifier, since they don’t have any strain gauges).

I’ve been thinking about that and see a few problems:

  • The block diagram the students came up with this fall (with my guidance) calls for 3 power supplies, which makes the amplifier a bit impractical to power from a battery or wall-wart power supply.
  • The students used an external triangle-wave generator.
  • The protoboard would have to be fairly large to accommodate the FETs and inductor and enough wiring space, which would probably result in a larger board than 5cm × 5cm, and so $2/board rather than $1/board.

I’ve not given much thought yet to the power-supply problem, but I did think a little about the triangle-wave generator.  Since they only need to generate triangle waves at a single frequency (in the 60kHZ–100kHz range), it should be possible to use a hysteresis oscillator with an integrator rather than a simple RC timing circuit.  Something like the following might work:


The slew rate of the MCP6004 op amps is only 0.6 V/µs, but the triangle wave only swings from VIL to VIH, or about 1V, so the minimum period is about 3.3µs, for a maximum frequency of 300kHz. If we use another op amp to amplify the signal to make it swing almost 5v, instead of 1V, the maximum frequency would be only 60kHz.

I might want to try this circuit out this week, to see if it is worth having the students play with next year.

Blog at

%d bloggers like this: