It's hard to build an oscillator

lcamtuf.substack.com

210 points by chmaynard 16 hours ago


ErroneousBosh - 13 hours ago

> There’s an old electronics joke that if you want to build an oscillator, you should try building an amplifier

It's funny, I was just thinking this morning about an old article in (I think) Television magazine that I read in the 80s when I was getting into electronics. The author was talking about some service notes he'd received for a particular model of Philips radio, which had just come out, and it was when shops tended to have their own service department that would repair things right there in the shop - and also, apply any "factory fixes".

One such fix was described as "Fix VIUPS", and involved changing a couple of resistors and adding a couple of capacitors. Not really any difference, but the author did think it seemed to make the amp a bit more stable and less inclined to make squealy ploppy noises at high volume when the battery was low. But, curiosity got the better of him, so he rang the Philips rep - what's this "VIUPS"?

No idea. But I'll get hold of someone at head office you can ring. Okay, what's this "VIUPS" thing? No idea, said the head office guy, but I can put you in touch with one of the factory engineers in Eindhoven.

So, a call came in, an international call! Quite a big deal in the 80s. "What's this VIUPS Fix thing in the service notes?" he asked the guy.

"Aha yes", he said in a heavy Dutch accent, "the VIUPS is the noise the set makes when the fault is present."

VIUPS VIUPS VIUPS. Yup.

dvh - 14 hours ago

It's super easy to build LC oscillator.

I made a program that generate random topology and uses spice simulation to find if it oscillate. The goal was to find some novel LC oscillators. It worked, it found many different oscillators. I let it ran for a while and soon I found out that the simplest possible LC oscillator has 1 inductor, 2 capacitors, 1 resistor and 1 transistor. I found many different variations of it, I called this class of oscillators "LCCRT oscillator" and it also always had 2 internal nodes so that's not very large search space (40000 combinations) so I generated all possible combinations and I found out there are exactly 12 distinct LCCRT topologies.

Basically any time cap connects to a rail it can be placed to other rail as well, and any time one rail connects via resistor, the resistor can also be moved to other rail. This creates 12 possible combinations. I tested them in real life and they are stable, even used one in metal detector.

Of course it found many different topologies. Some times they were unique, other times they could be simplified into already found oscillator. It can also use multiple transistors not just one. You can find entire project on github, it is a ngspicejs script: https://github.com/dvhx/lc-oscillator-finder

ofalkaed - 13 hours ago

When I was starting out in electronics I found the easiest way to build an oscillator was to build an amplifier and the easiest way to build an amplifier was to build an oscillator. I guess the trick is to be 7 years old and have far more ambition than skill. Couldn't guess at how many tries it took me to make an amplifier that didn't oscillate and when I moved onto oscillators, they never oscillated but they did amplify. In that first year or so, I couldn't actually read resistor color codes, but I thought I could.

summa_tech - 5 hours ago

I wanted to give a quick explanation of the odd and off-hand "lightbulb" comment in the article. Why would an oscillator need a lightbulb? Especially since the article does not get into the weeds of building oscillators that would actually care about this.

A somewhat difficult part of making (moderate-frequency) analog oscillators is getting a clean sinewave without harmonics. It sounds like the easiest thing in the world: a delay, a low-pass filter, a linear amplifier that compensates for the loss in the delay and filter, and boom, sinewave. You can even put the low-pass filter and the delay in a single phase shifter circuit.

The difficulty is hidden in the "compensates for the loss" language. If you amplify too little, your oscillation will decay. If you amplify too much, you will inevitably saturate the amplifier, introducing lots of harmonics (like a squarewave output in the article). So you need some way to stabilize your gain at exactly the right level.

A lightbulb is an interesting device: it is a very linear resistor at short timescales, but nonlinear at long timescales. As the filament heats up, resistance rises. The thermal constant can be fairly substantial, certainly more than kHz or MHz oscillator frequencies. So you can exploit this sweet and clean nonlinearity to produce an oscillator that self-stabilizes!

Design your circuit so that the amplifier gain is controlled by lightbulb's resistance (which is quite easy: you use the lightbulb as one of the gain-setting resistors). And boom, pretty much a perfect sinewave.

kurthr - 14 hours ago

Building an oscillator is "just" putting some gain around a large enough phase delay (>90deg). The challenge is in making the oscillator predictable and STABLE.

You want a frequency generator that oscillates with a constant period/frequency. Even an unbalanced oscillator can just be divided by two to provide uniformity. However, it turns out that building something that is not sensitive to any outside inputs (temperature, strain, voltage, time, etc) is really hard to do over a very wide frequency range (from ~DC to many MHz), but from that you can build a stable clock.

