* SPICE netlist
C1 hp_signal phototransistor_voltage 470n
R1 hp_signal 0 3.3k
V1 phototransistor_v 0 5 AC 1
R5 0 phototransistor_voltage 100k
R2 Vout N001 10k
R3 N001 N003 10k
R6 Vref 0 10k
R7 Vref 5V 10k
V2 5V 0 5V
R9 N005 0 1k
R10 N005 5V 1k
XU1 N004 N005 0 5V Vout level1 Avol=1Meg GBW=10Meg Vos=0 En=0 Enk=0 In=0 Ink=0 Rin=500Meg ;pnba In+)In-)V+)V-)OUT
V3 N004 0 4
V4 N003 0 SINE(2.5 2.5 1k)
XU3 5V N002 5V 0 schmittIn level1 Avol=1Meg GBW=10Meg Vos=0 En=0 Enk=0 In=0 Ink=0 Rin=500Meg ;pnba In+)In-)V+)V-)OUT
R4 N002 0 1k
R8 schmittIn N002 52.5k
XU4 hp_signal followerOut 5V 0 followerOut level1 Avol=1Meg GBW=10Meg Vos=0 En=0 Enk=0 In=0 Ink=0 Rin=500Meg ;pnba In+)In-)V+)V-)OUT
XU2 N001 Vref 5V 0 Vout level1 Avol=1Meg GBW=10Meg Vos=0 En=0 Enk=0 In=0 Ink=0 Rin=500Meg ;pnba In+)In-)V+)V-)OUT
.tran 0.001

* LTspice schematic (.asc)
Version 4
SHEET 1 2576 816
WIRE 936 -392 872 -392
WIRE 1096 -392 1016 -392
WIRE -360 -280 -360 -328
WIRE 216 -280 136 -280
WIRE -392 -264 -472 -264
WIRE 328 -264 280 -264
WIRE 360 -264 328 -264
WIRE -296 -248 -328 -248
WIRE -232 -248 -296 -248
WIRE 216 -248 168 -248
WIRE -392 -232 -472 -232
WIRE -1192 -216 -1288 -216
WIRE -1160 -216 -1192 -216
WIRE -1000 -216 -1096 -216
WIRE -856 -216 -1000 -216
WIRE 248 -216 248 -232
WIRE 248 -216 232 -216
WIRE 776 -216 728 -216
WIRE 872 -216 872 -392
WIRE 872 -216 856 -216
WIRE 920 -216 872 -216
WIRE 1096 -200 1096 -392
WIRE 1096 -200 984 -200
WIRE 1176 -200 1096 -200
WIRE -1192 -184 -1192 -216
WIRE -1000 -184 -1000 -216
WIRE -360 -184 -360 -216
WIRE 920 -184 872 -184
WIRE 168 -168 168 -248
WIRE 232 -168 168 -168
WIRE 328 -168 328 -264
WIRE 328 -168 312 -168
WIRE 168 -152 168 -168
WIRE 952 -136 952 -168
WIRE -472 -120 -472 -232
WIRE -296 -120 -296 -248
WIRE -296 -120 -472 -120
WIRE -1000 -104 -1192 -104
WIRE 872 -104 872 -184
WIRE 872 -104 840 -104
WIRE -1192 -72 -1192 -104
WIRE 872 -72 872 -104
WIRE -376 136 -408 136
WIRE -264 136 -296 136
WIRE 1064 168 1064 136
WIRE 1032 184 968 184
WIRE 1288 200 1096 200
WIRE 1032 216 984 216
WIRE 1064 264 1064 232
WIRE 984 296 984 216
WIRE 984 296 952 296
WIRE 984 328 984 296
FLAG -856 -216 hp_signal
FLAG -408 136 0
FLAG -264 136 phototransistor_v
FLAG -1192 -72 0
FLAG -1288 -216 phototransistor_voltage
FLAG 872 8 0
FLAG 760 -104 5V
FLAG 664 168 0
FLAG 664 88 5V
FLAG 1176 -200 Vout
FLAG 984 408 0
FLAG 872 296 5V
FLAG 1064 264 0
FLAG 1064 136 5V
FLAG 1288 200 Vout
FLAG 888 184 0
FLAG 648 -216 0
FLAG 872 -104 Vref
FLAG 248 -296 0
FLAG 168 -72 0
FLAG 232 -216 5V
FLAG 360 -264 schmittIn
FLAG -360 -328 0
FLAG -360 -184 5V
FLAG -472 -264 hp_signal
FLAG -232 -248 followerOut
FLAG 952 -136 5V
FLAG 952 -232 0
FLAG 136 -280 5V
SYMBOL cap -1096 -232 R90
SYMATTR InstName C1
SYMATTR Value 470n
SYMBOL Res -1016 -200 R0
SYMATTR InstName R1
SYMATTR Value 3.3k
SYMBOL Voltage -280 136 R90
SYMATTR Value 5
SYMATTR InstName V1
SYMATTR Value2 AC 1
SYMBOL Res -1176 -88 R180
SYMATTR InstName R5
SYMATTR Value 100k
SYMBOL Res 1032 -408 R90
SYMATTR InstName R2
SYMATTR Value 10k
SYMBOL Res 872 -232 R90
SYMATTR InstName R3
SYMATTR Value 10k
SYMBOL Res 856 -88 R0
SYMATTR InstName R6
SYMATTR Value 10k
SYMBOL Res 856 -120 R90
SYMATTR InstName R7
SYMATTR Value 10k
SYMBOL Voltage 664 72 R0
SYMATTR InstName V2
SYMATTR Value 5V
SYMBOL Res 968 312 R0
SYMATTR InstName R9
SYMATTR Value 1k
SYMBOL Res 968 280 R90
SYMATTR InstName R10
SYMATTR Value 1k
SYMBOL OpAmps/UniversalOpAmp 1064 200 M180
SYMATTR InstName U1
SYMBOL Voltage 984 184 R90
SYMATTR InstName V3
SYMATTR Value 4
SYMBOL Voltage 744 -216 R90
SYMATTR InstName V4
SYMATTR Value SINE(2.5 2.5 1k)
SYMBOL OpAmps/UniversalOpAmp 248 -264 M180
SYMATTR InstName U3
SYMBOL Res 152 -168 R0
SYMATTR InstName R4
SYMATTR Value 1k
SYMBOL Res 328 -184 R90
SYMATTR InstName R8
SYMATTR Value 52.5k
SYMBOL OpAmps/UniversalOpAmp -360 -248 M180
SYMATTR InstName U4
SYMBOL OpAmps\\UniversalOpAmp 952 -200 M180
SYMATTR InstName U2