TestBit

PLCopen motion icon

 FunctionClosed A 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

Input

Data Type

Range

Unit

Default

Description

IN

ANY

 

 

 

8- to 64-bit integer register.

BIT

DINT

 

 

 

Bit number (0 = less significant bit).

Outputs

Output

Data Type

Range

Unit

Description

Q

BOOL

FALSE, TRUE

 

Bit value.

Remarks

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

FBD Language Example

FFLD Language Example

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

IL Language Example

Not available.

ST Language Example

Q := TESTBIT (IN, BIT);

See Also

SetBit