Possible to detect pulses over an audio cable without audio board/ADC?

Status
Not open for further replies.

tom_d

Member
Hi,

Just took delivery of a Teensy 4.1 today and first have to say how impressed I am - really easy to get up and running with, had a basic MIDI sequencer going not long after getting out the box!

I would like to detect audio signals for timing sent from an audio interface’s output via an audio cable, these could just be simple clicks or pulses, whatever is easiest to detect... and I was wondering if it’s possible to just directly connect a 3.5mm jack socket to one of the input pins and detect whether the input signal is “low” or “high” in order to detect these pulses, or if I need the audio board or a similar ADC even for this “simple” case?

I’m pretty new to electronics so don’t want to just connect up a jack and experiment in case there’s a risk of damaging the Teensy with the audio signals coming in or whatever - if anyone has any advice here that would be great!

Thanks,
Tom
 
What is the voltage range of these "audio signals for timing"?

Hm, in all honesty I am not sure. They would be being generated by a computer just like any other audio, and coming through the headphone/line out socket of a computer’s audio interface (eg the internal headphone socket on a MacBook). Just a series of clicks or blips or whatever might work best in terms of detecting it, they’d be audible if you plugged in headphones.

The idea is to keep the MIDI being generated by the Teensy tightly in sync with the audio being generated by the computer.

A quick Google suggests this line/headphone voltage level might not be that high? But I am not yet familiar enough with electronics to say for sure, there is talk of impedance etc that goes over my head!
 
The first answer on this Stackoverflow sounds a lot like what I want - I want to be able to detect whether there is an audio signal present (above the background noise level), but I don’t care about actually reading the signal in any way aside from detecting its presence. Is anyone able to advise if this circuit would work please?

https://electronics.stackexchange.c...-to-microcontroller-from-a-3-5-mm-stereo-jack

(My initial post was slightly confused by the way, I realise now that Teensy 4.1 does have analog input pins (ADC) - I was confused with DAC!)

Edit: another relevant link would seem to be http://interface.khm.de/index.php/lab/interfaces-advanced/arduino-realtime-audio-processing/index.html
 
It vital to prevent out-of-range voltages hitting any pin - this can instantly destroy the chip, or if lucky just that pin.

And for an ac signal you must level-shift it to midrail to see the whole waveform.

Something like this:
audio_input_circuit.jpg
The capacitor allows the DC level shift, the two 100k resistors perform the shift to midrail, and the 10k
resistor and two schottky diodes provide protection from over- or under-voltage whether the circuit is
powered up or not.
 
Slightly more advanced you can add a bleed resistor and RF filtering:
audio_input_circuit2.png

The 100pF caps would be ceramic and as close to the input socket/connector as possible - if you have severe
problems with RF break-through the values can be increased to a few nF.

The 1M bleed resistor removes charge from the capacitor to reduce any clicking on connecting an input.

Basically a good audio input network is surprizingly complicated :)
 
Or you could use a voltage comparator lm393
This model have open collector that means you can use a pull up resistor connected to the same supply as the teensy i.e. the 3v3, then the comparator can be supplied by the 5v. This way you also protect the teensy further.
And by using a comparator you can select which level it should detect as high, and because the lm393 has two inside you could also use that to detect when the signal goes under a specific voltage as well.
There can off course be some protecting circuit at the input of the v-comp to protect that.
 
Hi both, I’m sorry I missed your replies, I must have accidentally disabled the email notifications on the thread!

Thanks so much for your input - I was able to get this working with the basic 2x resistor circuit I originally linked to. However, it sounds like this isn’t a very “safe” solution, so I’ll try to replicate one of the circuits you kindly provided and see how that goes (and also try to understand how the circuit works, it felt like a revelation when I understood the basic one and proved my understanding with a multimeter haha) :)

Thanks very much!
 
Status
Not open for further replies.
Back
Top