0
\$\begingroup\$

I'm trying to create a digital audio switch or relay using an Arduino nano.

It's a very simple circuit, it's just a gate (transistor) which is operated by a digital signal (computer) through a microprocessor (Arduino nano).

I have a NPN transistor working as a switch, which receives the audio signal (at the collector) and receives a 5v signal from the Arduino (at the base) to open the gate and then send (at the emitter) the audio signal to the speaker. It works fine, except for the noise ("click" or "pop") that is heard when the gate opens. I did some research and it seems that a capacitor could open the gate slowly (fading in) eliminating the noise.

I've tried some types of ceramic capacitors and I'm not sure if I'm doing something wrong or using the wrong capacitor, but so far I had no results.

I guess it would be just like fading in a LED from a 5V signal passing through a transistor. Could anyone help me?

Thanks a lot!

Ian

Below is an attempt of a schematic, my apologises if it's not very accurate (I'm a musician).

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • 1
    \$\begingroup\$ Feeding DC to a speaker sounds like a bad idea \$\endgroup\$ – PlasmaHH Jun 6 '16 at 10:51
  • 1
    \$\begingroup\$ Could you post a diagram of what you are doing? It would be easier to discuss. \$\endgroup\$ – JRE Jun 6 '16 at 10:52
  • \$\begingroup\$ I'm actually not feeding DC, the DC signal only opens the gate for the audio signal and maybe it also amplifies it (a transistor also amplifies a signal, right?). But if it's really a bad idea, I guess I can put a resistor before the base. \$\endgroup\$ – Chu Jun 6 '16 at 10:55
  • 1
    \$\begingroup\$ There is a schematic button on the editor toolbar. Draw a diagram of the essential parts of what you have built. Realise that your audio signal is AC and will oscillate above and below GND. \$\endgroup\$ – Transistor Jun 6 '16 at 10:56
  • \$\begingroup\$ Ok I will try to draw it. I've never drew electronic diagrams/schematics as I'm a musician and not an electrical engineer, but I will try to do it anyway, sorry if it's too amateur. \$\endgroup\$ – Chu Jun 6 '16 at 10:58
4
\$\begingroup\$

I'm surprised that you don't hear a lot of distortion when you turn on this circuit. There are a few problems.

  • You are now feeding DC to your speaker. If you turn off the audio and turn on the transistor you will see the speaker coil move in or out and stay there until you turn the transistor off.
  • The DC is flowing from the battery through the base of the transistor and out the emitter to your speaker.

Usually it's best to mute the audio at 'line' level before it gets to the amplifier. Alternatively use a relay energised by your micro to connect and disconnect your speaker.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Switching speaker with relay.

How it works:

  • The GPIO goes high and a current of a few mA flows into Q1 base.
  • Q1 turns on and RLY1 is energised. The contact closes and the speaker is connected to the amplifier.
  • On switch-off D1 absorbs the inductive kick from the relay and prevents damage to Q1.

Depending on your amplifier you may still hear a click or thump in the speaker. This is usually caused by the amplifier output capacitor discharging through the speaker. Putting 100 \$\Omega\$ or so between AMP+ and AMP- will discharge the capacitor before the relay contact closes and prevent the thump.

\$\endgroup\$
  • \$\begingroup\$ Thanks for your answer! I want to try this solution since I will need to have amplified speakers in this project. Just a quick question, do I really need Q1? Couldn't the GPIO energise the relay directly, closing the contact? (I've never used a relay before but I'm guessing it works like a transistor, so why 2 gates?). Thanks. \$\endgroup\$ – Chu Jun 6 '16 at 14:11
  • \$\begingroup\$ Calculate the relay current for the device you choose, compare that with the maximum GPIO current, applying a safety factor of at least two and then decide. \$\endgroup\$ – Transistor Jun 6 '16 at 14:22
2
\$\begingroup\$

The symptoms you are describing is exactly WHY that technique is not used by designers of quality audio circuits. Using a bipolar transistor in series as a switch will inherently cause that problem because in fact your audio signal is riding on top of a DC component, and that DC component switching transient is what you are hearing.

The more common ways of switching audio signals include:

  1. Use the bipolar transistor as a SHUNT (where the audio is "shorted" to ground when turned "off"). This is rather less susceptible to switching transients, but is considered a rather "low-end" solution.
  2. Use a MOSFET switch, particularly one which is powered from a bipolar supply. For example the very common "jelly-bean" chip 4066 has long been a popular choice for this application.

Ref: http://tech.thetonegod.com/switches/switches.html

\$\endgroup\$
  • \$\begingroup\$ To clarify: the 4066 will work on the line-level circuit but won't handle the speaker current or negative voltages. \$\endgroup\$ – Transistor Jun 6 '16 at 12:01
  • \$\begingroup\$ Yes, good clarification. We are assuming you aren't REALLY switching speaker-level signals. That is typically NOT a proper technique. Audio signals are typically switched and otherwise controlled and processed at "line-level" before being presented to the speaker-level amplifier as the final stage. The 4066 will handle negative voltages if one uses a bipolar power supply as I mentioned. \$\endgroup\$ – Richard Crowley Jun 6 '16 at 12:04
  • \$\begingroup\$ Thank you for your answers!! I've just tried with a 4066 and it's working perfectly since I'm using it at line-level. The other solution seems great as well, but I don't have a relay and a 1N4148 diode to try yet.. I may try that as well in future when I buy them, anyway, so far so good! Thank you for your time, I really appreciate! \$\endgroup\$ – Chu Jun 6 '16 at 12:55

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.