0
\$\begingroup\$

I'm trying to use a soundcard to send a trigger signal to an Arduino. However, the software I'm using limits the output of the soundcard to between -1 and 1V, which is insufficient to trigger the digital pin on the Arduino.

Basically, I want to try and amplify this 1V signal to a 3.3-5V signal in the simplest way possible, maybe by using a transistor to route the Arduinos 5V supply to the digital pin.

This is somewhat time sensitive, and the only components I have available at the moment are some NPN transistors (2N2222) and a broad selection of resistors. Can I build a transistor amplifier to get the 5V I need? I'm new to this, so I am also not sure how/where to put resistors in this circuit. Any help would be greatly appreciated!

edit: Just to clarify, I'm using the soundcard to present a sound on one channel, and this trigger signal, in the form of a short pulse, to accurately estimate the onset of the sound from the arduino/for other experimental synchronization purposes

\$\endgroup\$
  • \$\begingroup\$ How do you plan on using the soundcard? Do you send a specific tone and want it detected regardless of amplitude? Or would you use a specific amplitude and want that detected regardless of frequency? Or do you think you can use the soundcard to produce DC pulses that go between those two voltages you mentioned? (Which I doubt you can reliably do.) (Personally, I'd just pick a tone and use amplitude modulation for triggering -- this would require a peak-detector circuit, which can be done well with two BJTs.) \$\endgroup\$ – jonk Jun 16 '17 at 16:25
  • \$\begingroup\$ Try using an arduino analogue pin and bias the soundcard signal to Vcc/2. \$\endgroup\$ – Andy aka Jun 16 '17 at 17:41
  • \$\begingroup\$ jonk - The way we have used this identical sound card is to just produce short 5V pulses to use as triggers, which have been vary reliable in the past. || andy - is the idea here to have some threshold detection on the analog pin? I've thought of that, but we want very fast detection of the trigger event, so we can estimate the onset of another sound on a separate analog channel, so I was worried that this might be a bit slow. \$\endgroup\$ – Chris Jun 16 '17 at 17:44
0
\$\begingroup\$

It would seem that you require a non-linear amplifier, because the digital input will only recognize a logic high (near Arduino + supply) or a logic low (near Arduino's ground).
This is complicated by a general CMOS requirement to drive an input very close to logic low, or very close to logic high - lingering near half-way stresses the logic gate with excess shoot-through current, or may cause oscillations. So a fairly high-gain amplifier is required, or a comparator.
Another complication involves AC coupling that a sound-card invariably employs: its average output will always be zero volts, even if you program full amplitude +1V or full -1V. So your threshold circuit will only be able to detect changes of amplitude.

schematic

simulate this circuit – Schematic created using CircuitLab This inverting amplifier will boost small changes at its input to logic-level changes at its output (Logic out) for a microcontroller. With no input, or too-small input, base biasing is arranged that "Logic out" will be high, pulled up via R3. Positive-going pulses at the input will turn on the transistor, and produce a logic low at the output, for a short time only (probably milliseconds).
Audio output must have its ground connected in common with the microcontroller's ground. Since this is a non-linear amplifier, output is very distorted, and would sound unintelligible. A continuous, full-amplitude tone at the input would produce logic-level pulses of the same frequency at the logic output.

\$\endgroup\$
  • \$\begingroup\$ Thanks! I'm not using an actual "sound" to trigger the arduino, but a square pulse on one of the channels, so I think AC coupling is not an issue? This leads to my next question: right now I'm sending a 5ms pulse as my trigger, will this lead to the logic out remaining low for ~5ms, or will it briefly go low at rising edge of the pulse? Thanks! \$\endgroup\$ – Chris Jun 16 '17 at 17:56
  • \$\begingroup\$ AC coupling will be an issue. Ensure that your audio-generated square pulse is a positive-going pulse. It's leading-edge should cause a negative-going logic edge at Arduino's input that is time-coincident. The later logic return-to-high might not be time-coincident with your input pulse (unless your input pulse is very short). \$\endgroup\$ – glen_geek Jun 16 '17 at 18:02
  • \$\begingroup\$ Ok, only getting around now to implementing the circuit. I'm assuming that the audio in (-) is supposed to go to the arduino ground (maybe the diagram is unfinished on the left??) \$\endgroup\$ – Chris Jun 16 '17 at 21:25
  • \$\begingroup\$ Yes, ground of soundcard (at input) to ground of microcontroller. \$\endgroup\$ – glen_geek Jun 17 '17 at 12:47
1
\$\begingroup\$

This will turn on the transistor when the audio voltage exceeds approx. 0.7V, this will pull the IO pin low. It will only trigger on the +ve going part of the audio signal.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ Essentially the same circuit as our man above but he is using quite low resistor values \$\endgroup\$ – cyclotron Jun 16 '17 at 16:35
0
\$\begingroup\$

I assume your sound card output is capacitively coupled ...if not then you could put a capacitor (1 uF or more) in series with the input.
The Arduino input pin should toggle for signals above about 0.7-0.8 V positive peak. If you use low frequency sine/square waves you may be able to get both presence and a frequency indicator.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
0
\$\begingroup\$

You can use the below circuit. As you haven't any diodes to hand, Q1's base-emitter diode is used to protect Q2's base from large negative voltages, such as static or transients.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • 1
    \$\begingroup\$ I do have a diode actually, I would swap that with Q1, with diode pointing away from ground? \$\endgroup\$ – Chris Jun 16 '17 at 17:55
  • \$\begingroup\$ Oh good and yes, anode to ground, cathode to base \$\endgroup\$ – TonyM Jun 16 '17 at 17:57

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.