SetBit

PLCopen motion icon

 Function - Set a bit in 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).

VAL

BOOL

FALSE, TRUE

 

 

Bit value to apply.

Outputs

Output

Data Type

Range

Unit

Description

Q

ANY

 

 

Modified register.

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 the value of IN without modification.

FBD Language Example

FFLD Language Example

  • In the FFLD Language, the conversion is executed only if the input rung (EN) is TRUE.
    • The output rung (ENO) keeps the same value as the input rung.
  • The function is executed only if EN is TRUE.
  • ENO keeps the same value as EN.

IL Language Example

Not available.

ST Language Example

Q := SETBIT (IN, BIT, VAL);

See Also

TestBit