process audio with an LM393 : harder than it seems

Hi all,

I'm trying to use an LM393 as a "positive detector" on two audio signals.
I mean that when the audio signal from the pre-amp is above 0 volts the LM393 should produce an arduino-compatible "1" (or "0").
the audiosignal is produced by the pre-amp using a 2.2uF cap in series, so what I get is a pure ac wave without DC bias.

easy ? well, I have searched hard and not found anything that really fulfills my needs (yet). "The Art of electronics" shows a
zero crossing circuit, but that did not work with the pre-amp.
I think that example assumes the source can deliver some current.

My needs are that I can measure the exact time the signal goes from

  • to +, or at least that all audio signals have the same delay when detecting this transition. if all else fails I would want something that
    can be regulated (i.e. tweaking some potmeters) to calibrate the setup. Very few components would be an added bonus.

it currently seems to work best with resistors from LM393 inputs to ground on all inputs. But I understand that the audio could go well
below -0.3 volts (+1/-1volt typ.), i.e. outside the range the LM393 can handle. Sometimes the LM393 seems to get into a high frequency
oscillation which might be caused by this (but it could also be the very old analog
oscilloscope I have, I'm more of a programmer..)

I now added diodes in the paths to ground to create a base DC voltage level of about 0,5 volts on the LM393 input pins (forward diode drop).
The actual voltage drops seem to vary with the diodes, it seems.
This means that for a pure sinus the square wave will be shorter on one LM393 output pin than on the other because
I will detect the (preamp-) signal crossing some voltage in the vicinity of 0 volts, differing per input.

is there any other way to add a bias to all 4 of the lm393 inputs, while not degrading the audiosignal ?

on another note : would a LVDS line receiver be a solution (instead of the LM393) ? such a beast still needs 350mV,
i.e. 0.3 volts bias, but al least it is an integrated solution.

Sorry if this seems discussed a hundred times, but when you try to build something, it is always harder than it seems.

here is what I have now. it shows one arduino pin being served.
I have another cricuit just like it servicing another arduino pin.
the pre-amps are earthed too, but I forgot to draw that line.
since the LM393 is open collector, I can connect the
5V arduino to this 9V setup.

I think you are right. the LM393 does already do the rail to rail switching, but the input weakness is what is giving me problems.
and I still have to insert a filter too before the LM393.

anybody who knows a nice one-chip 4 channel audio amplifier ?
(I know I can do it with opamps, but that usually means
quite a bit of extra components. I'm all for simplicity)

the filtering bit was another thing to do, I'm now testing without a filter
(hurray for the breadboard).
freq. range will be up to about 4000 Hz.
I thought you advised me to amplify the signal first, but on second reading you seem to advice to amplify instead of applying the lm393.

I seem to recall it is possible to combine the filtering and amplifying requirements to be combined in an opamp setup. back to the books...

Thanks for your responses !

Looking at that circuit you need a resistor from the positive input of the LM393 and the +ve supply.
As you have it there is no current from the positive input to make the diode conduct and so set the threshold at the 0.7V you want it to be.

Thanks. it works now.
I was under the impression that the inputs of the LM393 were
supplying current, because I read somewhere that when only connected to a capacitor they tend to charge up the capacitor until Vcc is reached.
I was expecting that the same process would build up a voltage until the diode would start conducting.
but a large-value resistor to vcc did the trick.

Thanks !