TESTBITPLCopen motion icon

FunctionClosedA function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. - Test a bit of an integer register.

Inputs

IN : ANY    8 to 64 bit integer register
BIT : DINT  Bit number (0 = less significant bit)

Outputs

Q : BOOL    Bit value

Remarks

Types LINT, REAL, LREAL, TIME and STRING are not supported for IN and Q. IN and Q must have the same type. In case of invalid arguments (bad bit number or invalid input type) the function returns FALSE.

In FFLD language, the operation is executed only if the input rung (EN) is TRUE. The output rung is the output of the function.

ST Language

Q := TESTBIT (IN, BIT);

FBD Language

FFLD Language

(* The function is executed only if EN is TRUE *)

IL Language

Not available

See also

SETBIT