The capacitor is used to remove the DC offset from the PWM output, and the voltage divider is used to reduce the vpp to 1 V. The 10 kOhm resistor is to reduce current to the OPAMP, and 20 kOHM is to multply the input by 2 so that the output wil be 2 V peak to peak. The transistors in the feedback loop helps to supply the required 125 mA to the speaker.
I don't have an scope to test this out, so I'm wondering if someone can verify that this circuit will not blow up.
Looks like it will function OK to me. I would use a audio taper pot on the input signal to give one a volume control. Keep in mind that there will be some 'cross-over' distortion in your output when the signal passes through 0vdc and neither transistors are conducting. 'Hi-Fi' class A/B amps usually apply a little dc bias such the both transistors are conducting a few milliamps with zero signal so that there is a smooth transistion between positive and negative cross-over. However as you are feeding this amp stage square waves anyway it's not like you won't have terrible odd order harmonic distortion anyway. Now if you did some low-pass filtering before the input stage and fixed the cross-over bias you might get musical quality tones through the thing.
s3n4te:
Would feedback cause the output to compensate for deadzone problem?
No. Recall your transistor basics. The emitter/base junction will only conduct when the applied voltage is greater then around .6vdc, so there is a time while the signal is moving from 0 to .6v that the transistor can't conduct. This is the source of the so called cross-over problem as one transistor stops conducting and the other starts conducting.
Any basic description/drawing of class AB amplifiers will explain the DC bias set-up where neither transistor is allowed to completely turn off no matter what the signal value is. In essence the amplifier runs in class A (at a low continuous current flow) until the signal is high enough to 'take control' of the conduction transistor and so enters class B operation.
I understand why there is distortion if there is no opamp there, but not when there is an opamp with the output is connected back to inverting input of the opamp. The output would always equal to the input * gain no matter if the transistors off when input is -0.7 -- +0.7V? Is this correct?
Edit: I did a Fourier analysis at the output with 10khz sine wave, and the THD is only 1.3%.
s3n4te:
I understand why there is distortion if there is no opamp there, but not when there is an opamp with the output is connected back to inverting input of the opamp. The output would always equal to the input * gain no matter if the transistors off when input is -0.7 -- +0.7V? Is this correct?
Yes the opamp feedback circuit will try and correct the situation, but then the output of the amp isn't the real reflection of the input signal (+ gain) for short period of time around zero input signal. It causes a 'notching effect' at zero crossing that is easily seen on a scope and can be heard if one knows what to listen for. Again just read up on basic audio amplifier circuits using discrete components and you will learn all there is to know about the subject.
Modern IC audio amplifier chips do the same thing inside to eliminate the problem. Again this is a classic problem for any amplifier using bipolar voltage push-pull output stage, which allows DC coupling to the speaker. A single ended amp stage does not have this problem, but are very inefficient running in continuous class A operation (50% current flow with zero audio signal) and have to be capacitance coupled to the speaker.
s3n4te:
If I add active low pass filter would that cause my output wave to be triangular?
Not for frequencies below the cutoff design frequency of the filter. Not sure how you are processing audio information via PWM output. Is this using some kind of PCM signal? Or are you just ramping up and down the PWM duty cycle using a audio sine wave table?
It's hard to design an effective filter unless one knows the signal format being used.
the output of the amp isn't the real reflection of the input signal (+ gain) for short period of time around zero input signal. It causes a 'notching effect' at zero crossing that is easily seen on a scope and can be heard if one knows what to listen for. Again
Absolutely true. However, if s3n4te is only listening to square waves out of an Arduino, he probably won't even notice it.
I told him that.
Not clear why one would string all those discrete components together to make a low-power amplifier when you can get an LM386 for less than the price of a pack of chewing gum?
Maybe he is trying to learn how to design audio circuits, it's still an honorable task. The 'golden ear' audiophiles still frown on using opamps or ICs in general in their megabucks systems, go figure.
PS: In his circuit he is taking the feedback signal not from the opamp output, but rather right from the speaker output tap, which is common for such audio amps.
You can improve the crossover distortion by trying to keep the transistors biased. Try adding a few resistors as shown to see if it improves things. You will need to experiment with the exact values, that's half the fun of building amplifiers.
The diodes are to provide the dc bias to prevent crossover distortion, the pot for volume control, and 22pF cap for active low pass filter. What do you guys think?
Okay I built the circuit, and the wonderful smell of magic smoke started to come out both bjts after decreasing resistance in the pot to 0 (I had to replace both). By the way, I kept the 4k and 1k voltage divider in the circuit. How do I calculate the power dissaption of the bjts in this type of circuit?
The MOSFET I used is IRF3707Z, any higher current logic level MOSFTETwill work, such as the sparkfun sells.
The speaker is from mpa.com http://www.mpja.com/prodinfo.asp?number=14618+SP
90dB. I use it in a fencing club to make a warble when a touch is scored, can be heard very well.
The current thru your BJT is (Vsource - Vce)/(sum of resistance in the rest of the path)