I've interfaced a similar microphone to an ADC input on a dsPIC, using a single BJT amplifier biased at half the supply voltage. You are welcome to that circuit, but I don't think that the BS2 is suitable for your application without an ADC.
Here's a circuit that hooks a two-pin electret mic up to an ADC for sampling by a Stamp or other micro. JonnyMac came up with this some years ago.
Ignore the part of the schematic up top for the SX portion (power supply, programming interface, sx). The part you want is the bottom half that shows the pre-conditioning of the mic signal, the op amp, and the ADC. You can read the ADC values which will correspond more-or-less to audio volume.
P.S. -- remember that these kind of mics are kind of like open-drain circuits. The mic has a ground pin and an output pin. The output pin must be pulled high with a resistor to Vdd. When the mic reacts to sound, it drives the output pin low.
What code is that? Post it. The ADC doesn't have to be the one in that circuit (which is going end of life anyway, as far as I know). Any ADC will do, pretty much, and most external ADCs either use SPI or I2C so the Stamp would be able to do it.
Be aware that the ADC will return the instantaneous amplitude of the audio waveform. You will need to take many readings, keep track of the maximum and minimum readings, and then subtract min from max to get the maximum sound level during the period. Still, however, the BS2 will not be able to sample fast enough (i.e. at the Nyquist rate) using this technique, so your results could well be misleading.
Hence the SX in the original circuit for doing the consistent (and fast) sampling. But if bomber wants to get a more or less "ambient" sound level, wouldn't taking a group of successive samplings and then either averaging them (perhaps tossing out the min and max readings as spurious) or doing a simple (slow) Nyquist probably be OK? Practically speaking, anyway, not formally.
No, it probably wouldn't work very well. Besides, averaging an AC wave would only yield the zero (quiescent) level. You'd have to average the mean-square deviation from the zero level to obtain anything useful. The best solution might be to introduce an analog integrating peak detector ahead of the ADC.
The circuit would be arranged so that the AC would be riding on a positive DC bias. But the average reading would equal that DC bias, since there would be as many excursions below the bias level as above. What you want is the RMS reading, not the average.
I think that at the moment, the most important matter would be to get the circuit working!!! I built the circuit, loaded the program, and looked at the Debug screen. I saw a voltage of about 2.5VDC. I made a lot of sound, and watched the Debug screen the reading was 2.5VDC (the reading was actually ocilating between 2.5VDC and 2.4VDC, but when I (and the ambient noise) were completely quiet, the reading kept ocilating between 2.5VDC and 2.4VDC). I turned the Potentiometer and nothing happened.
Here's a circuit you can use to interface the microphone to your ADC:
The first stage is a x100 amplifier to boost the feeble microphone output to something useable. (The LM358 uses a single +5V supply here.) The second stage is a peak detector to sample and hold the high excursions of the audio waveform long enough that they can be measured.
Here's a scope trace showing the input to the peak detector (blue) and the output (yellow):
Some things to tinker with:
1. If you need to measure higher ambient levels than what this circuit accommodates, lower the value of the 1M feedback resistor.
2. There's no bleeder resistor on the 0.1uF output cap. Leakage seems to provide enough of a bleed route that one was not necessary. By the same token, however, if your ADC has a low input impedance, the cap will bleed too quickly. You can substitute a larger cap or use an additional op-amp unity-gain buffer stage after the cap. In this case, you'd want to use a quad op-amp, like the LM324.
Comments
Ignore the part of the schematic up top for the SX portion (power supply, programming interface, sx). The part you want is the bottom half that shows the pre-conditioning of the mic signal, the op amp, and the ADC. You can read the ADC values which will correspond more-or-less to audio volume.
-Phil
-Phil
-Phil
The first stage is a x100 amplifier to boost the feeble microphone output to something useable. (The LM358 uses a single +5V supply here.) The second stage is a peak detector to sample and hold the high excursions of the audio waveform long enough that they can be measured.
Here's a scope trace showing the input to the peak detector (blue) and the output (yellow):
Some things to tinker with:
1. If you need to measure higher ambient levels than what this circuit accommodates, lower the value of the 1M feedback resistor.
2. There's no bleeder resistor on the 0.1uF output cap. Leakage seems to provide enough of a bleed route that one was not necessary. By the same token, however, if your ADC has a low input impedance, the cap will bleed too quickly. You can substitute a larger cap or use an additional op-amp unity-gain buffer stage after the cap. In this case, you'd want to use a quad op-amp, like the LM324.
-Phil