cmos inverter oscillator - Page 1
Forum section: electronics / beginners

author: vivi-d
author_rank: Regular Contributor
timestamp: March 05, 2022, 01:11:53 pm
content: I recently saw a video by GreatScott on youtube where he used 3 logic inverters in series to create an oscillator. I attempted to do the same but with discrete transistors. It didn't work out. Nothing seemed to be oscillating. I just got different DC voltages at various places (I should have written what I was measuring...) What am I missing to makethe circuit oscillate?I've attached a schematic and a pic of the circuit. The IC on the right is an lm358 to buffer the output and flash an LED according to the output.

author: CaptDon
author_rank: Super Contributor
timestamp: March 05, 2022, 01:49:03 pm
content: Far too many parts!!! The phase shift network is all wrong. You can do it with one transistor, five resistors, and three capacitors and be guaranteed to oscillate on a wide voltage range. The circuit can be simpler but may not always start up. A CMOS gate biased to the midpoint between VDD and GND can become an unstable amplifier. Add some phase shift and presto, you have an oscillator. Your circuit represents none of the above.

author: vivi-d
author_rank: Regular Contributor
timestamp: March 05, 2022, 01:52:03 pm
content: I never said it was practical LOL!How do I add a phase shift?

author: TimFox
author_rank: Super Contributor
timestamp: March 05, 2022, 03:05:03 pm
content: The phase shift of a single R-C network approaches (but does not reach) 90 degrees at high frequencies. You need to achieve 180 degrees to make an oscillator, so at least three R-C's in cascade are required.This is covered in any textbook of the vacuum tube era. One clever phase shift network from that time is to take a large-value (like 22 megohm) resistor and wrap it in grounded metal foil, connecting between the plate and grid. Early in my career, this was achieved accidentally in an op-amp transresistance amplifier when the ceramic substrate for a hybrid construction had a grounded metal pad under the feedback resistor.

author: CaptDon
author_rank: Super Contributor
timestamp: March 05, 2022, 06:01:37 pm
content: Tim, you are exactly on track, one collector resistor (1K?) one bias resistor (22K?) and three resistors (10K?) along with three capacitors (.1mfd) to form the A.C. coupled phase shift network. Maybe able to delete the last 10K resistor and rely on the bias resistor and base resistance to get the last stage of phase shift. I built tons of these for different purposes and demonstrations about 40 years ago. 2N2222 works great for the transistor.

author: TimFox
author_rank: Super Contributor
timestamp: March 05, 2022, 06:39:26 pm
content: A general comment on feedback oscillators: the frequency of oscillation is determined by the frequency where the net phase shift around the entire loop is 0 (or 360o). If the circuit were truly linear (as on paper), the amplitude of the oscillation (at that frequency) would increase without bound, to the surprise of the 9 V battery powering the circuit. In reality, something limits the amplitude of the oscillation, either a good on-purpose circuit (such as the famous light bulb in the -hp- Wien-bridge oscillators), or just the output hitting the power supply rails, or the non-linearity of the active device at high signal amplitude.

author: jpanhalt
author_rank: Super Contributor
timestamp: March 05, 2022, 06:50:41 pm
content: Here's a nice review by Fairchild (attached). The link I had is no longer valid.Note that a single Schmitt inverter will do. Also, if you look at the oscillator section for PIC's, you will find how to use a crystal for more accuracy. If not Schmitt, then an odd number of 3 or more is needed. A single inverter will not start reliably, unless you use a Schmitt.

author: vivi-d
author_rank: Regular Contributor
timestamp: March 05, 2022, 07:13:16 pm
content: Thanks for the link!This is exactly what I was trying to recreate, but by using discrete FETs to make inverters. Unfortunately, I couldn't get my circuit to start oscillating...

author: jpanhalt
author_rank: Super Contributor
timestamp: March 05, 2022, 07:26:42 pm
content: Have you tried the configuration in Figure 2?

author: Benta
author_rank: Super Contributor
timestamp: March 05, 2022, 07:51:23 pm
content: Quote from: vivi-d on March 05, 2022, 07:13:16 pmWell, there are two reasons for that:1: your discrete MOSFET circuit has very little voltage gain.2: it's not a Schmitt trigger.

author: jpanhalt
author_rank: Super Contributor
timestamp: March 05, 2022, 08:32:49 pm
content: A Schmitt trigger is not required for consistent starting with 3 inverters.EDIT: I am anxious to see what happens if the OP tries the configuration in Figure 2.

