Thanks picster.

What I finally did is this:

Code:
 if ADvalue < upper-hyst then
            relay.0=1
        elseif ADvalue > upper+hyst then
            relay.0=0
        endif
The user through menu, can set the hyst (hysteresis) window.

Also the update of the relays is not done immediately but every xx seconds also user defined.

Both these did the trick.

Ioannis