Square Wave Generator

Hi All,

I have not been successful at modeling a square wave generator in circuit lab. I want to design this with an op-amp and two resistors in parallel from output to non inverting side of op amp and with a resistor and capacitor from output to the inverting side of the op amp (this values change the frequency). I made some calculations of the values that I need but when I try modeling the circuit in circuitlab (transient) I get a signal that is almost random and in micro-volts.

Has anyone tried this successfully?

by Eth
June 07, 2012

I just tried this too and I get nonsensical results, like one of the feedback resistors has a slow leaky capacitor in series..

by arduinohacker
June 08, 2012

Do you mean something like these?

by signality
June 09, 2012

@signality yes that's exactly what I was trying to do. I think the problem I had was setting the correct time intervals. Thanks.

by Eth
June 09, 2012

I meant problems like this:

This is essentialy the same thing as your #1 circuit, but it sure acts funny, oscillating a tiny bit at first before the output goes to 6 Gigavolts.

Kinda unlikely with plus and minus 12 volt supplies.

by arduinohacker
June 11, 2012

@arduinohacker,

I think your time steps are too coarse.

Try

Stop Time = 20m

Time Step = 200n

That works for me with or without skip initial condition ticked.

There are some notes about this in the description section for the schematic:

by signality
June 11, 2012

Hmm, well, I consider it a CL problem, when it merrily goes and tells me an op amp with plus and minus 12 volts power on it puts out -32 Gigavolts.

if I change the time steps to 2 microseconds, the simulation hangs at 64%. I'd call that a simulator problem too.

It's dissapointing when an app with so much promise goofs up royally on such a simple circuit!

by arduinohacker
June 11, 2012

I agree that it's a CL problem; my suggested timestep was sort of a workaround to the problem rather than being a "That's not the right way to run your sim".

I am disappointed that CL is still struggling with so many solver issues. Much of my time here on CL has been spent finding ways to cajole sims that are perfectly happy in other simulators (even QUCS which is not the greatest converging simulator) into playing nicely and converging in CL.

One thing I am bothered by is that there are one or two of my public sims that used to converge which at present no longer do so. I don't publicise a sim that doesn't converge without plastering it with notes about non-convergence so if it's one of my public circuits and it doesn't have any non-convergence notes then it converged at the time I published it. Yet earlier on today I found that my behavioural opamp 01 non longer converged.

Hmmmm.

:(

by signality
June 11, 2012

the little bit of numerical analysis programming I've look at or done, it's all too easy to have bugs. Or worse, introduce patches like: "if Denom = 0.0 then Denom := 0.0001;" ... patches like that will fix the immediate problem of dividing by zero, but probably break a whole lot of other things.

One careful survey of a large numerical program, a program that had been worked over for years, found a numerical error on average once every 32 lines of code. Programming generalized numerical applications is hard.

by arduinohacker
June 11, 2012

Post a Reply

Please sign in or create an account to comment.