It's Hard to Build an Oscillator

(lcamtuf.substack.com)

46 points | by chmaynard 2 hours ago

10 comments

  • dvh 1 hour 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

    • seg_lolr 6 minutes ago
      Those are all Collpits LC oscillator variants, circa 1918. All LC oscillator topologies were thoroughly investigated more than a century ago, hundreds of books have been written about them. A little more humility please
    • webdevver 22 minutes ago
      this is always the risk of posting on hackernews: a random commentator absolutely iq mogs the op.
    • amelius 53 minutes ago
      Nice! Perhaps you could sort them based on Q-factor.
  • ofalkaed 35 minutes 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.
    • seg_lol 21 minutes ago
      > the trick is to be 7 years old and have far more ambition than skill

      Never lose this

      • hollerith 20 minutes ago
        Apologies for my bluntness, but in my humble opinion, American society would be better if it had fewer adults like this.
        • immibis 0 minutes ago
          Ambition develops skill. One of the problems with American society is people thinking they have skill when they don't. If people knew they had ambition and no skill, they'd try things and learn.
        • ofalkaed 13 minutes ago
          Being able to enjoy and find worth in the process regardless of the outcome is bad? Are we man-children if we don't treat everything as if it were as serious as cancer? I'm not really sure what you are trying to say.
  • kurthr 1 hour 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.

  • reactordev 41 minutes 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.
  • a5c11 23 minutes ago
    One of my favorite is an RC circuit with a Schmitt triggered inverter. So simple and ingenious.
  • Mizza 1 hour 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
    • ofalkaed 24 minutes ago
      Temperature sensitivity only matters in polysynths where you don't have easy access to per-oscillator tuning. It is not difficult to build an oscillator with better pitch stability than a guitar, even my VCOs with no temperature compensation require less tuning than any guitar I have owned.
      • Mizza 13 minutes ago
        But that's for synths where the oscillators are ICs. I'm talking about simple oscillators from basic components
  • eternauta3k 2 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.

    • Joel_Mckay 30 minutes ago
      Most use GPSDO references for equipment, as they are inexpensive. Even miniature TCXO tend to still offer quite good value these days. =3
  • IsTom 28 minutes ago
    I wish Esaki oscillator was mentioned. It's a funny bit of trickery.
  • atoav 2 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).

    • eternauta3k 1 hour ago
      Relaxation oscillators are easy, good phase shift oscillators are an art.