SetBit

PLCopen motion icon

 Function - Set a bit in an integer register.

  • 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.

Inputs

Input

Data Type

See Data Types.

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

See Data Types.

Range

Unit

Description

Q

ANY

 

 

Modified register.

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