1. Upper and lower limit control LIMIT/LIMITD/LIMITF
1. Upper and lower limit control LIMIT/LIMITD/LIMITF
1.1. Instruction Description
The limit control command specifies whether the input value (IN3) of a single character is within the range of the upper and lower limit values specified by (IN1) and (IN2), in order to control its storage in (OUT).
The upper and lower limit control of doublet and floating-point correspond to the types of doublet and floating-point, respectively.
When IN3 (input value) is less than IN1 (lower limit value), OUT (output value) is set to IN1 (lower limit value).
When IN3 (input value)>IN2 (upper limit value), OUT (output value) is set to IN2 (upper limit value).
When IN1 (lower limit)&# 60= IN3 (input value)&# 60= When IN2 (upper limit value) is reached, OUT (output value) is set to IN3 (input value).
图1 Upper and Lower Limit Control
When controlling only through the upper limit value, set - Inf in IN1 (lower limit value).
When controlling only through the lower limit value, set Inf in IN2 (upper limit value).
1.2. The valid operands of the instruction
1.2.1. Limit control for single word upper and lower limits (LIMIT)
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| MIN | 16 bit integer | D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) | minimum |
| MAX | 16 bit integer | D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) | maximum |
| VAL | 16 bit integer | D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) | current value |
| OUT | 16 bit integer | D/CV/TV/AO/V/Z, bit composite word (Y/M/C/T/S), local variable (LW) | output |
1.2.2. Double word upper and lower limit control(LIMITD)
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| MIN | 32-bit integer | D/CV/K/H/FD, bit composite word (X/Y/M/C/T/S), local variable (LD) | minimum |
| MAX | 32-bit integer | D/CV/K/H/FD, bit composite word (X/Y/M/C/T/S), local variable (LD) | maximum |
| VAL | 32-bit integer | D/CV/K/H/FD, bit composite word (X/Y/M/C/T/S), local variable (LD) | current value |
| OUT | 32-bit integer | D/CV, bit composite word (Y/M/C/T/S), local variable (LD) | output |
1.2.3. Floating upper and lower limit control (LIMITF)
| Input/Output | Data Type | operand | Description |
|---|---|---|---|
| MIN | 32-bit real number | D/K/FD, local variable (LF) | minimum |
| MAX | 32-bit real number | D/K/FD, local variable (LF) | maximum |
| VAL | 32-bit real number | D/K/FD, local variable (LF) | current value |
| OUT | 32-bit real number | D, local variable (LF) | output |
1.3. Example
Command table:
NETWORK 000
LD X000
BIN K16X20 D0 // Convert the BCD values of X020~X037 to integers and store them in D0
LIMIT K500 K100 D0 D1//Limit control D0 and output it to D1
图2 LIMIT
1.4. Action
D0 < 500时,D1=500。
500 <= D0 <= 5000时,D1=value of D0。
D0 > 5000,D1=5000。
图3 Action