Electronic – What does this LM393N circuit do

picvoltage

I'm attempting to connect to Loconet(spec) to a PIC32, and I've found a circuit to connect to an Arduino, but I'm not sure what exactly it does:

Loconet to Arduino
(source page)

Specifically, I don't know what the LM393N voltage comparator at the top middle of the schematic does. I think that what is going on is that the LM393N is clamping the voltage to a certain level, between 0 and 5V or so in order for a microcontroller to read it as either a 0 or 1. I'm assuming that because of the following statements in the spec, as well as the given that VCC=5v:

Page 3: 
a) High = 1 = "MARK" : LOCONET+/- voltage above +4.0 Volts with respect to ground conductors. 
b) Low =0 = "SPACE" : LOCONET+/- voltage below +4.0 Volts with respect to grounds. 
c) The data should be received with 1.0 volt of HYSTERESIS centered on +4.0 volts. 
d) Maximum LOCONET+/- high voltage is +24V and nominal is +12V

I've seen another circuit that is similar, but uses an opto-isolator after the voltage comparator to actually interface with the microcontroller, which I'm assuming will then drop the voltage down to CMOS levels if it isn't already.

BONUS QUESTION: The LM393N in the center doesn't appear to be connected to anything, what's up with that?

Best Answer

The inverting input(pin 6) to the comparator is a voltage reference of 3V. This is what you are comparing the non-inverting input(pin 5) to. When the non-inverting input is greater than the inverting input, the output(pin 7) will be high.

Notice that there is a feedback resistor from the non-inverting input to the output. This is for hysteresis. It will keep the voltage at the non-inverting pin slightly higher when the output is high, and keep the voltage slightly lower when the output is low. This will prevent the output from toggling when both inputs are at very similar voltage levels.

This is basically what a schmitt trigger does.

It gives you a nice digital output for your microcontroller.

Bonus: There are two comparators on the LM393N. One is simply not used.