Maker Pro
Maker Pro

Audio amplifier from biased square wave

davyvr

Jul 29, 2015
3
Joined
Jul 29, 2015
Messages
3
Hello everyone,

I have been looking for about 2 days for a good way to generate sound from a biased square wave, using LTSpice to simulate everything, but I keep seeing high distortion or low efficiency. Since I'm quite unexperienced in this field I decided to post my question here, to make sure I get the basics right.

So at the start I have a pulse wave between 0 & 5 volts, with a fixed frequency (only one tone at a time). I could send this straight into a speaker, but then I would get a 2.5V DC bias into that speaker (not good as far as I read), high distortion because of the square wave, and most importantly , not enough power. My source delivers 10 mA and I need 600mA for the speaker (4 Watts, 8ohm). So I need to double the voltage (5V p-p instead of 2.5V) and a higher current. I have 5V, 9V and 24V available.

I've found some amplifier circuits online, but they all have problems:
1) http://bryanduxbury.files.wordpress.com/2012/01/amplified.png?w=400&h=183
has no DC bias compensation so not good for the speaker. A capacitor in series with the speaker doesn't work here. (correct me if I'm wrong)

2) http://www.electronics-tutorials.ws/amplifier/amp31.gif?81223b
Speaker between Vou and 0V would work, if the resistors in series with the transistor are very low (I need 5V over the speaker). Result: high power loss (easily 70%). Since I'm working on batteries I want to avoid this dissipation of 5-6 watts.

3) http://forum.arduino.cc/index.php?topic=66637.15
Same problem as 1 I think: DC current through speaker. (correct me if I'm wrong)

4) http://www.electronics-tutorials.ws/amplifier/amp47.gif?81223b
Could work, but has some disadvantages which were solved by this one:
http://www.ibiblio.org/kuphaldt/electricCircuits/Exper/05320.png
They both work fine with AC signals 0.5Vp-p I suppose, but again. Mine is 2.5V p-p. So I need to lower it through voltage division, and at the same time low-pass filter it (remove distortion square wave) and high pass filter it (to remove DC bias). This contradicts. And if I want 15kHz to pass I can't get a sine wave out of 2kHz with the same low pass filter. Additionally I don't have -9V so I need to use virtual ground, which gets complicated.

5) So I thought: if I have to go to 0.5V p-p anyway, why shouldn't I use an amplifier chip, like a TI LM384. This simplifies my work. But even then I still wonder how I can get from 0 - 5V pulse to -0.5 - +0.5V sine wave in the complete 2kHz - 15kHz spectrum. And do I have to do this before or after the amplification? I think in case of a chip I need to do it before. But is that the best choice?

6) Perhaps I'm going too far? Is a DC current really a problem? Do I really need a +- sine wave or will my speaker also sound OK with a square wave?

Here I got a bit lost... Can anyone point me in the right direction?

Thanks a lot for anyone who can help!

Kind regards,
Davy Van Rossem
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
I keep seeing high distortion or low efficiency.
Not surprising. A square wave is efficient, but high in overtone content, therefore lots of distortions are heard. A sine wave, on the other hand, has no overtones, so no distortions, but is low in efficiency due to the analog natire of the signal.

DC bias should be not an issue with this circuit. The issue is that the speaker is in the emitter leg of the transistor. The transistor shopuld be used in a common emitter configuration, placing the speaker in the collector leg.Also, since the speaker is an inductive load, a freewheeling diode should be added to protect the transistor. Also you may have to add a series resistor for limiting the power as the 8Ω load will draw too high a current from the 5V.

This circuit is not suitable for power amplifiers. It gives voltage amplification, but not current amplification.

Right, same as 1, only with higher gain due to the use of a darlington transistor. Same comment applies.

This is a typical classs AB amplifier and should work well. Which are the disadvantages you mention?

low-pass filter it (remove distortion square wave) and high pass filter it (to remove DC bias). This contradicts
Only if fc(low) < fc(high). You'd setthe high pass corner frequency fc(high) at e.g. 10Hz to block DC. You set the low pass filter frequency to e.g. 1kHz to reduce higher harmonics. Signals from 10Hz...1kHz will pass the filter easily. This is an issue you'll have with all these amplifiers if you want to filter the signal.

