Comparator model

How do you implement a comparator that can receive an analog input, and output a digital signal? I tried using the generic opAmp ,but he output me only 0 - even when I input him a constant 1V signal. Also the SCHMITT behaved the same.
Many thanks.

1 Like

Thank you! The problem was that I forgot to connect supplies to the comparator. :person_facepalming:

You can use a dependent voltage source with an expression comparing the two inputs. You don’t need power connections, and this works well for driving a high-side N-channel FET. The dependent sources, B & E devices were not intended for implementing logic and do not implement any temporal tolerance like in LTspice. Making the maximum timestep small helps at the expense of more steps in the simulation.

See the following video:
Qspice #1: Introduction and How to Create New Components (youtube.com)

You can also use the SCHMITT device, but you have to make power connections to it.