3
\$\begingroup\$

I have been trying to build a sawtooth generator using a current source which linearly charges my capacitor and a comparator which was supposed to discharge my capacitor; instead it doesn't. Here is the schematic (first picture) of my attempt which doesn't work.

I decided to break the connection between the operational amplifier output and the transistor base to check the signals OSC_CH2 and OSC_CH3 with my osciloscope (second picture). I figured out that the operational amplifier is working just fine (third picture). The problem must lie in the transistor or the circuit behind the operational amplifier. But how do I fix my problem?

Enter image description here

Enter image description here

\$\endgroup\$
2
\$\begingroup\$

A relaxation oscillator requires a discharge device or circuit which exhibits hysteresis: this means that when the capacitor charges to the high threshold, the device turns on a discharge path and keeps the discharge path open even as the capacitor drops below the threshold until some low threshold is reached at which point the discharge path closes.

The discharge transistor you have there does not have hysteresis.

Furthermore, the circuit has stabilizing negative feedback. The discharge transistor acts as an inverting stage (which is why it is negative feedback even though it goes through the + terminal of the op-amp). Turning on the discharge transistor more causes it to conduct more collector current, draining the capacitor to drain to a lower charge, which has the effect of opposing the turn-on of the transistor.

This arrangement will naturally solve for a capacitor voltage which is precisely so high that, through the op-amp, via a minute voltage difference between + and - inputs, it programs the discharge capacitor to have a collector current which matches that of the charging capacitor. The charge current continues to flow, and just enough of it trickles into the capacitor to keep it charged in the face of any leakage. The rest goes through the discharge transistor's collector-emitter path. Any build up of extra charge on the capacitor is amplified through the comparator's monstrous gain, and almost instantly raises the collector current on the discharge transistor, which will promptly remove the charge. If the capacitor loses charge, the discharge transistor will instantly reduce its collector current, causing more of the charging current to be diverted into the capacitor to replenish the charge.

Such system as described could oscillate, but not as a relaxation oscillator. There would have to be some frequency at which the product of the gain and feedback is 1, and the feedback is phase shifted by 180 degrees. That would be a phase shift oscillator.

Without hysteresis, and without the conditions for phase shift oscillation, your circuit is simply stable. It settles back to equilibrium even if externally disturbed.

\$\endgroup\$
2
\$\begingroup\$

The output from the LM358 should go through a resistor or it will be limited by the base-emitter voltage and strange things may happen. Try inserting a 1 kohm resistor in series with the base connected to the LM358.

I think the circuit needs hysteresis. Here's why... As the capacitor starts charging and the +input starts to rise close to the -input, the comparator output will begin to rise and this will start to turn on the transistor, but not enough to discharge the capacitor - just enough to sustain it in limbo with maybe 0.4 V on the base of the transistor and stalemate on the capacitor.

I think you need to add hysteresis, but this might be detrimental given the circuit you've gone for, because you don't want to be adding resistors from the comparator output to the capacitor, because it'll tend to limit its ability to linearly rise with time.

Try a 10 kohm in series with the +input and 1 Mohm from the comparator output back to +input. At least try this to see if it starts oscillating; then we can move on.

\$\endgroup\$
  • \$\begingroup\$ @71GA - i was nearly correct in my first analysis but i have changed my mind about the problem. The upshot is the same but insert just a series resistor and see if it works \$\endgroup\$ – Andy aka Mar 19 '13 at 9:33
  • \$\begingroup\$ I added series resistor 1k between opamp output and base and it wont change anything. \$\endgroup\$ – 71GA Mar 19 '13 at 10:04
  • \$\begingroup\$ I also tried adding a combination of 2 resistors. I put 1k between opamp output and base and 4k7 between base and GND. Still it is not working. \$\endgroup\$ – 71GA Mar 19 '13 at 10:16
  • \$\begingroup\$ In the circuit with only series 1k resistor or with outh it i figured out that capacitor won't charge unless i disconect wire going from colector to the top of capacitor... Maybee problem lies there? \$\endgroup\$ – 71GA Mar 19 '13 at 10:19
1
\$\begingroup\$

As suggested in another answer you should add a resistor between the LM358 output and the transistor base to limit current into the transistor base.

Correction: Below comment is incorrect as pointed out by Andy aka. I misread the schematic connections.

As drawn your circuit does have a fundamental design problem though. When the capacitor is initially discharged the LM358 + input will be at a higher voltage than the - input. This will cause the output to be high which in turn causes the NPN transistor to be ON. The ON transistor will cause the capacitor to stay discharged. One way to correct this problem would be to interchange where the + and - inputs to the LM358 connect into the circuit.

\$\endgroup\$
  • \$\begingroup\$ When the cap is initially discharged the +input will be below the -input so there's no problem there.. The op-amp will stop activating the transistor and the cap should start charging again. Maybe i've misread what you've said? \$\endgroup\$ – Andy aka Mar 19 '13 at 10:29
  • \$\begingroup\$ @Andyaka -- You are correct. I misread the + and - schematics connections. \$\endgroup\$ – Michael Karas Mar 19 '13 at 11:19
1
\$\begingroup\$

My first guess would be thatyou fried your transistor by discharging a big cap across it with nothing to limit the current.

\$\endgroup\$
  • \$\begingroup\$ Good point. The problem here is that i need to discharge it fast or else i won't get a sawtooth. Would i fry mossfet if i used it instead of transistor? \$\endgroup\$ – 71GA Mar 19 '13 at 12:41
  • \$\begingroup\$ @71GA - read my re-modified response (EDIT 10:29) - I think you need to apply hysteresis to the circuit or it won't oscillate. \$\endgroup\$ – Andy aka Mar 19 '13 at 13:05
  • \$\begingroup\$ FET would be a better choice, but read the specs first, and test the transistor you have now to see if it works. You have all the tools you need to debug this in front of you, and some good leads to start you in the right direction. \$\endgroup\$ – Scott Seidman Mar 19 '13 at 15:04
  • \$\begingroup\$ @Andy Aka I think you might be right i did measure a very low voltage on the base. Was around 0.2 V. I thought that opamp switches output from 0V to 12V instantaneously. I will try to apply histeresis but two days from now as i am out of country. Will definitely report back if i get the anwser. \$\endgroup\$ – 71GA Mar 19 '13 at 16:38
  • \$\begingroup\$ To reduce the discharge current through the transistor, make the capacitor smaller. You can achieve the same ramp rise time if you make the current source smaller by the same factor. E.g. 0.1 uF cap instead of 10uF, and increase the 10K emitter resistor 100 times to 1 Megohm to program a smaller collector current. \$\endgroup\$ – Kaz Mar 20 '13 at 1:59

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.