5) So I thought: if I have to go to 0.5V p-p anyway, why shouldn't I use an amplifier chip, like a TI LM384
Because your signal is purely digital. Using a quasi linear amplifier (quasi as the LM384 is a classs-D type) is a waste of ressources and a simple circuit as in 1) can do the job.

6) Perhaps I'm going too far? Is a DC current really a problem? Do I really need a +- sine wave or will my speaker also sound OK with a square wave?
It will sound good with neither of these.
  • A pure sine will sound clear, but is far from the richness of a musical note played by an instrument which always has overtones.
  • A pure square wave has lots of overtones, but not a well formed spectrum
It depends on your goal. What kind of tone do you want to achieve? What is the purpose of the tone (entertainment, alarm,...)? What freqeuncy range do you want to cover?
 

ramussons

Jun 10, 2014
462
Joined
Jun 10, 2014
Messages
462
I have been looking for about 2 days for a good way to generate sound from a biased square wave, using LTSpice to simulate everything, but I keep seeing high distortion or low efficiency. Since I'm quite unexperienced in this field I decided to post my question here, to make sure I get the basics right.

If you drive a speaker from a "biased square wave", you will generate a sound. Is'nt that what you want? o_O

A capacitor will block the DC.

Or are you planning to make a wide range Sine Wave Oscillator? Then there are other ways to go about it.
 

davyvr

Jul 29, 2015
3
Joined
Jul 29, 2015
Messages
3
DC bias should be not an issue with this circuit. The issue is that the speaker is in the emitter leg of the transistor. The transistor shopuld be used in a common emitter configuration, placing the speaker in the collector leg.Also, since the speaker is an inductive load, a freewheeling diode should be added to protect the transistor. Also you may have to add a series resistor for limiting the power as the 8Ω load will draw too high a current from the 5V.

Thanks for reacting so quicky. Some questions extra about this though:
1) "Bias should not be a problem": so the speaker will not break down because of the bias current? I read this in some places.
2) Limiting the power to the speaker: it's a 4 watt 8 ohm speaker so I think I need the 5V without series resistor to get full power sound? This would generate about 90dB and I think I might need this. I can place a potentiometer in series to regulate the volume. Only problem is that I would waste a lot of power when not at full volume. I think there is no way round that with this setup?

This is a typical classs AB amplifier and should work well. Which are the disadvantages you mention?
The explanation is here: http://www.ibiblio.org/kuphaldt/electricCircuits/Exper/EXP_6.html#xtocid103729
This has a not wasteful volume regulator and an efficient output stage, which is good for me, but the "Audio signal in" is supposed to be a sine oscillating around 0V (not with me) and I don't have a -V voltage source so this is not really usable I think?

Only if fc(low) < fc(high). You'd setthe high pass corner frequency fc(high) at e.g. 10Hz to block DC. You set the low pass filter frequency to e.g. 1kHz to reduce higher harmonics. Signals from 10Hz...1kHz will pass the filter easily. This is an issue you'll have with all these amplifiers if you want to filter the signal.
I need sound production on tweeter level between 2kHz and 15kHz let's say. I'm looking to see if I can combine frequencies but this is not sure yet, I want to stay flexible in this. This means that if I put my high pass at 2 kHz I lose too much on > 10kHz, and if I put it at 15kHz, I have a lot of distortion at 2kHz. But I suppose there is no way round that.

It depends on your goal. What kind of tone do you want to achieve? What is the purpose of the tone (entertainment, alarm,...)? What freqeuncy range do you want to cover?
It should in fact be a melody generator for an AGV. So a pure sound is not important, but I don't want it to be unbearable to listen to either. Since I don't have an experimental setup it's difficult for me to judge how far I have to go.

If I summarize: is the best solution to use one of these with a band pass filter in front of them?
http://www.electronics-tutorials.ws/amplifier/amp47.gif?81223b
And then:
1) Is an RC band pass filter OK? So this? http://www.play-hookey.com/ac_theory/filters/images/band_pass_rc_sch.gif
Between 10Hz and 10kHz perhaps and accept the distortion that remains.
2) The output will bias around Vcc/2. I could use 9V supply and then the bias will be 4.5V with signal going back and forth between 0.5V and 8.5V for example. Will the speaker cope with this? It seems strange to me, it will expect -4 to +4 volts instead.

