Experiments with a 74HC14 Schmitt-Trigger IC2021-01-29
A recent PetitFoo talk at the Chaospott on how to debounce keys with a Schmitt trigger prompted me to play with a 74HC14 IC I had lying around.
converts an analog voltage to a digital logic level.
It has two voltage thresholds, and the interesting thing happens between the two:
Here is an oscilloscope screenshot of the basic behavior of one inverter of the 74HC14, using a triangle wave from the function generator as the input: The yellow trace is the input triangle wave, the green trace is the output. The X cursors are set to the edges of the output manually. The Y cursors are set to track the input waveform, in order to get the voltages corresponding to the X cursors. You can see that it switches the output when the input reaches 1.94 V on the downward slope (Y1), and when it reaches 3.07 V on the upward slope (Y2).
The circuit is very simple and consists only of the 74HC14, and a 100 nF decoupling cap for the power supply on the top left of the IC. The input signal is attached to the pin header on the left and is connected by the green wire to the input of the first inverter on pin 1 of the IC. Its output is on pin 2. The other inputs are tied to ground to prevent unwanted oscillations, other outputs are not connected. The oscilloscope probes on pin 1 and 2 are attached via 100 Ω resistors, which reduce ringing but cause a small slowdown.
Schmitt-trigger vs standard logic input
A close-up on the output edge shows that it is very clean. Its rise time is about 3 ns and there is just a little bit of overshot and ringing:
When the 74HC14 is replaced by a 74HC04 hex inverter with standard non-Schmitt-trigger inputs (and the triangle wave slowed to 10 kHz) then the output misbehaves severely, oscillating for about 600 ns somewhere in the middle between the logic levels:
Building a Relaxation Oscillator
It's also easy to build an oscillator from a Schmitt-trigger inverter, a so called relaxation oscillator. Connect a capacitor between the input and ground, and a resistor back from the output to the input. Then the output will cyclically charge and discharge the input capacitor, and the input voltage will oscillate between the two thresholds. The frequency is determined by R, C and the threshold voltages, which in this case are not that well defined (the ranges for the thresholds specified in the data sheet are quite large). So it should only be used if the frequency doesn't need to be precise. This is an example with R = 10 kΩ and C = 100 nF and a frequency of roughly 1 kHz:
Tie Your Inputs Down!
And since it is so easy to get an oscillator, if you don't tie the other inputs to a defined logic level then it may happen all by itself, some of the inverters may start to oscillate and disturb the rest of the system. In my circuit the first inverter does this, and if I connect the triangle wave to the second inverter it gets a lot of injected noise from its neighbor: