How to fix this RC op-amp oscillator - Page 1
Forum section: electronics / beginners

author: MathWizard
author_rank: Super Contributor
timestamp: August 21, 2024, 12:32:03 am
content: On a breadboard I wanted a near 120Hz pulse signal to drive a CD4024 counter. And a basic astable osc. works in LTSpice. But IRL, it's not working with 1k and 150nF, or 10k and 68nF. With a 100 ohm resistor on the output as well to attach my scope probe, if I touch the end of the resistor it does start to osc a bit. And the tighter I squeeze my fingers and grip more of the lead, the osc gets faster, and more consistent. Some of it is 60Hz coming through me, but I saw over 200Hz too.And I tried putting the cap up top, between the inverting and OP, that didn't work, but the OP goes high (I could test the op-amp to be sure it works). My rails are +10V, GND, I'm using those common green mylar caps.I made a 4kHz version this summer, and that worked right away. I need to try the full frequency domain feedback eqns for this again, but I'd expect a square wave, not a low duty cycle pulse like LTSpice.So what goes wrong in real life with the above, at the low freq of 120Hz ??

author: TerrySt
author_rank: Regular Contributor
timestamp: August 21, 2024, 02:02:14 am
content: The op amp needs a negative rail instead of ground. Or another way would be to tie the ground end of R18 to 1/2 Vcc instead of ground. You could use two 200k Ohm in place of R18. One pulled up to 10v and the other to ground. The other end of each ties together and to R20.Terry

author: Konkedout
author_rank: Frequent Contributor
timestamp: August 21, 2024, 04:37:40 am
content: Quote from: TerrySt on August 21, 2024, 02:02:14 amYES: Generally speaking if you want to understand this stuff is to probe around the nodes of the circuit and see what makes sense. A basic requirement is that the voltage at the two op amp inputs needs to be able to cross so that the - input can be above the + input sometimes and below the + input at other times. The way your circuit is drawn, that is not going to happen.Another issue (less critical; just good practice) is to make sure that the resistance seen by the two op amp inputs should be approximately the same.You might try making the oscillator with an LM393 dual comparator instead of LM358 op amp. The LM383 can swing the output closer to the negative supply rail, but it needs an external pullup resistor. Generally speaking a comparator is better for driving logic because the low output level is a better logic "0".

author: watchmaker
author_rank: Unknown
timestamp: August 21, 2024, 10:37:04 am
content: So I can follow.

author: PGPG
author_rank: Frequent Contributor
timestamp: August 21, 2024, 11:05:27 am
content: Use generator as at figure 20 (page 15) in:https://www.ti.com/lit/ds/symlink/cd40106b.pdf?ts=1724216433605&ref_url=https%253A%252F%252Fwww.mouser.de%252FYou will get close to 50% duty signal.

author: MathWizard
author_rank: Super Contributor
timestamp: August 21, 2024, 05:28:52 pm
content: Ok thanks adding a 100k from the INVpin to Vcc did the trick (but I need to recalulate for the freq I want). I remember something about the internal BJT's saturating too, anytime stuff goes from rail to rail. Maybe that affects the duty cycle some, if it saturates harder to one rail or the other.But as a 2-state hysteresis type problem, yeah I need some pdf's on these too. But I just had to fix a similar same type of thing for a comparator circuit. I had to ensure the non-Inv pin can only ever be positive, higher or lower voltage.What I'm really making is a step counter for the stair steps of a Heathkit Curve Tracer I'm making. It used a R2R type setup, to set the max step #. It will count from the CD4024, but I'm trying with a constant-current source and at the end I'm using an LM393, and AND-gate. It works pretty good in LTSpice.In the curve tracer, 120Hz will come from mains rectification. But this little op-amp osc. is just for the breadboard testing.

author: MathWizard
author_rank: Super Contributor
timestamp: August 24, 2024, 03:21:50 am
content: So I'm just trying to derive / calculate the period of this type of oscillator, aiming for 120Hz w/ an LM358. And as a 2-state problem, treating the output as Vhigh or Vlow, and getting upper and lower thresholds for the non-inv. pin, and calling those the thresholds for the inverting pin as well, ignoring the slew rate and the few dozen uV difference-voltage to make it change states. And I'm ignoring over/undershoot and any other internal effects like saturation. And the bias currents don't matter, I never checked what the 2mV Voffset does tho.So I get eqn's of the same form, and get the right period for Vcap to go from Vlowthres to Vupperthres. But when discharging, my period is a bit quicker, but I'm pretty sure the RC eqn's are correct, so is it really the LM358 that's slowing it down ??T1= -tau_o * In [(Vut-Vhi) / (Vlt-Vhi)]T2= -tau_o * In [(Vlt-Vlo) / (Vut-Vlo)]T3=T1+T2~7msI made it on a breadboard, and it agrees with LTSpice, that for R=33k, C=150nF, fosc~123Hz. But with T2 being wrong or an incomplete model, I calculate fosc would be 143Hz.LTS and IRL these numbers are about the same w/ Vcc=5V, Vhi=3.65V, Vlo=53mV, Vut=2.95V, Vlt=1.86V.So is it really the LM358 that's slow to discharge such a small charge ?I need to try it over in the frequency domain with the feedback eqn's, I don't have that working yet.

author: MrAl
author_rank: Super Contributor
timestamp: August 27, 2024, 01:09:06 pm
content: Quote from: MathWizard on August 24, 2024, 03:21:50 amHello,Yes you need that 3rd 100k resistor from the non inverting input to +Vcc to get it to oscillate. The basic formula is simple after that because the cap voltage ranges from Vcc/3 to 2*Vcc/3, and that simplifies the charge and discharge time to:t=ln(2)*RCwhere the ln(x) function is the natural log, and math software often uses log(x) for that (log base 'e' not log base '10').This means that the oscillation time period will be:tx=2*ln(2)*RCand so the frequency will be:f=1/txNote that if the output does not go all the way to the positive rail then the frequency will be a little different. Same if the output does not go all the way to the negative rail (which is ground in this circuit).Also note that if you use a comparator then you will also need a pullup resistor. That means the time to charge will depend also on that pullup resistor because the time constant when charging will be:tc=(R+Rp)*Cbut for discharging will still be:td=(R)*CWe can calculate all this if you want to have a more accurate formula.