Look up Allan Variance, if you're looking for bit of a rabbit hole on clocks and oscillators and other sensors.

highspeedbus - 10 hours ago

I've build a signal injector to debug a guitar pedal that was not working. It was a nice little journey in itself. The astable multivibrator produces so much harmonics that I could hear it all the way back from the input jack, where it was supposed to be silent. Heck, I could hear it just by putting the probe nearly close to the circuit. The signal pushed through the circuit like Juggernaut breaking walls. Learned a lot about filters and was able to produce a nice sine wave out of it, it worked great.

dragontamer - 3 hours ago

Oscillators are hard because our specs on oscillators are absurd.

Let's take the common watch circuit. Conceptually it's just like 5 components: crystal, a few capacitors, a NOT gate/transistor/amplifier. Introduce 180-degree phase shift at the 32.768k target frequency and bam, oscillator.

Except not really. A clock is expected to have a drift in the region of 100 ppm (or 0.001% error), or lose a second per day or so. That's the hard part, building something that accurate and consistent.

There are also startup specs, power specs (less power is harder. More power helps startup....) etc. etc.

-------

If you just need something to oscillate back and forth randomly, try making a noise generator lol, it will oscillate wildly at many frequencies, one of which might have been the frequency you wanted.

---------

The 555 timer is perhaps the easiest oscillator for a beginner if you are willing to put up with +/-10% drift. It's honestly good enough for far more applications than you might expect.

Even without the premade chip, a 555 timer is just 2x comparators (analog version of an If statement), a 33%/33%/33% voltage divider, and a capacitor. If Voltage > 66% input voltage, remove power from capacitor. If Voltage < 33% input voltage, add power to capacitor. Bam, you now have an oscillator that is accurate to the +/-10% capacitance values of your electronics kit.

Alas, modern circuits need to be faster and more accurate than the humble 555. But a beginner article about oscillators should be about the 555, rather than about opamp or transistor based oscillators.

ErroneousBosh - 12 hours ago

Two things not mentioned - hey maybe I should blog about these myself and post them up?

The first being the "Two Transistor Metronome" that I can't even remember where I saw first - possibly Electronics Today International or Hobby Electronics, although Practical Electronics was a contender - we didn't get that one much though. I remember my dad and I building this when I was probably about seven or eight, and I've built loads since.

https://tinyurl.com/22qjecj7

It's a relaxation oscillator where the two transistors form more-or-less an SCR, which fires when its (negative-going) gate voltage exceeds its anode voltage. Kind of.

A similar circuit using three transistors and a diode is used in the oscillators in the Roland TB303 and Korg MS10/20/50 series, with a current source used to set the capacitor charging time so you get a nice linear sawtooth. Conveniently the expo converter turns an incoming control voltage into an exponentially-rising current, which is just what you need!

stevetron - 8 hours ago

In some reading I did several (decades) years ago, I read how the invention of the oscillator was an accident. Someone was building an amplifier, and made a wiring error that was described as connecting the amplifier's input to the amplifier's output and it produced a squeal.

Up until that time, radio frequency carriers were produced with AC Generators designed for a high-frequency (> 60 Hz) output. That is in part why it took so long for things like music to be broadcast by radio: you needed a high-frequency carrier. Generators were topping out at about 15K Hz according to the old article I read.

So once they had the accidental circuit that squealed, it was studied and expermented upon (trial and etrror modifications), and that is where all the 'classic' oscillator circuits originate.

Essentially, an oscillator is an amplifier with positive feedback. Amplifiers that are amplifiers sometimes have negative feedback.

lm2s - 13 hours ago

For anyone interested in this kind of stuff with a music oriented gist, a while ago I found this awesome YouTube channel: https://www.youtube.com/@MoritzKlein0/

eternauta3k - 15 hours ago

I was hoping this would go more into startup and amplitude control, which are for me the tricky parts of building a phase shift oscillator (because you have to analyze the non-linear behavior).

I guess hobbyists nowadays are just using SI5351 and calling it a day.

a5c11 - 13 hours ago

One of my favorite is an RC circuit with a Schmitt triggered inverter. So simple and ingenious.

IsTom - 13 hours ago

I wish Esaki oscillator was mentioned. It's a funny bit of trickery.

Mizza - 14 hours ago

Never found it hard to build an oscillator, the hard part is musical voltage per octave. 3340 repro chips are the way to go, the best non-3340 circuit I've seen is this one and it's still temperature-sensitive: https://www.youtube.com/watch?v=FiCMjt0mqvI

