Sunday, January 17, 2010

Three Transistor Ring Oscillator

I don't remember how it came up tonight, but somehow I ended up looking at the pendant Drew built back in October out of UV LEDs and a uranium glass marble.  It's a very cool project, and I urge you to go check out his photos and video of it in action (and schematic!).

The electronics in it form what is called a ring oscillator.  A ring oscillator is an odd number of inverters connected in a circle.  Each inverter outputs the opposite of its input, but since there is an odd number, it's never stable, and will oscillate.  Its frequency depends on how much you slow down the signal by using resistors and capacitors.  If there was an even number of inverters, note that it would be stable, which isn't useful for an oscillator, but can be used to store information, and is known as SRAM.

Looking at Drew's schematic, I realized that with a little digging, I probably had all the parts to build the same oscillator, though with only three stages instead of seven.  I also don't have any uranium marbles or UV LEDs sitting around, so we'll have to settle with the significantly less awesome bright red.  I've tried to build this circuit before using a 7404 inverter instead of discrete components, but didn't quite grasp the concept at the time enough to get it to work.

The keen eye will note that I used IRF630 MOSFETs, instead of the 2N7000s he did. This is because I tried to use the last of my 2N7000s to build it, but managed to smoke them in the process (first time using 7000s; turns out the pinout wasn't quite what I expected.). A keener reader will note that IRF630s are rated for 9 amps, which means using them to switch 15mA LEDs is some kind of silly.  They were all I had in my junk box; don't mock me.

And yes, my hand drawn schematics are unfortunate, but I'm still not happy with any of the CAD programs I've been experimenting with, so it's either this or nothing tonight.

Video

14 comments:

  1. Cool!
    Am I right in assuming (I don't know a whole lot about electronics) that the arrows at the top of the diagram and the ground symbols connected to the capacitors and transistors are positive and negative respectively?

    ReplyDelete
  2. Yes you are. That's done because power and ground are so universal that bothering to draw the lines to all of them are more redundant than helpful. Usually the arrows will have a voltage next to them, but I didn't happen to note one here, since this ring will run on anything from 5V to ~12V (you could run it higher with resistors larger than 330 to protect the LEDs)

    ReplyDelete
  3. Thanks, that's a real help

    ReplyDelete
  4. Cool! Is it possible to make such oscillator with just single transistor (and single LED just alternating it's brightness)? I've tried to simulate your circuit without two extra transistor layers and it was not working as expected (but i guess that there is no MOSFET delay in my cirquit simulator) - it was acting as some kind of voltage stabilizer.

    I am looking for some really simple (or simplest possible) LFO for my noise-box :-)

    ReplyDelete
  5. @Harvie: That's an interesting challenge. The problem at that point is that the output of the inverter (which each transistor really is) feeds back into itself too fast with a single inverter to have any kind of instability; it finds a linear stable operating point and merrily sits there.

    A possible solution might be to use a series of RC networks [series resistor, capacitor to ground] to phase shift the output enough such that it doesn't directly feed back into the input. Then the feedback would be something like 270 degrees out of phase, making it independent enough. That's really whats happening with these three, just with more than one transistor's worth of gain through the oscillator. Having enough gain might be the limiting factor. It can't be less than 1, or the oscillation will taper off and the system stabilize.

    ReplyDelete
  6. Really nice. Is it possible to do the same with BJTs ? Or there is some reason by which this only works with MOSFETs ? Just tried with 2n2222 with no luck...

    ReplyDelete
  7. You need the high impedance inputs of the MOSFETs. BJTs will drain the capacitors too quickly for the caps to store the state.

    ReplyDelete
  8. what is other term for mosfets???

    ReplyDelete
  9. Great little circuit. I'm curious, could this be adapted to control the individual pins of a common anode rgb led instead of 3 seperate leds?

    ReplyDelete
  10. I would think so, yes. As long as you keep the current limiting resistors, you can replace the LEDs with any arbitrary current load. RGB LEDs, logic gates, motors, etc.

    ReplyDelete
  11. A Phase Shift Oscillator uses a single transistor (BJT) and with largish 10 uF capacitors, can oscillate at 1 Hz or less. Makes for a nice LED fader. Search for Watson's LED fader on Youtube for a short video of mine working.

    ReplyDelete
  12. awesome circuit. do you have any idea on how I can make this at a certain frequency? What is the operating frequency of this ckt? :D thanks - frustratedengineeringstudent

    ReplyDelete
    Replies
    1. The frequency is going to be related to the RC time constant, so if you know your MOSFET's gate voltage, figuring that out should be pretty straight forward. As for actually doing the math, it's a little more tedious than I feel like doing. Building one and playing with it should be pretty easy; experiment with it.

      Delete
  13. Kenn as for an EDA CAD program I use and recommend KICAD. It is mature, well supported and many libraries are available. It has schematic capture, PCB creation, Gerber viewer & electronic & PCB calculator. And don't forget LTSpice for all your simulation needs. Hope this helps.

    ReplyDelete