author: Benta
author_rank: Super Contributor
timestamp: March 05, 2022, 08:45:23 pm
content: Quote from: jpanhalt on March 05, 2022, 08:32:49 pmFirst: one inverter is equal to three inverters in series, three just give more voltage gain (not in this case, though).Second: the circuit the OP has presented is figure 6. And this certainly needs Schmitt trigger operation (or some other switching threshold control).Third: the MOSFETs the OP is using are not really suited for 3.3 V operation.

author: jpanhalt
author_rank: Super Contributor
timestamp: March 05, 2022, 09:12:52 pm
content: "One experiment is worth 1,000 expert opinions."

author: Benta
author_rank: Super Contributor
timestamp: March 05, 2022, 09:18:36 pm
content: Well, go build it.

author: RoGeorge
author_rank: Super Contributor
timestamp: March 05, 2022, 11:00:34 pm
content: Even when it oscillates, like in the first schematic and first plot, the V(vout) amplitude of the oscillations is very small.It looks like these MOSFETs are not good enough for 3.3V, because when fed with a square wave at input, like in the second schematic plots 2 and 3, the outputs V1, V2 or V3 never goes less than 2.5V, like seen in the 3rd plot.Later edit:Works OK, just that I've connected the upper side transistors in reverse.

author: vivi-d
author_rank: Regular Contributor
timestamp: March 06, 2022, 12:11:05 am
content: Thanks for all the replies!I will do some modifications to the board when I get some free time...I will have to double check which mosfets I'm really using. The kicad schematic I posted is not really the actual parts I built the circuit with.

author: jpanhalt
author_rank: Super Contributor
timestamp: March 06, 2022, 10:11:47 am
content: Quote from: vivi-d on March 06, 2022, 12:11:05 amI am just an occasional hobbyist. It is tempting to do what you did, perhaps most of us have done it, but it is not a good idea.1) I have used Eagle from the start. That program allows one to change the name and/or value of any component. There may be warnings. KiCad may allow you to do the same with warnings.2) The earlier you learn to make your own component libraries, the better. In time, those will be what you use.Anxious to get your update.

author: Ian.M
author_rank: Super Contributor
timestamp: March 06, 2022, 11:08:40 am
content: You'd be surprised how simple a squarewave discrete complimentary MOS oscillator can be given appropriate choice of MOSFETs and supply voltage. This is the maximally Muntzed version.You cant simplify it further without either discarding 'complimentary MOS' or making it a quasi-sine phase shift oscillator. N.B. if building it for real, good decoupling will be needed as it draws approx. 100mA current spikes during transitions.

author: not1xor1
author_rank: Frequent Contributor
timestamp: March 07, 2022, 08:47:45 am
content: Quote from: Ian.M on March 06, 2022, 11:08:40 amI noticed that you didn't use a voltage source in the LTspice circuit, but just a directive (V3V...) I didn't know (or remember). Could you please provide some hint about its usage? Thanks

author: Ian.M
author_rank: Super Contributor
timestamp: March 07, 2022, 08:54:34 am
content: It *IS* a voltage source, connected between nodes 3V3 and 0 (Gnd). See user guide for parameters. I just find it personally preferable not to clutter up my schematic when its supposed to be a physically buildable circuit, by placing parts only required for simulation on it, when I can either enter them directly as SPICE lines or place them separately and hook them up with net labels (which is what I do if I want to easily be able to check supply currents).

author: ledtester
author_rank: Super Contributor
timestamp: March 07, 2022, 12:04:57 pm
content: Quote from: not1xor1 on March 07, 2022, 08:47:45 amI found this interesting, too.The top "3V3" is a label and the "V3V3 3V3 0 3.3V; PSU" is a directive which also could have been written "Vmyname 3V3 0 3.3V" to define a voltage source between nodes "3V3" and ground which DC value 3.3V

