Hi,
Here's another aproach
Code:
ON CON 1
OFF CON 0
Hysteresis CON 5
Setpoint CON 120

Solenoid VAR PortB.0

InputSignal VAR BYTE

' With the above value we will turn the output ON when the SetPoint reaches 125 and OFF when it reaches 115.

If (Solenoid = OFF) AND (InputSignal >= (Setpoint + Hysteresis)) THEN
  Solenoid = ON
ENDIF

IF (Solenoid = ON) AND (InputSignal <= (Setpoint - Hysteresis)) THEN
  Solenoid = OFF
ENDIF
/Henrik.