Schmitt trigger

Why do we need a Schmitt trigger?  Well, noise on our signal can cause false triggering.

A noisy signal (just what we expect from a sensor) will produce false counts  Adding a Schmitt trigger circuit to our detector will eliminate this mis-triggering, and give a much more reliable output.
Here is the circuit diagram for our Schmitt Trigger
 

Our practical circuit has this characteristic.  The green line represents a rising voltage, and the blue line a falling voltage at the input. The space between the blue and green lines is the hysteresis.  Once the input signal has passed 4.30V to give a high output it can't give a low output without falling below 4.26V

You can also see that the output voltage changes by 8V for a change of only 0.04V at the input - a gain of  200!

The detector needs a change of 400mV at the Schmitt to provide a rectangular wave at the output.  This means we need only 400uV from the sensor, so should provide excellent sensitivity.