author: RoGeorge
author_rank: Super Contributor
timestamp: March 07, 2022, 12:09:22 pm
content: Quote from: Ian.M on March 07, 2022, 08:54:34 amNice trick, never thought doing that, thanks!The I(V3v3) can still be added as a trace, just that it requires to go through the menus: Plot Settings -> Add trace (or use the CTRL+A shortcut, or right click "Add Traces" on the plot area) then select the current through the desired source by the source name, here V3V3.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 07, 2022, 12:11:18 pm
content: Quote from: RoGeorge on March 05, 2022, 11:00:34 pmCheck the supply current; the PMOS are backwards!Tim

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 07, 2022, 12:27:13 pm
content: Quote from: vivi-d on March 05, 2022, 01:11:53 pmWhat are you measuring with? It's entirely possible the transistors are oscillating at a rate determined by the propagation delay between them (some MHz), and your meter doesn't read that. You need an oscilloscope with enough bandwidth to cover that, to truly see if it's oscillating or not.A chain of three amplifiers (more or less what this is), doesn't need to oscillate; such configurations have been used for amplification in the past. What matters is having enough loop gain, at frequencies where the phase shift is substantial. So, some MHz, where each stage causes significant phase shift (namely 60 degrees) into the next, and so on, while the amplitude grows around the loop and thus increases until saturation (~square wave output).With the disproportionately sized RC out front of just one stage, you've killed the loop gain at high frequencies, so that the phase shift of each stage is irrelevant, and the RC dominates. (You've made an amplifier, withdominant pole compensation, it seems!) And it's only 90 degrees at high frequency, not enough for the full 180 needed to oscillate.Anyway, ring oscillators are only used at very high frequencies -- comparable to the propagation delay of the gates used. Like, most digital electronics use an adaptation of this circuit for 10s to 1000s of MHz (usually adjustable, with a PLL (phase locked loop) setting it to a multiple of a quartz crystal reference frequency).So, for a low frequency oscillator, this architecture is wholly unsuitable; a more conventional multivibrator is the way to go. As has been ably explained/demonstrated above.A tip about multivibrators: usually, there's a DC negative feedback path (notice the resistor around one or three inverters), and an AC positive feedback path (notice the capacitor around two or etc. inverters).Negative feedback causes the system to tend to return to a stable bias condition (i.e., the middle of the input threshold voltage).Positive feedback causes the system to latch into a particular state (bistability). If the capacitor were replaced with a resistor, it would indeed latch: you tease the input towards +V and it stays stuck there; you ground it and it stays stuck at GND. You need to apply enough current to the input, to force the input voltage across its threshold, and only then will it switch. A schmitt trigger.Suppose the positive feedback were time-limited, so its effect eventually decays. We put a capacitor there, and it latches up/down momentarily, but eventually negative feedback brings it back down to the input threshold. But suddenly the output switches, and the positive feedback kicks in again, and so the system repeats forever: an astable multivibrator.If we have gates with hysteresis (a schmitt trigger), we can do this with a single gate and RC, and the amplitude and frequency depend on the input thresholds (rising/falling) of that gate. We have some advantage with the 2-3 gate version here, as the amplitude can be essentially the full VDD, and operation is less dependent on threshold or supply voltages.Tim

author: RoGeorge
author_rank: Super Contributor
timestamp: March 07, 2022, 12:40:36 pm
content: Quote from: T3sl4co1l on March 07, 2022, 12:11:18 pmDoh, sorry, and thanks!

author: not1xor1
author_rank: Frequent Contributor
timestamp: March 09, 2022, 08:57:40 am
content: Quote from: ledtester on March 07, 2022, 12:04:57 pmOK ... I got it... more details are in the Voltage Source documentationSyntax: Vxxx n+ n- <voltage> [AC=<amplitude>] [Rser=<value>] [Cpar=<value>]Syntax: Vxxx n+ n- PULSE(V1 V2 Tdelay Trise Tfall Ton Tperiod Ncycles)etc...unfortunately the documentation is not much detailed and I never thought I could use that directive in that waythanks you and Ian for the hint

author: RoGeorge
author_rank: Super Contributor
timestamp: March 09, 2022, 01:38:28 pm
content: There was a time when SPICE didn't have a graphic interface, and the schematic was described by text only, in a .net file called the netlist. The .net file is still how it's done today. The GUI only converts the drawn schematic in a .net text file. The syntax for this text file is documented in the SPICE docs.- one of the rules in the .net syntax is that the first letter tells the component type, V for voltage source, R for resistor, etc.- the netlist lines starting with a dot character are for SPICE directives, which are not parts, but commands of what to do with the rest of the netlist. For example the spice directive ".tran 1s" will run a transient analysis. That is why in the GUI they are called spice directives.- but the GUI implements the spice directives in the simple way, by copying whatever text line from the GUI to the .net file.Since there is no specific order for the .net lines (the .net "code" is a hardware description, not a program), one can add not only genuine spice directives that start with a dot character, but also lines starting with other character that may be a component, or maybe something else that will be added in the future LTspice versions, who knows.That's the elegance of keeping it simple.For the fun of it, the Wire2 in the pic, apparently disconnected, should have 0V, but it shows 500mV, because between Wire1 and Wire2 there is another resistor of 9k, shown as a directive text, so present in the .net but not in the schematic drawing.Imagine the trolling possibilities of adding spice directives parts in a schematic, disguised as plain English comments.

