3

I have been working on a project lately which uses Arduino to play a wav file from SD card. I am using TMRPCM library which made the job very easy. But the problem is that the output sound in the speaker is very low. I am using the below single transistor circuit with my Arduino to drive 1.2W / 8ohm speaker enter image description here But the Audio output is barely audible. And i have tried many speakers with different wattage but same result.

I am wondering that is there is something wrong with the Wav file i have used for my project. It is 16000Hz/ 8 bit unsigned PCM coded. So in a nutshell my questions are

1) How can i improve the sound obtained from my speaker by making modifications in the transistor amplifier circuit?

2) Was the less audible sound is due to the Wav file i have used?

Kindly help me out, thanks in advance.

closed as off-topic by MichaelT, sempaiscuba, Juraj, VE7JRO, MatsK Mar 13 at 15:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Arduino, within the scope defined in the help center." – MichaelT, sempaiscuba, Juraj, VE7JRO, MatsK
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I had some success using an LM386 audio amplifier after an CRC band-pass filter (to remove the DC and the PWM frequency). It's a very common and cheap (less than $1) amplifier specifically designed to drive a speaker. See the datasheet for the proper wiring. – Edgar Bonet Apr 26 '17 at 7:41
  • Can you play the WAV file on your PC? Is it quiet on there? Can you play another WAV file, or use another audio source? – Code Gorilla Apr 26 '17 at 8:29
  • Hi @EdgarBonet , I have tried hooking up with a LM386 based amplifier but very little improvement. May be i will try with the CRC filter before feeding it to transistor. Am not quite whether its quiet in PC i would say its fine. Other wav files are less audible as well. However i have tried default Arduino melody tones which sounds pretty good with the same setup – Frank Donald Apr 26 '17 at 9:01
  • you need to at least block the dc component with an rc filter. edit: basically, what Majenko has shown. – dandavis Apr 26 '17 at 21:43
  • Ditto with @Edgar. There are Arduino LM386-based amplifier modules available for peanuts. They can drive a decent speaker. – SDsolar Apr 27 '17 at 6:00
5

Your amplifier arrangement is fundamentally flawed. At the moment you are "tickling" the top end of the electromagnet in the speaker - that is, you are energising it when the Arduino outputs a HIGH, and leaving it energised to de-energise by itself when the Arduino outputs a LOW. Coupled with that the fact that a PCM file outputs PWM with a carrier frequency much higher than a tone() function (and ideally above human hearing frequencies) you end up with almost nothing happening on the speaker.

The classic Class A amplifier has a different arrangement:

schematic

simulate this circuit – Schematic created using CircuitLab

With that arrangement the transistor and R1 form a simple RTL inverter. Size R1 to give the output current you need for your speaker (lower resistor = more power = more heat = bigger transistor as well). R3 and C2 remove the high frequency switching from the PWM (you could also replace R3 with a suitable inductor if you want less losses from the resistor). C1 removes the DC offset from the signal to give the full swing to the speaker and prevent excess clipping and heating.

It's not an efficient design by any means. A better "first stage" (replacing R1 and Q1) would be a high drive output logic gate (one of the CD4000 series, since it can run from 12V). I have seen AND gates used before - this also gives the benefit that you can use the second input to the AND gate as a MUTE signal. The rest (R3, C1, C2) remains the same.

The advantage of using a logic chip instead of the RTL arrangement is that it gives a more efficient "Push-Pull" output which can deliver much more current with far less heat losses.

Instead of the speaker you could connect an audio power amplifier to the output of C1 to then drive a more powerful speaker. In this case you can most likely remove the first stage (Q1/R1/R2) and drive the RC filter directly from the Arduino.

  • Thanks for the circuit. Tried it but no luck the sound has even dropped. Double checked to make sure i have hooked up everything correctly. Also the transistor is heating up, any idea why this is happening? – Frank Donald Apr 27 '17 at 4:28
  • The transistor is heating up because it's a tiny little 2N2222. If you look in a real audio amplifier you will see TO220 style transistors and big heat sinks. Using PCM audio on an Arduino is pretty silly anyway. You should invest in a proper audio shield, or a more powerful MCU that can do real audio. – Majenko Apr 27 '17 at 9:51
1

You might try an audio transformer in the circuit, following a low-pass filter to smooth the PCM signal. Here's a picture of suitable inexpensive transformers (from alexnld.com; but similar transformers are available on Ebay etc.):

1300:8 audio transformer, about 1/2" on a side

The effect of the transformer in the circuit is transforming the high voltage, high impedance output of the transistor driving circuit to the low voltage, low impedance needed at the speaker. The impedance ratio of the transformers in the picture is 1300 Ω to 8 Ω.

0

"It is 16000Hz"

That's pretty high frequency. Is your hearing good enough for that? Many folks couldn't hear it.

0

First, do not get fooled by some that answer that 16kHz is a pretty high, nearly unhearable frequency. You're talking about sampling rate here. Then 16khz is pretty low end (although maybe on the edge of what's possible with the microcontroller, I don't know that off the top).

I would recommend introducing a negative supply rail to majenko's design as you can not expect a circuit to output negative voltages (i.e the negative halfwaves of an audio signal) without a negative supply...

As others already pointed out the transistor you use is a pretty poor choice. There is a transistor selection guide available here. It has an audio section, take a look at that!

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