ur-whale - 36 minutes ago

My all time favorite analog oscillator is the Twin-T (the one with a BJT) [1]

It was hard to get a proper intuition of how and why it works, but when you finally do ... fireworks!

Another thing that's real fun with oscillators is to try and build a true chaotic oscillator, but only with R+C+BJT

Not easy, but can be done [2]

[1] https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj...

[2] https://www.instructables.com/A-Simple-Chaos-Generator/

parsimo2010 - 7 hours ago

It's great to do experimentation because you get to learn a lot, but at the end of the day stick with well-studied designs if you're making a something you want to use. The oscillators mentioned below all have well known strengths and weaknesses:

The author mentions that they consider a center-tapped inductor to be "fancy," but if you consider a regular inductor to be fair game, then the Colpitts oscillator is a good choice. And I suppose you could build a Hartley oscillator with two inductors rather than one center-tapped inductor.

If you consider op-amps to be fair game even though it is made from multiple transistors, then you might consider digital logic to also be fair game and should consider a Pierce oscillator. I'm also assuming that a crystal is also fair game, but those are quite cheap.

Side note- these oscillators are all part of the exam material for the Extra class amateur radio license in the USA. If you find lcamtuf's Substack interesting, then amateur radio might be for you.

crmd - 5 hours ago

The bring up of seemingly every tube guitar amp i’ve ever built starts with wild oscillation due to negative feedback from the wrong transformer secondary, aka positive feedback. Gets me every time.

JJMcJ - 3 hours ago

Also if it oscillates does it oscillate at the frequency you want?

- 8 hours ago
[deleted]
kazinator - 6 hours ago

It's not hard to build an oscillator. Just focus on designing an amplifier, and stop chasing oscillation.

reactordev - 13 hours ago

As someone with a CS degree and not an EE degree, this is fascinating. I tried a decade ago to build some simple RC lights controller circuit that would operate off of a PWM signal and failed. Hats off to you hardware folks. Manipulating atoms and electrons and building circuits that allow us to play games, build businesses, communicate with loved ones, and write this post.

jhallenworld - 10 hours ago

Easy negative resistance oscillator: a neon bulb in parallel with a capacitor connected to a DC power supply through a resistor.

fjfaase - 12 hours ago

I remember creating an oscilator by soldering a transistor onto an inductor with two windings in series with loudspeaker an battery.

atoav - 15 hours ago

Coincidentally I thought a class of art students just yesterday how to build oscillators. And it is not hard at all. Take a logic inverter IC (CD40106 Schmitt-Trigger Hexinverter) pick a single gate, connect the output to the input, add a capacitor from the input to ground. That is it. Three parts and you got a Relaxation Oscillator. And then you have 5 inverter gates left.. But of course one could argue ICs are cheating, since any PLL-IC would have an oscillator onboard.

Why the first two circuits fail is also pretty obvious without derper circuit analysis: to get reliable oscillation you don't only need amplification, you also need some time setting element, usually in the form of a capacitor (or involuntary capacitance).

- 10 hours ago
[deleted]
temp0826 - 12 hours ago

As the famous one-liner from EE goes- if you want to build an oscillator, build an amplifier; if you want to build an amplifier, build an oscillator.

Zardoz84 - 11 hours ago

> The circuit can be simplified to two transistors at the expense of readability, but if you need an analog oscillator with a lower component count, an operational amplifier is your best bet.

Well... Using a NOT (really a NAND) gate was a very classic way of generate clocks for discrete logic.

- 14 hours ago
[deleted]
ZyanWu - 13 hours ago

What intrigued me was the "just use a microcontroller" comment at the bottom of the page - I genuinely don't know if it was pinned because it's a joke, a genius idea or just top 10 dumbest comments of 2025

jason-richar15 - 5 hours ago

[dead]

tony-john12 - 9 hours ago

[dead]

readingnews - 8 hours ago

It is hard to put into words how so many people "out there" can print things, have people read them, and they are so worded that the average person is probably reading this as "the truth".

> but it’s rather difficult to build a good analog oscillator from scratch. The most common category of oscillators you can find on the internet are circuits that simply don’t work. This is followed by approaches that require exotic components, such as center-tapped inductors or incandescent lightbulbs.

It is not hard to build a good analog oscillator from scratch, we have been doing this for decades. Secondly, while an incandescent _might_ be considered exotic, and completely unnecessary for an oscillator, a center tapped inductor is totally not exotic, and also, not really necessary for an oscillator.

As others have noted, it is simple to build a really good analog oscillator. This article is blah, and "meh" at best.