I'm trying to simulate a comparator in LTSpice. I'm actually trying to simulate the comparator in an LPC15xx microcontroller. It has programmable hysteresis of 5mV, 10mV or 20mV.
Obviously, I could make the hysteresis by a feedback resistor from output to non-inverting input, but the amount of hysteresis then changes when I vary any of the other resistor values.
I'm thinking that I could put a SPICE Voltage source in series with one of the inputs, then use the state of the output to toggle the value of the voltage source between two different values, but I don't know how to do that. Could someone please help me out?
Obviously, I could make the hysteresis by a feedback resistor from output to non-inverting input, but the amount of hysteresis then changes when I vary any of the other resistor values.
I'm thinking that I could put a SPICE Voltage source in series with one of the inputs, then use the state of the output to toggle the value of the voltage source between two different values, but I don't know how to do that. Could someone please help me out?