{"id":"iec-limit","model_id":"LIMIT","name":"CODESYS LIMIT","summary":"LIMIT is an IEC selection operator in the CODESYS development system that limits a value to a range. It is written as OUT := LIMIT(Min, IN, Max) and is equivalent to OUT := MIN(MAX(IN, Min), Max), so a value above Max returns Max and a value below Min returns Min. The source gives the example Var1 := LIMIT(30,90,80); which returns 80.","study_notes":["LIMIT is described as an IEC selection operator and is used for limiting.","The call form is OUT := LIMIT(Min, IN, Max).","It is equivalent to OUT := MIN(MAX(IN, Min), Max).","Max is the upper limit of the result; if IN is above Max, LIMIT yields Max.","Min is the lower limit of the result; if IN is below Min, the result is Min.","Permitted data types for IN and OUT: all.","Example: Var1 := LIMIT(30,90,80); gives the result 80 in Var1."],"safety_notes":[],"sources":[{"url":"https://infosys.beckhoff.com/content/1033/tc3_plc_intro/2528972171.html","title":"Beckhoff Information System","accessed":"2026-10-26"},{"url":"https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_operator_limit.html","title":"CODESYS Group","accessed":"2026-10-26"}],"verification":{"status":"source_checked","checked_at":"2026-10-26","values":13,"method":"llm_source_check"},"updated_at":"2026-10-26","type":"instruction","spec":{"language":"structured_text","code":"LIMIT","group":"selection operator","syntax":"OUT := LIMIT(Min, IN, Max)","parameters":[{"name":"Min","description":"Lower limit for the result."},{"name":"IN","data_type":"all","description":"Value to be limited."},{"name":"Max","description":"Upper limit for the result."},{"name":"OUT","data_type":"all","description":"Result of the limiting operation."}],"dialect":"CODESYS","related":[],"standards":[]},"url":"https://machineschema.com/instruction/iec-limit","license":"https://creativecommons.org/licenses/by/4.0/"}