generate a digital signal from an analog source

Thread Starter

dandy1

Joined Sep 30, 2017
88
Is it possible to use an analog signal (speaker output) to signal a digital input?

I have a gsm module which I want to use to signal a digital pin on a microcontroller. When i play an audio file through the speaker i was hoping that i could use the signal voltage to interrupt the micro? The audio is irrelevant and will not be connected to the speaker - so its just acting as another source for an interrupt.

the datasheet:

speaker.JPG
 

wayneh

Joined Sep 9, 2010
16,390
Is it possible to use an analog signal (speaker output) to signal a digital input?

I have a gsm module which I want to use to signal a digital pin on a microcontroller. When i play an audio file through the speaker i was hoping that i could use the signal voltage to interrupt the micro? The audio is irrelevant and will not be connected to the speaker - so its just acting as another source for an interrupt.

the datasheet:

View attachment 205617
Yes, you can detect an audio signal and use it to squelch an input. There are lots of approaches. An op-amp integrator circuit would work, I think, and so would a 555 timer circuit called a one-shot. Once triggered, it will hold an on-or-off output for a selectable length of time. It then resets to watch for another trigger.
 

Thread Starter

dandy1

Joined Sep 30, 2017
88
Yes, you can detect an audio signal and use it to squelch an input. There are lots of approaches. An op-amp integrator circuit would work, I think, and so would a 555 timer circuit called a one-shot. Once triggered, it will hold an on-or-off output for a selectable length of time. It then resets to watch for another trigger.
Interesting - I keep seeing the 555 timer popping up in lots of posts I read, I really should get to grips with its uses - a selectable length of time being 0 - infinite? I really have no excuse not to explore this

On the other hand I was wondering about the output wave of the amplifier - and this demonstrates my knowledge - but does it not output AC characterisitics - i.e negative and positive voltages?
 

Audioguru again

Joined Oct 21, 2019
1,505
If an audio amplifier is powered from a positive and negative power supply then its output is AC. If the amplifier is powered from only a positive power supply then its output averages at half the DC supply voltage but swings up to near the power supply voltage and swings down near 0V by the audio. Then a coupling capacitor blocks the DC and feeds the AC to a speaker. The output voltage swing is determined by the loudness of the audio. If it swings too high then it will destroy your microcontroller but a voltage divider will reduce it.
 

wayneh

Joined Sep 9, 2010
16,390
- a selectable length of time being 0 - infinite? I really have no excuse not to explore this
If you want "infinite", you'd use a latch circuit. That would then require a manual reset. Like many things in electronics, there are several ways to accomplish that.

On the other hand I was wondering about the output wave of the amplifier - and this demonstrates my knowledge - but does it not output AC characterisitics - i.e negative and positive voltages?
Yes, the average voltage should be zero with fluctuations above and below. Just like AC coming out of your wall, that can be rectified to either eliminate (half-wave) or invert (full-wave) the negative-going peaks. You can then smooth (integrate) the pulses to give a steady DC voltage that is proportional to the volume. The one-shot circuit doesn't need a steady voltage - any peak of sufficient amplitude will trigger it.
 

Reloadron

Joined Jan 15, 2015
5,456
I have a gsm module which I want to use to signal a digital pin on a microcontroller. When i play an audio file through the speaker i was hoping that i could use the signal voltage to interrupt the micro? The audio is irrelevant and will not be connected to the speaker - so its just acting as another source for an interrupt.
Since you plan to just run the audio into a uC to make something happen I really see no need for a 555 or other discreet active components. I would just get a common 1N914 or 1N4148 diode and place it in your audio path. Cathode side (band) to your uC digital input pin. Give this a read as your audio positive peaks need to be of enough amplitude for your logic to see a digital high. I don't know if your uC is using 3.3 volt or 5.0 volt Logic? I guess if you have one you could also use an analog input channel and give it a low threshold in your code to trigger or do whatever you want to do. The uC will try and clip any signal going below common (0 volts) so we place a diode in there passing along only the positive peaks.

Ron
 

Thread Starter

dandy1

Joined Sep 30, 2017
88
Since you plan to just run the audio into a uC to make something happen I really see no need for a 555 or other discreet active components. I would just get a common 1N914 or 1N4148 diode and place it in your audio path. Cathode side (band) to your uC digital input pin. Give this a read as your audio positive peaks need to be of enough amplitude for your logic to see a digital high. I don't know if your uC is using 3.3 volt or 5.0 volt Logic? I guess if you have one you could also use an analog input channel and give it a low threshold in your code to trigger or do whatever you want to do. The uC will try and clip any signal going below common (0 volts) so we place a diode in there passing along only the positive peaks.

Ron
I suspected that i could get away with a diode. The GSM determines the voltage which can be as high as 4.4v. But as it works fine at 3.7v (and this helps keep the power down) and this would be the nominal design voltage. The uC is atmega328pb and there are available analog channels to use but the ADC is switched off during sleep so that's a no go. I'd imagine that there is enough voltage (60% of vcc) to guarantee an interrupt - but does require 1 clock cycle @8Mhz for a clean interrupt.


Give this a read link routes me to my mail outbox? was that the intention?
 

Reloadron

Joined Jan 15, 2015
5,456
Just about anything audio, even an audio spike should exceed .125 uS which is an 8.0 MHz clock cycle time. I have an Arduino Uno sitting here plus an audio source, I could likely just flick a piezo transducer. What I don't have laying here is a simple, common diode. :) It should be easy enough to try.

Ron
 

Thread Starter

dandy1

Joined Sep 30, 2017
88
Just about anything audio, even an audio spike should exceed .125 uS which is an 8.0 MHz clock cycle time. I have an Arduino Uno sitting here plus an audio source, I could likely just flick a piezo transducer. What I don't have laying here is a simple, common diode. :) It should be easy enough to try.

Ron
Yes cheers Ron, will give it a try as soon as I can get away from this 555 timer piece - I'll be up all night now!
 
Top