Skip to main content
3 of 3
added 1438 characters in body
Spehro 'speff' Pefhany
  • 422.4k
  • 23
  • 352
  • 949

Here is my simulation in LTspice, seems to work just fine:

enter image description here

The switching thresholds are almost exactly at the expected 3.5V & 1.5V, when the input is as slow as I've chosen here.

Using an op-amp as a comparator is not always the best approach (but that's not your problem here). .asc file below.

Version 4
SHEET 1 880 680
WIRE 192 48 128 48
WIRE 304 48 240 48
WIRE 128 64 128 48
WIRE 240 128 240 48
WIRE 192 144 192 48
WIRE 208 144 192 144
WIRE 368 160 272 160
WIRE 384 160 368 160
WIRE 208 176 192 176
WIRE 80 240 16 240
WIRE 192 240 192 176
WIRE 192 240 160 240
WIRE 192 272 192 240
WIRE 384 272 384 160
WIRE 384 272 272 272
FLAG 240 192 0
FLAG 304 80 0
FLAG 128 96 0
FLAG 16 272 0
FLAG 368 160 OUTPUT
FLAG 16 240 INPUT
SYMBOL Opamps\\AD8541 240 96 R0
SYMATTR InstName U1
SYMBOL MiniSyms4\\voltage- 304 64 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V1
SYMATTR Value 5
SYMBOL res 288 256 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R1
SYMATTR Value 10K
SYMBOL MiniSyms4\\voltage- 128 80 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V2
SYMATTR Value 2.5
SYMBOL res 176 224 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R2
SYMATTR Value 4K
SYMBOL MiniSyms4\\voltage- 16 256 R0
WINDOW 3 -59 43 Left 0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V3
SYMATTR Value PULSE(0 5 10ns 100ms 100ms 10ns 200m)
TEXT -44 322 Left 2 !.tran 200ms
Spehro 'speff' Pefhany
  • 422.4k
  • 23
  • 352
  • 949