author: mawyatt
author_rank: Super Contributor
timestamp: March 09, 2022, 02:36:15 pm
content: Recall the early days of Dr Larry Nagle Berkeley SPICE written in FORTRAN. Circuits were described in net lists and outputs were just an array of numbers, later a graphical routine could be employed where the "graphs" were just text lines (80 or 132 columns) of characters to create a very crude plot. We created IBM punch cards for the simulation which were placed in a mail box and picked up by a courier and airmailed to the IBM mainframe location 1000 miles away!! A couple days later we would get a paper print out in our mailbox of the results on 132 column wide fan-folded paper, and then get our colored pencils out to trace out the voltage and current graphs!! Also recall when we got the Apollo-Mentor system and could run SPICE locally, then the PC versions of SPICE like PSPICE, and so on.Wow, how things have changed!!!Best,

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 09, 2022, 02:44:17 pm
content: Still computing in the cloud, the mail delivery's just a little faster now.Tim

author: TimFox
author_rank: Super Contributor
timestamp: March 09, 2022, 03:54:53 pm
content: Back in the Hollerith card era, a neighboring group at the University of Chicago used to carry boxes of cards downtown on the Illinois Central commuter train to the old Standard Oil building, which rented out time on their IBM 360 at a cheaper rate than the University's computer center. Just a few years later, it was an incredible deal to use a satellite link to send the same information to a computer in the UK.Meanwhile, I continue to run a line-oriented SPICE (from AimSpice) which I (personally) find easier to edit than with a schematic capture. The package includes a very useful post-processor module that can output to a .CSV file that I graph with a good graphing program.http://www.aimspice.com/I just noticed that they haven't updated their site since 2020, but I hope they are still around.

author: mawyatt
author_rank: Super Contributor
timestamp: March 09, 2022, 04:00:24 pm
content: Could you import that CSV file to an AWG, then create the waveforms from SPICE in real life!!Best,

author: TimFox
author_rank: Super Contributor
timestamp: March 09, 2022, 04:02:41 pm
content: That should work, so long as you have the process to program your AWG from a CSV file.I usually output frequency-domain data for my applications, but in .TRAN calculation mode SPICE generates data in the time domain.

author: RoGeorge
author_rank: Super Contributor
timestamp: March 09, 2022, 10:30:36 pm
content: Quote from: mawyatt on March 09, 2022, 02:36:15 pmI guess the IBM operators loved to handle packs of punched cards containing net lists instead of FORTRAN programs. In case the pack of cards was accidentally spilled on the floor, there was no stress to put the netlist cards back in the exact same order.

author: TimFox
author_rank: Super Contributor
timestamp: March 09, 2022, 11:35:06 pm
content: Real programmers made use of the sequence numbers in the final columns that were reserved for that purpose.A cardpunch could fill them automatically, and the card sorter could then re-sort the shuffled cards. No CPU time required.

author: SiliconWizard
author_rank: Super Contributor
timestamp: March 10, 2022, 01:19:48 am
content: Quote from: jpanhalt on March 05, 2022, 06:50:41 pmYes. Note that, IIRC, a Schmitt-input inverter, if implemented with discrete transistors, will take 6 of them. If the OP wants to go with 6 discrete transistors, that could be the way to go.

author: vivi-d
author_rank: Regular Contributor
timestamp: March 19, 2022, 07:23:49 pm
content: I have much to learn...Do you have any books you would recommend for learning about oscillators/PLLs and the like? I get confused about where a phase shift is required and how much.Anyways, I brought out an O-scope and found the circuit was making a square wave, albeit a dirty one. So I've achieved my goals with this experiment.Here are some wave forms. I wrote which inverter I was measuring in the lower right.

author: not1xor1
author_rank: Frequent Contributor
timestamp: March 20, 2022, 08:21:27 am
content: Quote from: vivi-d on March 19, 2022, 07:23:49 pmIMHO there is no need for such detailed pictures in this case. You should reduce the image size to 1200x900pixels or less to save storage space and energy.

author: jpanhalt
author_rank: Super Contributor
timestamp: March 20, 2022, 10:54:25 am
content: Quote from: vivi-d on March 19, 2022, 07:23:49 pmFrom one of my folrders:http://www.ti.com/lit/an/szza043/szza043.pdfhttp://www.freescale.com/files/microcontrollers/doc/app_note/AN3208.pdfhttp://ww1.microchip.com/downloads/en/appnotes/00949a.pdfhttp://www.ti.com/lit/an/slaa322b/slaa322b.pdfhttp://zpostbox.ru/relax_e.htm(some of your tracings resemble relaxation)Also try Google. I have not checked whether all links still work.EDIT: BTW, it is ambiguous at best what circuit gave which trace. Please post the corresponding circuitsas builtand show were you attached the probes.

author: vivi-d
author_rank: Regular Contributor
timestamp: March 21, 2022, 09:22:12 pm
content: Sorry about that, this should help