include "LIB" SP, ZONE = 30, 0.5 -- °C PV_REG, OUT_REG = 21, 50 -- id of the registers with process value and output function tempControl(sp, pv, zone, out, inZone) -- on - off function --- local inZone_ = (pv >= (sp - zone)) and (pv <= sp) and TRUE(inZone) if (pv >= sp) then SET(inZone) elseif (pv < (sp - zone) ) then RESET(inZone) end DEBUG("sp pv " .. sp .. ' ' .. pv) U(out, not (pv >= sp or inZone_) ) end function main (userId) ------- Main body --------------------- tempControl(SP, R(PV_REG), ZONE, OUT_REG, "inZoneControl") end