Schmitt Trigger to clean square wave

Thread Starter

sc0tch

Joined Nov 6, 2018
64
Hey guys,

I have a set of hall effect water flow sensors at the end of a long cat5E cable. The circuit has worked very well over past several months with about a +/-4% margin of error. Looking with an oscilloscope where lot of the issues is when the sensor stops with the magnet next to the hall effect sensor leaving the gate closed. During these times there is an occasional dip by roughly .75V making the pi register another rising edge when it rises.

My question is, is this something that a Schmitt trigger could clean up, and if so should I use it before the voltage spliter on the 5V0 signal or after the slitter against 3V4 signal? Also what would be an advisable reference voltage to give the trigger?
 

crutschow

Joined Mar 14, 2008
34,464
A Schmitt trigger should help.
You can configure the LM393, that Eric mentioned, as such a trigger with a small amount of positive feedback.
 

MrChips

Joined Oct 2, 2009
30,823
The main purpose of a Schmitt trigger is to implement hysteresis. This prevents chatter when there is noise in the region of the low-to-high and high-to-low transition thresholds. It also provides shorter rise and fall times at the output.

If you are using long cables, you want to avoid short rise and fall times at the transmitter. Cable drivers are designed to slow down the edges. A slower edge reduces the bandwidth of the signal which in turn reduces signal ringing and cross talk.

You want to put the Schmitt trigger at the receiving end of the cable. You can use an analog comparator such as LM393 as a Schmitt trigger. Just remember to add positive feedback along with a pullup resistor at the output.

The reference voltage of the comparator should be set to halfway between the Vmin and Vmax of the received signal.
 

Thread Starter

sc0tch

Joined Nov 6, 2018
64
hi S,
Have you considered using a LM393 dual comparator, low cost and small size.?
E
A Schmitt trigger should help.
You can configure the LM393, that Eric mentioned, as such a trigger with a small amount of positive feedback.
The main purpose of a Schmitt trigger is to implement hysteresis. This prevents chatter when there is noise in the region of the low-to-high and high-to-low transition thresholds. It also provides shorter rise and fall times at the output.

If you are using long cables, you want to avoid short rise and fall times at the transmitter. Cable drivers are designed to slow down the edges. A slower edge reduces the bandwidth of the signal which in turn reduces signal ringing and cross talk.

You want to put the Schmitt trigger at the receiving end of the cable. You can use an analog comparator such as LM393 as a Schmitt trigger. Just remember to add positive feedback along with a pullup resistor at the output.

The reference voltage of the comparator should be set to halfway between the Vmin and Vmax of the received signal.
Thanks everyone! My plan was to implement a trigger at the receiving end of the line as that's the PCB that has all my logic gates and such on it anyway. Is it better to use the comparator on the 5V signal then drop to 3v using a splitter or zener? Or should I drop to 3v then use a comparator
 

crutschow

Joined Mar 14, 2008
34,464
Is it better to use the comparator on the 5V signal then drop to 3v using a splitter or zener? Or should I drop to 3v then use a comparator
I see no good reason to drop the voltage first, unless you only have 3V available to power the comparator.
In that case, use a resistive divider to reduce the signal voltage to 3V maximum.
 

Thread Starter

sc0tch

Joined Nov 6, 2018
64
I see no good reason to drop the voltage first, unless you only have 3V available to power the comparator.
In that case, use a resistive divider to reduce the signal voltage to 3V maximum.
I have 3V3, 5V, and 12V available on my board so powering the comparator at 5 isn't a problem. Thanks so much for the help!
 

MrChips

Joined Oct 2, 2009
30,823
You can power the LM393 at whatever supply voltage you have available from 2 to 36V. The output of the comparator is open collector. Hence you will connect a pullup resistor (3K to 10KΩ) from the output to your 3.3V logic supply.

Use a terminator resistor (about 330Ω) at the receiving end of the cable. Then examine and measure the signal at the receiving end of the cable using an oscilloscope.

Edit - If the received signal is 5V high, then power the LM393 with 5V. If the signal is greater than 5V and less than 12V, power the LM393 from the 12V supply.
 

Thread Starter

sc0tch

Joined Nov 6, 2018
64
hey crutshow,

Im redoing the schematic, and wasn't able to screengrab as when it expired it just had a prompt to purchase over the whole window. Thought i was using a free online tool but guess it wasn't really free. Another colleague also recommended using a zener diode instead of my voltage divider.

His logic was the voltage divider if the voltage dipped 1 volt from 5 to one would drop the 3.4V output to 2.9V which is below the gate threshold. But using a zener diode of 3.3V these dips should not effect output voltage at all unless they dip below 3.3V.

Any thoughts on the validity of that approach? or would i be best off sticking with the comparator?
Also whats a good program to quickly draft schematics, I really cant stand working with the schematic portion of circuitMaker(altium) though i do like it's PCB design capabilities

Thank you!
 

ericgibbs

Joined Jan 29, 2010
18,865
His logic was the voltage divider if the voltage dipped 1 volt from 5 to one would drop the 3.4V output to 2.9V which is below the gate threshold. But using a zener diode of 3.3V these dips should not effect output voltage at all unless they dip below 3.3V
hi
Please post a sketch of this circuit.
E
 

Thread Starter

sc0tch

Joined Nov 6, 2018
64
Thanks for the time and patience everybody! Here is the current schematic simply using a voltage splitter, along with a schematic using a LM393(cad software says 339 as it didn't have the 393) and the last one as using a Zener diode to achieve 3.3V

Current Configuration-Voltage Splitter_sc0tch.png

With LM393_sc0tch.png

With Zener_sc0tch.png
 

Thread Starter

sc0tch

Joined Nov 6, 2018
64
Sorry forgot to divide voltage output from the comparator and pull down the input.

I also attached the PCB Layout i'm playing with using 4 of the dual differential comparators. I know it's not really feasible to read from a PCB but i also made another schematic. With LM393 Fixed.png With LM393 PCB All.png With LM393 PCBPartial.png
 
Top