one inverter oscillator

Thread Starter

zortharg

Joined Apr 16, 2013
4
Ok, so I have used 3 of 4 nand gates in a quad nand already and I would like to make a basic oscillator with the last one without using another chip, and using as few capacitors and resistors as possible. It seems to me that it's no good to have just a 1-capacitor 1-resistor low-pass filter - the usual circuit for when you have not just an inverter, but a schmitt trigger inverter. The reason it's no good is that when the input is considered by the inverter to be low and its output is high, when the capacitor voltage gets charged high enough to make the output low, it is already SO close to the threshold back on the way down (since it's not schmitt trigger) that it will just immediately switch back, in a period of time which is so short that it has little to do with the values of the resistor and capacitor or worse still, find a stable point right in the middle of the transition.

HOWEVER, it seems to me, that if (see picture attached at the bottom) you have TWO resistors and TWO capacitors, that what can happen is that even when the output swings from high to low and C1 starts to discharge, the voltage on C1 will still be high enough to continue to charge C2 for a while - and THEN the voltage on C1 falls below the threshold level, and THEN the voltage on C2 would have to be discharged away by C1's falling voltage back below the threshold, and that would take time, as opposed to an infinitesimal time for the voltage on the one capacitor to go back and forth between an infinitesimal above and below the threshold voltage.

I'm having a bit of trouble with the math, and I'm getting weird real world results using an actual chip. For simplicity so that I'm dealing with 1's and 0's and not 5's and 0's, I am pretending that it gets a 1 volt supply and that the inverter's (it's 4000 series CMOS -specifically a 4011) transition is 0.5 volt. I get the voltage on C2 is k*e^-(Q1*t)+(0.5-k)*e^-(Q2*t) where Q1=(R1*C1+(R1+R2)*C2+sqrt((R1*C1-R2*C2)^2+2*R1*C2*(R1*C1+R2*C2)+R1^2*C2^2))/(2*R1*R2*C1*C2) and that Q2=(R1*C1+(R1+R2)*C2-sqrt((R1*C1-R2*C2)^2+2*R1*C2*(R1*C1+R2*C2)+R1^2*C2^2))/(2*R1*R2*C1*C2). So far unremarkable, just an obnoxious 2nd order but non-oscillatory (a positive quantity under the square root) linear ordinary differential equation having two characteristic exponentials. Note that the coefficients on the exponentials are k and 0.5-k: this is because the starting voltage is 0.5, since I'm assuming that's the transition voltage given a supply of 1 volt.

And then I try to possibly find the value of k that results on the road to find the value of t at which the voltage falls back to 0.5 volt, which would then begin the symmetric opposite phase where the inverter's output is 1 and the capacitor C2's voltage is less than 0.5 and it has to charge back up to 0.5 volt to switch states again. After some tedious math I get these 2 things:

e^-(Q1*t)=Q2/(k*(Q2-Q1))-1
e^-(Q2*t)=Q1/((k-.5)*(Q2-Q1))-1

which leads to these 2 things:

k=(Q2/(Q2-Q1))/(1+e^-(Q1*t))
k=(Q1/(Q2-Q1))/(1+e^-(Q2*t))+0.5

Since I don't REALLY care what k is, I REALLY want to know what t is, I then subtract the 2 equations and it simplifies down to:

Q2*(1-e^-(Q1*t))*(1+e^-(Q2*t))=Q1*(1+e^-(Q1*t))*(1-e^-(Q2*t))

Messing around with my TI85's solver, it's really, really not finding any solutions for t>0 no matter what values of R1, R2, C1 and C2 I try. It just starts to converge to t=0 and then it (using C1=C2=R1=R2=1 for my test example) seems to decide it has found a solution at around t=5*10^-5, but that's not really good because what really happened was that it just decided something that was close to 0 was close enough to 0 to decide it found a solution. I have pondered that last equation above and I can't seem to actually prove mathematically that it doesn't have any solutions for t>0, and of course both sides of the equation are equal to 0 when t=0 because e^0=1 and you have 1-e^0 on each side. Which has me worried that perhaps having the second capacitor and resistor doesn't really change anything, that it's got the same problem as a single resistor and capacitor in a non-schmitt triggered inverter, it's merely the case that it's not so obvious that such would be the case. But it's sufficiently non-obvious that I can't really be definitive about it, since again, I can't mathematically prove it has no solutions. Can anyone else here prove it has no solutions for t>0? Or if it has solutions, can anyone say the conditions on C1, C2, R1, R2 when it has solutions?

So I tried it with a real CD4011. And at FIRST I got very nice results. I used R1=R2=1 megohm and C1=C2=0.02 microfarad, and my frequency counter said "300 Hz", powering it straight from a 9 volt battery. I replaced C1 and C2 with 4.7 nF capacitors, and the frequency became 1200 Hz. Perfect. Quadruple the frequency when you quarter the capacitors.... and THEN I tried it using a 5 volt regulator. And it went crazy. The frequency counter just went overload, with either capacitors. I tried other capacitors. The frequency counter only goes up to 20 kHz, but even so, that's a pretty big deviation from 300 Hz! I shouldn't expect it to be so strongly dependent on the supply voltage! And if anything, I'd expect the frequency to go DOWN if I give it 5 volts because the data sheets say that the switching time is longer when the supply voltage is lower. But no, it switches super-fast when I power it with 5 volts. I didn't try it with any in between voltages either, just 5 volts and 9.

Does anyone have an explanation for this? The circuit I want to use it in uses 5 volts (figures it would be bad for 5 and good for 9 and not the other way around), and has anyone any information or thoughts on this particular circuit and situation?
 

Attachments

Last edited:

ErnieM

Joined Apr 24, 2011
8,377
What you are attempting to create is called an "RC Oscillator."

To create an oscillator you need 360 degrees of phase shift. 180° comes from the inverting amp. That's good. But an RC can only give a max of 90° of phase shift at infinite frequency, and that's not very useful when using just 2 RC's.

The solution is to use 3 RC networks. If they match then each has 60° of phase shift at the frequency of oscillation.

Here's a web steal of the first RC oscillator I found. It uses an op amp instead of a logic inverter but it works all the same.

 

crutschow

Joined Mar 14, 2008
34,439
Your problem with 5V may be that the input voltage threshold difference between logic high and logic low become so small that the frequency of oscillation becomes determined by the internal circuit delays and not the external RC circuit.
 

THE_RB

Joined Feb 11, 2008
5,438
Inverters already have the necessary 180' phase shift and only need a single R and C to make an oscillator.

The problem if you don't use a schmidt trigger inverter or gate, is that they can (and do!) tend to latch up with a slowly changing input voltage. Generally they are less likely to latch up if you use a lower value resistor (more RC current).

Most of the newer performance CMOS gates like AC and ACT have pretty well defined HI and LO threshold for input triggering, and are "schmidt like" in operation.

I'm not sure about your CD4011, it's good to do some testing, like put a 50k pot from 5v-0v, with the wiper on the gate input. Then with a LED on the gate output and a voltmeter on the input, you can slowly turn the pot and read the HI and LO input voltage thresholds, and also see if it seems prone to latchup.
 

crutschow

Joined Mar 14, 2008
34,439
Inverters already have the necessary 180' phase shift and only need a single R and C to make an oscillator.

...................
An oscillator requires zero degrees (or 360 degrees) of phase shift from output to input so the near 90° maximum phase-shift from a single RC isn't sufficient. That's why ErnieM's circuit (with a single inverter) shows three RC circuits with each one providing 60° of shift.
 

Thread Starter

zortharg

Joined Apr 16, 2013
4
crutschow comment #1: So you're saying that the width of the threshold region is more or less relative to the power supply voltage depending on the power supply voltage? For instance, maybe the transition range is very narrow if you give it 5 volts but not with 9 volts, or vice versa?

ErnieM and dodgycave and sheldons. No. I have quad nand chips. I have 4011 non schmidt trigger quad nand gates. Not schmidt triggers, not op amps, not 555 timers, not NPN transistors. It is what it is, and that's what I have. There is a world of difference between that and an op-amp, nor do I want a sinewave generator based on a linear phase-shift filter, if I wanted to use an op-amp I'd use it as a comparator, since I want to produce a clock signal to D flipflops which are positive edge triggered. Besides, you don't need an op-amp for the phase shift oscillator, a transistor will work, and it's a lousy use of components because at the frequency I want, it would be 3 electrolytic capacitors. I am trying to do something with my nand gate, also because being CMOS, it can involve very high valued resistors, meaning I don't need electrolytic capacitors even for the low frequencies I want, I can in principle use 0.1 or 0.047 microfarad capacitors with 1, 2.2, 10 megohms. If I can find a solution. Make no mistake, if my quad nand gates were schmidt triggered, I would never have asked a question in a forum. One resistor, one capacitor, it's all I would have needed, and I would have known exactly what to do. I'm hoping someone has any thoughts on my circuit, or has a better idea of what to do with my one single nand gate which is not schmidt triggered.

crutschow comment #2 and #12. Look more closely at Ernie's circuit. That's not a nand gate, that's an op-amp. It is not only not an answer to my dilemma, it is a complete non-sequitur.
 

t_n_k

Joined Mar 6, 2009
5,455
You employed a 5V regulated source for the situation when things went pear shaped. I wonder how the circuit would behave if you used a properly decoupled 9V regulated source rather than a 9V battery.

I doubt you will find a solution to your problem with the constraints you have at present. That is, with only R's & C's to play with.
 

crutschow

Joined Mar 14, 2008
34,439
crutschow comment #1: So you're saying that the width of the threshold region is more or less relative to the power supply voltage depending on the power supply voltage? For instance, maybe the transition range is very narrow if you give it 5 volts but not with 9 volts, or vice versa?
............................................

crutschow comment #2 and #12. Look more closely at Ernie's circuit. That's not a nand gate, that's an op-amp. It is not only not an answer to my dilemma, it is a complete non-sequitur.
#1: Yes, the threshold voltages do not vary a lot with the power supply voltage. Thus the N-channel and P-channel thresholds will tend to be closer together at a lower supply voltage.

#2 and #12: True, the circuit shows an op amp, not a digital gate, but that doesn't make it a complete (or even partial) non-sequitur. The op amp is used in the inverting mode where it's output is 180 degrees out from the input, the same as a NAND inverter. The only difference is the gain of the circuit. The op amp will have a gain determined by Rf. The NAND has a high (but finite) gain. It should oscillate similar to the op amp with the same phase-shift circuit.
 

THE_RB

Joined Feb 11, 2008
5,438
An oscillator requires zero degrees (or 360 degrees) of phase shift from output to input so the near 90° maximum phase-shift from a single RC isn't sufficient. ...
I'll argue that! :)

If the "oscillator" has only two states (which it does because it is a logic gate), and has some hysteresis (ditto) it needs 180' phase shift from input to output. Which is why we use inverters.

A single RC is all it needs, to provide ANY time delay between the output changing state and the input following it.

I'd like to see you build an oscillator from a gate with 0' phase shift! I'm sure it could be done with enough cap stages and some defined start conditions... But the optimal phase shift for a gate oscillator is 180'.
 

ErnieM

Joined Apr 24, 2011
8,377
crutschow comment #2 and #12. Look more closely at Ernie's circuit. That's not a nand gate, that's an op-amp. It is not only not an answer to my dilemma, it is a complete non-sequitur.
Before you type out a diatribe perhaps you should actually READ what people have said.

Here's a web steal of the first RC oscillator I found. It uses an op amp instead of a logic inverter but it works all the same.
For the mentally challenged that means you can use your precious NAND gate where the op amp is.

As they said in Airplane: "Chump don't want the hep, chump don't get the hep."

And welcome to my ignore list.
 

crutschow

Joined Mar 14, 2008
34,439
I'll argue that! :)

If the "oscillator" has only two states (which it does because it is a logic gate), and has some hysteresis (ditto) it needs 180' phase shift from input to output. Which is why we use inverters.

A single RC is all it needs, to provide ANY time delay between the output changing state and the input following it.

.........................
Ok, if we're talking about a hysteretic oscillator, but his circuit is a standard NAND gate with likely little or no hysteresis when operated at 5V.
 

ErnieM

Joined Apr 24, 2011
8,377
An oscillator requires zero degrees (or 360 degrees) of phase shift from output to input so the near 90° maximum phase-shift from a single RC isn't sufficient...
I'll argue that!

If the "oscillator" has only two states (which it does because it is a logic gate), and has some hysteresis (ditto) it needs 180' phase shift from input to output. Which is why we use inverters.
"Extraordinary claims require extraordinary proof." Somehow every reference on oscillation theory states the phase shift needs be a multiple of 360 degrees.

If the entire world is wrong and you are right... start by checking your work.

A single RC is all it needs, to provide ANY time delay between the output changing state and the input following it.
That is not true for an oscillator. It is true for a multivibrator.

multivibrator != oscillator

I'd like to see you build an oscillator from a gate with 0' phase shift! I'm sure it could be done with enough cap stages and some defined start conditions... But the optimal phase shift for a gate oscillator is 180'.
The criterion for oscillation is 360 degrees of phase shift. There is no criterion that some must come from the amplifier. Here "enough cap stages" would be a phase shift of 360 degrees.

I could further taunt you by stating it is obvious that the gain of the amplifier for the oscillation signal must be equal to unity... but that may confuse you some more and further steal this thread.
 

THE_RB

Joined Feb 11, 2008
5,438
Ok, if we're talking about a hysteretic oscillator, but his circuit is a standard NAND gate with likely little or no hysteresis when operated at 5V.
I covered that in my post #8. I've built many oscillators using a spare inverting gate, and not always schmidt. :)

ErnieM said:
"Extraordinary claims require extraordinary proof." Somehow every reference on oscillation theory states the phase shift needs be a multiple of 360 degrees.
Take this in context, the OP is not talking about making a general sine oscillator. His post is specifically about using a digital (two state) gate and making it "oscillate".

If you want to put some proof where your ego is, show me how you can build an oscillator with one NON-inverting gate simpler and easier than I can build an oscillator using one inverting gate, and one R and one C.

ErnieM said:
I could further taunt you by stating it is obvious that the gain of the amplifier for the oscillation signal must be equal to unity... but that may confuse you some more...
You really need to check your arrogance Ernie! You are NOT talking to an inferior so please change your tone.
 

t_n_k

Joined Mar 6, 2009
5,455
I could further taunt you by stating it is obvious that the gain of the amplifier for the oscillation signal must be equal to unity... but that may confuse you some more and further steal this thread.
Now that is interesting!

Do you mean that the total open loop gain with amplifier plus passive phase shifting elements is unity - or the amplifier considered in isolation requires only unity gain?
 

ErnieM

Joined Apr 24, 2011
8,377
If you want to put some proof where your ego is, show me how you can build an oscillator with one NON-inverting gate simpler and easier than I can build an oscillator using one inverting gate, and one R and one C.
Assuming "simpler" means "fewer components," and you've supplied yourself with an amp, an R, and a C then I have to build mine with fewer?

Can't be done even with the same component count. As has been explained to you an oscillator requires 360 degrees of phase shift, far more then a single RC can supply.

Nice try but zero points.

Do you mean that the total open loop gain with amplifier plus passive phase shifting elements is unity - or the amplifier considered in isolation requires only unity gain?
I mean the amplifier plus passive phase shifting elements is unity. Exactly unity too.

Has to be if you think about it:
if it's less then unity then the signal dies out.
if it's greater then unity then the signal "grows without bound."

What happens is a real world amp has limits on how large a signal it can make, and that clamping action is what limits the gain to exactly one.
 

t_n_k

Joined Mar 6, 2009
5,455
I mean the amplifier plus passive phase shifting elements is unity. Exactly unity too.

Has to be if you think about it:
if it's less then unity then the signal dies out.
if it's greater then unity then the signal "grows without bound."
Indeed, I had thought about it - long time ago. I thought maybe someone had at last discovered the holy grail - over-unity system:rolleyes:
 
Top