2
\$\begingroup\$

I am trying to build a Schmitt trigger that would allow adjusting High and Low threshold values with a microcontroller.

schematic

simulate this circuit – Schematic created using CircuitLab

I could replace R1-R2 with a DAC, but how do I adjust the feedback resistor R3? Is the trigger going to work properly if I replace R3 with a digital potentiometer?

\$\endgroup\$
5
  • \$\begingroup\$ why not use a dual comparator setup with two DAC/digital pot based setpoints (maybe DAC through a latched output analog multiplexer to get more set point channels) to get the hysteresis and lots of flexibility \$\endgroup\$
    – KyranF
    Commented Nov 30, 2015 at 17:55
  • \$\begingroup\$ ah nevermind, I was thinking one step too far ahead, each of the comparators I mentioned basically need to be schmitt triggers anyway. don't mind me.. \$\endgroup\$
    – KyranF
    Commented Nov 30, 2015 at 17:57
  • 2
    \$\begingroup\$ Hmm. If you're already using an MCU, can you just read the input signal with an ADC and produce the output with an MCU pin? Then, the threshold values could just be numbers in your code. \$\endgroup\$
    – Greg d'Eon
    Commented Nov 30, 2015 at 17:57
  • \$\begingroup\$ @Gregd'Eon there is merit in that, but offloading this sort of closed loop control onto hardware circuitry is better in the long run. just setting setpoints is an easy and low speed task, compared with fully monitoring an analog signal and being able to respond correctly every time \$\endgroup\$
    – KyranF
    Commented Nov 30, 2015 at 17:59
  • 1
    \$\begingroup\$ @Gregd'Eon - using an ADC would be the best option, unfortunately I'm dealing with relatively fast signals (~500kHz). This would require sampling rate of at least 2.5MSPs to get adequate results. Since all I need is to count pulses, I decided to go with hardware implementation. \$\endgroup\$
    – Ashton H.
    Commented Nov 30, 2015 at 18:05

2 Answers 2

3
\$\begingroup\$

Completely replacing R1-R2 with a DAC may give you mixed results because the circuit saves a part by relying on the voltage divider's parallel impedance R1||R2. You'll need to ensure that the DAC has the same output impedance as seen from R3.

schematic

simulate this circuit – Schematic created using CircuitLab

That will adjust the threshold while keeping the hysteresis constant. To adjust the hysteresis, you can now replace R1||R2 and R3 with a digipot.

\$\endgroup\$
2
  • \$\begingroup\$ Would it work if I omit the DAC and simply connect a digipot R1||R2 between Vcc and R3? \$\endgroup\$
    – Ashton H.
    Commented Nov 30, 2015 at 18:09
  • \$\begingroup\$ @AshtonH. Maybe. I assume you're turning the fixed divider into a pot? The hysteresis will depend on how close you are to a rail because the parallel impedance changes. (equivalent of R1||R2) \$\endgroup\$
    – AaronD
    Commented Nov 30, 2015 at 19:26
6
\$\begingroup\$

This is a real proper way of doing it for the pedants amongst us (and that usually includes me).

Use two comparators (one for the high level threshold and one for the low level threshold). Use two DACs (or digipots) to set the thresholds for each comparator. Feed the input signal into both comparators.

The two comparator outputs can be used to set a flip flop and reset a flip flop respectively.

\$\endgroup\$
6
  • \$\begingroup\$ I was kind of hinting at that in the question's comments, but this is way better, +1 \$\endgroup\$
    – KyranF
    Commented Nov 30, 2015 at 22:35
  • \$\begingroup\$ @KyranF so you did - great minds think alike (or is that fools?). I've recently had to implement something like this at work so it's fresh. You should have made an answer out of it (too late muhuhahaha). \$\endgroup\$
    – Andy aka
    Commented Nov 30, 2015 at 22:38
  • \$\begingroup\$ The idea of two comparators driving a flip-flop isn't that new - actually it's implemented in the well-known NE555 timer chip. Using THR and TRIG as threshold inputs (driven by DAC outputs) and forcing the input voltage into CONT ("forcing" means working agains the resistor VCC/CONT) should solve the problem at hand. Remember that TRIG is compared to CONT/2, while THR is compared to CONT. \$\endgroup\$ Commented Nov 30, 2015 at 22:54
  • \$\begingroup\$ @MichaelKarcher yes, absolutely correct but you don't have such simple control of the individual thresholds but, point taken. \$\endgroup\$
    – Andy aka
    Commented Nov 30, 2015 at 22:55
  • 1
    \$\begingroup\$ There is no reliance on the output level for determining absolute threshold levels. A single opamp creates two threshold levels by involving positive feedback and therefore the output level and power voltage level are factors that affect thresholds. \$\endgroup\$
    – Andy aka
    Commented Dec 1, 2015 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.