I'm trying to simulate the circuit posted [here](https://electronics.stackexchange.com/questions/163253/sine-wave-to-square-wave-schmitt-trigger), which looks like this:

[![enter image description here](https://i.stack.imgur.com/6f3Xw.png)](https://i.stack.imgur.com/6f3Xw.png)

I'm running a transient analysis and have the following settings:

[![enter image description here](https://i.stack.imgur.com/z565q.png)](https://i.stack.imgur.com/z565q.png)

I expected to get the output as a square wave, but I'm getting this instead:

[![enter image description here](https://i.stack.imgur.com/DFsKU.png)](https://i.stack.imgur.com/DFsKU.png)

Does anyone know why I might be getting a zigzag wave rather than a square wave?

Here is the definition of LM339 used:

[![enter image description here](https://i.stack.imgur.com/GQBPX.png)](https://i.stack.imgur.com/GQBPX.png)

EDIT:

If I use a time step of 0.055ms and the stop time to just 5ms, I get the following:

[![enter image description here](https://i.stack.imgur.com/dLW0V.png)](https://i.stack.imgur.com/dLW0V.png)

which is still not a square wave.

The amplitude of the input signal is 5V.