I will try again to make a simulation of this circuit. Of course I also have the problem that I'm not sure my simulation in LTSpice is correct according to what the reality will bring. I found some simplified speaker model but it might not apply to my speaker...
 

davyvr

Jul 29, 2015
3
Joined
Jul 29, 2015
Messages
3
If you drive a speaker from a "biased square wave", you will generate a sound. Is'nt that what you want? o_O

A capacitor will block the DC.

Or are you planning to make a wide range Sine Wave Oscillator? Then there are other ways to go about it.
A capacitor will block the DC indeed but you cannot simply put a capacitor between the speaker and the collector of your transistor I think? In my simulations this doesn't really work anyway.

I want to be able to play a melody in fact, possibly only one frequency at a time, but if possible I might play several frequencies at the same time. It should be loud enough because it will be in a noisy environment, so for this I have a small 4W 8ohm speaker.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
"Bias should not be a problem": so the speaker will not break down because of the bias current?
Forget what I said about a freewheeling (or flyback) diode across the speaker. The flyback voltage will turn on the C-E leg of the transistor thus creating a reverse current through the speaker, thus reversing current direction for a short time. It is not true AC, but sufficient for a toy.
You wouldn't do this to a HIFI amplifier and speaker, but for a simple alarm speaker it is o.k.

Limiting the power to the speaker: it's a 4 watt 8 ohm speaker so I think I need the 5V without series resistor to get full power sound? This would generate about 90dB and I think I might need this. I can place a potentiometer in series to regulate the volume. Only problem is that I would waste a lot of power when not at full volume.
A potentiometer in series would have to have a low resistance (only a few Ω to some 10 Ω - its the ratio of the pot's resiataance to the speaker's resistance that counts) but comparatively high wattage (the pot will have to dissipate the excess power).

I think there is no way round that with this setup?
There is. For one you could use the LM384 as you mentioned in your first post. Then you'd control the amplitde at low power at the input to the amplifier. A class-D amplifier as the LM384 is rather efficient at the cost of increased effort in your circuit.
Depending on the source of your signal you could also use PWM to generate the signal. You'd issue a high frequency PWM signal during the on-period of the tone and no PWM signal during the off-period. By changing the duty cycle of the PWM signal you can control the amplitude of the sound.

That link contains a lot of text. What exactly are the disadvantages you mean? The amplifier will work with a square wave input, too. Lack of a negative supply is another matter.

This means that if I put my high pass at 2 kHz I lose too much on > 10kHz, and if I put it at 15kHz, I have a lot of distortion at 2kHz
No, if ypu put the corner frequency of the high pass at 2kHz, it will let pass frequencies >2kHz, therefore no loss at 10kHz. You'd put the corner frequency of the high pass rather low, say at 100Hz, so everything above this (especially 2kHz and higher) will pass almost undistorted.

It should in fact be a melody generator for an AGV. So a pure sound is not important, but I don't want it to be unbearable to listen to either. Since I don't have an experimental setup it's difficult for me to judge how far I have to go.
Give it a try. The simple amplifier from 1) (with the speaker in the collector leg) is built in no time at all and you can judge for yourself whether the sound is suitable.

I will try again to make a simulation of this circuit. Of course I also have the problem that I'm not sure my simulation in LTSpice is correct according to what the reality will bring. I found some simplified speaker model but it might not apply to my speaker...
Although I'm not unfond of simulations, don't stress LTSPICE too much. For one, as you mention yourself, the result of the simulation depends on the quality of your models, especially the model for the speaker. Secondly, LTSPICE will neither tell you whether a component will break down due to stress (in this case unwanted DC), nor will it tell you how the result sounds (although you can output the current through the speaker as .wav file and listen to it on your computer, but this will not include the effect of the speaker on the real sound in air) .

want to be able to play a melody in fact, possibly only one frequency at a time, but if possible I might play several frequencies at the same time. It should be loud enough because it will be in a noisy environment, so for this I have a small 4W 8ohm speaker.
Have you had a look at melody generators? Schematics or complete modules can be found easily. Add a small amplifier and you're done. Look for a dumped desktop PC speaker with built-in amplifier, connect it to the meldoy generator and you're set up.
 
Top