0
\$\begingroup\$

I am trying to find a way to connect an Arduino board to an USB sound card, equipped with 2 outputs: RCA and headphone jack 6.3mm. I would like to simoultaneously play a sound from one and record the signal output from the other. The sound changes in volume, but has short duration. My main goal is timing: I want a voltage trace that takes trace of when the sound is played and when it is not, so that I can syncronize it with other signals in my setup (I allign the signals a posteriori, after the voltage traces have been recorded and saved on my PC, no need of doing it on-line). I am also not very interested in the sound waveform itself, as I already know it. I mainly care about timing.

To this end, I have connected a couple of speakers to the RCA port and I am trying to connect the headphone jack to Arduino. I am using a 6.3>3.5 mm adapter, male-male jack cable to carry the audio signal to Arduino with the help of a breakout board like this.

I am reading the audio signal through the A0 PIN of Arduino. I am trying to use this circuit found in the internet:

schematic

simulate this circuit – Schematic created using CircuitLab

If I get it right, the resistors represent a bias circuit so that the negative voltages coming from the jacks are turned into fluctuation around a constant positive voltage (in this case 2.5V for the way the voltage divider is built).

What I really do not get is:

  1. why do i need the capacitor? Perhaps to low-pass filter the signal? can I use higher/lower capacitance?
  2. is it safe to use this circuit? I have read that headphone and line-level audio output, in absence of amplification, are kind of OK. But how do i make sure that I will not damage with overcurrent/voltage Arduino or the USB port to which it is connected?
\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

Yes you need the capacitor to decouple the DC bias you have correctly found on the input,otherwise you will possibly damage the audio signal source. Circuit looks safe ( if you use the capacitor ) and unless the output voltage of the audio source exceeds the maximum Arduino accepted voltage ( 5V ) this means your audio output being over 5 vpp, everithing will be fine. In any case no damage to the USB is expected. Capacitor value of 10 uF looks big enough to don't cut any low audible frequencies.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Not just 5 Vpp, but 2.5 Vpk. Positive and negative peaks aren't necessarily the same magnitude. \$\endgroup\$
    – Hearth
    Dec 11, 2023 at 20:33
0
\$\begingroup\$

To answer your questions:

  1. The analog pin on the Arduino can only read signals within its supply range (0V to 5V in this case). By setting the bias at 2.5V with the resistor network, you have the largest amplitude of input you can measure (+-2.5V swing). This way, you can measure the negative side of the wave too, which is impossible if it's a negative voltage. The capacitor here is to block the DC bias of the signal and allow it to be set relative to mid-rail; theoretically in steady state, this capacitor could be as big as you wanted. It's a low-pass cap and sets the low pass 3dB roll-off frequency along with the effective resistance of your divider network, f=1/(2pi50kOhm*C). In this case you're passing signals above about 0.3Hz, which is plenty low, and it also means you need at least a couple seconds to bias up when you first turn on the supply.

  2. It's safe to use as long as you can guarantee your input doesn't go above 2.5V peak amplitude. If this is a concern, you can put a diode from your A0 to positive voltage, and your ground to A0. This clips the signal if it swings too far. If high frequency, high amplitude ringing is a use case you want to design for, you can also put series resistance with your capacitor to limit current; if you do this though, you'd probably want to use something more like a 1uF capacitor and then use 8 Ohms impedance, which would give you a high frequency roll off around 20kHz.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ For section 2, it's not 5 Vpp, but 2.5 Vpk that's the limit. Positive and negative peaks aren't necessarily the same magnitude. \$\endgroup\$
    – Hearth
    Dec 11, 2023 at 20:34
  • \$\begingroup\$ @Hearth yeah, you're right; I've updated it to reflect your point. It would take a pathological example for it to make a difference (more likely something from a function generator than a guitar), but still worth mentioning in case they're into electronic music. \$\endgroup\$ Dec 12, 2023 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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