Monday, 8 December 2014

How to make a Schmitt Trigger using an OP-Amp

Time for another tutorial with Op-Amps - This time the subject is Schmitt Triggers.  These are electronic circuits similar to an analogue comparator except that the output value does not change until the input changes more than a preset threshold.  So it is very similar to a comparator with Hysteresis but the threshold levels control the output.

Here are some websites which discuss Schmitt Triggers in detail:

Here is the Schematic Symbol for a Schmitt Trigger which is an internally configured Op-Amp or comparator designed to perform the Schmitt trigger function:

The giveaway is the Hysteresis diagram in the centre of the symbol.  It denotes the switching of the output once a given threshold has been crossed.  The purpose of the device is to convert any input signal of whatever shape into a square wave output so that it can easily be counted or processed using a microcontroller or analogue to digital converter.

The difference between a Schmitt Trigger and a comparator is only slight.  The positive feedback is applied to the reference voltage and not the signal input.  The similarity between Schmitt Triggers and a comparator with hysteresis is that the output will come on and stay on until the input drops below a lower threshold.  Schmitt Triggers can again be inverting or non inverting.  Here is an inverting Schmitt Trigger circuit using a 741 Op-Amp:

If one were going to make this circuit up they will need:

1x 741 Op-Amp 
2x 1k resistors 
1x 100k resistor
1x 100R resistor - Optional
1x LED - Optional

The circuit works by taking a constantly changing input (a 3 V pk to pk sine wave will do) and converts it to a square wave signal by using positive feedback introduced to a known reference voltage.  The output will be high (LED On) when the voltage at the non inverting terminal is higher than the reference. The output will stay high until the input drops below the threshold voltage.

The mathematics to calculate the resistor values and voltage thresholds is complicated.  There are online calculators to do this for the aspiring engineer but for completeness here are comes the mathematics (* I still hate mathematics *). It is possible to draw a Hysteresis diagram for this circuit but I don't find them useful so I'm not going to bother for this circuit.

To make things easier for me I like to choose resistor values for R1, R2 and R3.  I then calculate the upper and lower threshold voltages and if they aren't what I want then I change resistor values.  

Lets set R1 to be 1k, R2 to be 1k and R3 to be 100k.  Here comes the mathematics:

First off lets calculate the total parallel resistance.  We will need this parameter later:

1 / Rp = 1 / R1 +1 / R2 + 1 / R3

1 / Rp = 1 / 1000 + 1 / 1000 + 1 / 100000

1 / Rp = 0.001 + 0.001 +  0.00001

Rp = 1 / 0.001 + 0.001 + 0.00001

Rp =  497.51243781 Ohms or 497.50 Ohms to two significant figures

Here is the formula for calculating the upper threshold voltage and lets set Vref and Vcc to the same value of 5V

Vut = ( Rp / R2 ) * Vref + ( Rp / R3) * Vcc

Lets insert the values and calculate the upper threshold voltage:

Vut = (497.5 / 1000) * 5 + ( 497.5 / 100000 ) * 5 

Vut = 2.4875 + 0.024875

Vut = 2.512375 Volts or 2.51 Volts to two significant figures

Lets now calculate the lower threshold voltage:

Vlt = ( Rp / R2 ) * Vref - ( Rp / R3) * Vcc

Vlt =  (497.5 / 1000) * 5 - ( 497.5 / 100000 ) * 5  

Vlt = 2.4875 - 0.024875

Vlt = 2.462625 Volts or 2.46 Volts to two significant figures

So we now know that with the resistor values chosen the Op-Amp output goes high when Vin is greater than 2.51V but doesn't go low until Vin is lower than 2.46V.  If those numbers don't suit then change the value for Rp by changing the resistor values chosen.  To be honest I use a circuit simulator or an online calculator for doing this work as it's quicker and I get answers immediately without any of the effort of performing calculations.  Here is a video of the circuit in action:

The Hyperphysics website provides a calculator for schmitt trigger circuits which I use when I need this kind of circuit.  I'm of the opinion that knowing how circuits work is good but knowing how to find the references to how circuits work is just as important.  It isn't knowing all the answers that makes someone intelligent its knowing where to find answers and being able to apply the knowledge *Really big grin*...

It is possible to make Schmitt trigger circuits using discrete transistors but I find it easier to use Op-Amps.  If a non inverting version is required then the circuit becomes much simpler.

That's all for now.  I hope this was useful to people.  If there are any other subjects or tutorials that you would like me to cover let me know in the comments.


No comments :

Post a Comment