3
\$\begingroup\$

I designed a simple triangle wave oscillator based around a switchable curent soure. It works for a few cycles, then it becomes unstable and finally stops working altogether. Why is this?

enter image description here

If anyone wants to simulate this - here is the link.

One other thing - occasionally, the osillator will manage 20 cycles, other times it won't complete a single one. Why is the simulation apparently not deterministic?

\$\endgroup\$
1
\$\begingroup\$

Alternatively, instead of the window comparator, simply use a comparator with positive feedback.

Sim Link

enter image description here

It has the advantage of being MUCH simpler, in terms of parts. Also, it should be VERY stable, thanks to the positive feedback on the comparator.

You can make it even simpler by just getting rid of the analog switch, as well as two of the op-amps.

Sim Link

enter image description here


Ok, I'm having fun now.

So, this circuit never makes a perfect triangle wave, because you're charging the capacitor with a voltage through a resistor.

To make it operate as a true triangle wave generator, we need to do a significant amount of refactoring.

Basically, we need to charge the capacitor with a current source.

This is simple enough to do, all you have to do is stick the cap in the op-amp feedback.

Look at This

enter image description here (Note: this oscillators start-up is a little weird. It basically relies on leakage to charge the capacitor enough that the bottom op-amp output goes to one of the rails. This would not be a problem in the real world, since op-amps always have a little bit of offset, which would drive the output to one of the rails immediately on startup.

Basically, the simulated op-amps are too perfect.)

\$\endgroup\$
  • 1
    \$\begingroup\$ the last one is no longer a triangle wave, because the "current source" has such a low output impedance. \$\endgroup\$ – markrages Mar 10 '11 at 7:07
  • \$\begingroup\$ @markrages - True, but the original drawing isn't a perfect triangle wave generator either. Anyways, I added a true triangle wave generator. \$\endgroup\$ – Connor Wolf Mar 12 '11 at 5:51
4
\$\begingroup\$

What's happening is that the simulation is not deterministic! What an exciting property for a simulator to have! It appears that if it takes too long for an event to occur (computationally) it gets delayed a time-step. If you set the simulation speed too fast, you may get a different result!

At any rate, your flip-flop is getting clocked twice at one of the peaks, and that causes the output to rail or do other silly stuff.

You can improve this circuit by using a S-R latch instead of a flip-flop. That way, even if you have glitches out of your comparators, it's the first glitch that counts. Second, there are no possible invalid states. Notice in your image how if the Q_Bar output = 0 and the output wave is below -0.2V, your circuit is permanently stuck.

What you really want is something like a Set-Reset latch. That way you don't care about the comparators glitching, because your circuit will still function. Here's a link back to the Farstad simulator, as well as a screenshot.

Improved state storage

\$\endgroup\$
  • \$\begingroup\$ Alternatively, add a little bit of positive feedback to the comparators \$\endgroup\$ – Connor Wolf Mar 10 '11 at 6:29
  • \$\begingroup\$ Agreed - some additional hysteresis in the comparators would improve the original circuit. I still maintain that the SR latch is a "stable" solution. \$\endgroup\$ – W5VO Mar 10 '11 at 6:33
  • \$\begingroup\$ It would definitely be stable. However, it is not very efficient in terms of parts. \$\endgroup\$ – Connor Wolf Mar 10 '11 at 7:06
  • \$\begingroup\$ Of course, you could always just use a 555... I was just answering towards the question. The window function is a bit pricey, although the current sink/source would be easy on an IC without opamps. \$\endgroup\$ – W5VO Mar 10 '11 at 7:50
  • \$\begingroup\$ I've played with the code for the Falstad simulator quite a bit. Some components are designed to take a time step to react, while others are designed to be "instant", and cause the simulator to re-evaluate everything when they change. If this re-evaluation process repeats too many times, the dreaded "Convergence Failed" message pops up. One difficulty with this is that some components which normally take a step to pass inputs to outputs may change their output "mid-step" when the simulator is re-evaluating the effects of changing something. I've experimented some with... \$\endgroup\$ – supercat Feb 23 '14 at 20:29
2
\$\begingroup\$

Not giving a full answer, but I remember oscillator simulations as being notoriously difficult to do. If you don't set the step time correctly you won't see anything at all. I'm not sure I'd assume the simulation is correct.

\$\endgroup\$
  • \$\begingroup\$ Usually the difficulty with oscillator simulations is getting them started. Typically simulations don't have any noise, so there's nothing that can be amplified and filtered. Also, startup may take hundreds to thousands of cycles to simulate. This is just an unstable oscillator. \$\endgroup\$ – W5VO Mar 10 '11 at 7:42
2
\$\begingroup\$

If you set the voltage slider lower, it seems to simulate fine.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Yes; but have a look a the tips of the waveform; they show microinstability (is that a word?) Maybe the circuit just isn't correct... \$\endgroup\$ – Thomas O Mar 9 '11 at 20:32
  • 1
    \$\begingroup\$ You're fretting over pretty minor things in a simulation. Is this circuit so complex and expensive you can't just build it and see if it works? \$\endgroup\$ – AngryEE Mar 9 '11 at 21:31
  • \$\begingroup\$ @AngryEE, well, it's nice to have a pure wave. Look at the op-amp output during those periods, it's oscillating rapidly. \$\endgroup\$ – Thomas O Mar 10 '11 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.