# Why do I get a triangle wave in this Schmitt trigger oscillator?

I'm trying to design a function generator that can generate square, triangle and sine waves, with frequency varying between 100Hz and 100kHz.

The circuit in the blue box is supposed to be a schmitt trigger with thresholds different from those of the NOT gate. the thresholds change when we change the Vb voltage and hence, the frequency changes. (I'm actually using a CD4093B NAND gate with one input in high voltage). This part of the circuit was suggested by my professor, but I have been trying to get it to work in Proteus and instead of a square wave, I'm getting a very neat triangle wave in the output pin of the gate, which doesn't make sense to me, since I thought this pin was supposed to have either a high, or a low voltage and not much in between.

This is the simulation result from this part of the circuit. The graph shows the voltage at the output pin of the gate: Can someone please explain why this is happening, and possibly suggest a solution to this problem?

I am only allowed to use resistors (not variable), diodes, capacitors and one CD4093B ic.

• What, exactly, is pin 5 tied to? If it's anything other than +5 or equivalent, you're going to have problems. Jul 9 '18 at 20:42
• Don't tell me you've left pin 5 floating? Jul 9 '18 at 20:51
• ِ@WhatRoughBeast It's not floating. As I said, it's high voltage. Jul 9 '18 at 20:58
• Start by changing R1 and R2 to 100k. Jul 9 '18 at 21:27
• Tried that. didn't oscillate. I've been playing around with the values for a while now. Jul 9 '18 at 21:55

It is supposed to be a Relaxation Oscillator , so the Square wave output on the Gate is integrated to ~ 1/3Vcc then toggles.

If you are seeing x MHz or whatever that is the unity gain bandwidth of the inverting gate in "quasi"- linear negative feedback mode with inadequate phase margin at unity gain.

Raise R1, 100k R2 to 330k or so will prevent that.so it doesn't load R4 and has gain>1

The external bias affects both duty cycle and frequency.

• I don't get what you are trying to say. As you see, I don't get the square wave that I predicted to get on the output. Jul 9 '18 at 21:12
• Tried that. didn't oscillate. I've been playing around with the values for a while now. Jul 9 '18 at 21:55
• You didn't wait long enough... or wired it up wrong. Try R2/R1 = 5 and R1>10R4 and expect 1kHz or it's not a Schmitt trigger. Leave R3 open or make R3=10*R1 with bias between 0 and 5V Jul 9 '18 at 22:02
• This did work! May I ask How you got these numbers? Jul 9 '18 at 22:26
• The ratios I specified are based on Increasing phase margin by reducing BW with higher gain Then the Schmitt trigger has 1/3 to 1/3 Vcc threshold but negative feedback gain affects this and R4C=1.23ms for 63% but the thresholds are less than this .... Jul 9 '18 at 22:45

It looks like you're trying to use R4 and C1 as timing elements. However, there's an easier path to C1 through R1 and R2, a 2K path rather than a 10K. If you're running it at 5V, you only get a milliamp out, but you need 2.5ma to overcome a 2K load at 5V. You're not loading straight to 5V or GND, but you're still going to be short since the cap is largely charged in the opposite direction.

Try increasing R1, R2, and R3 by 10X and see if that helps. Or, since U1 is a Schmitt trigger and already has hysteresis built in, eliminate R1, R2, and R3 completely.

• I think R3 is supposed to feed in the 'bias' voltage but how this is supposed to change the frequency of oscillation I'm not sure yet. Jul 9 '18 at 20:09
• I changed the resistors as you said, and it doesn't oscillate anymore. Jul 9 '18 at 20:32
• @Transistor The blue box is a schmitt trigger and the hysteresis voltage changes as the bias voltage changes. Jul 9 '18 at 20:34
• I'm familiar with Schmitt triggers but in the CMOS variety their hysteresis voltage is fixed. Adding in a bias current would, I expect, change the duty cycle but not the frequency. Jul 9 '18 at 20:52
• I've done the math on this, and if I've gotten it right, f=1/(RC*ln(vt1/vt2)) . vt1 and vt2 are dependent on Vb, Vt10,Vt20, and the 3 resistors inside the box. Vt10 and Vt20 being the threshold voltages of the gate. Jul 9 '18 at 21:02