Type
| Function |
Description
| Inverts a bit in the bit string connected to the IN input and returns the resulting bit string. The bit to be inverted is selected with the BIT input. The function can operate on various input data types. |
Notes |
- The output must have the same length or must be larger than the input.
- The value applied to the BIT input must be greater than or equal to 0 or less than the length of the IN bit string.
- The OUT value remains unchanged and no error is generated in the MESSAGES window if the above conditions are not met.
|
Parameters
| Inputs
IN
Data type: | ANY_BIT |
Description: | Input bit string. |
BIT
Data type: | ANY_INT |
Description: | Number of the bit to be inverted. |
Output
OUT
Data type: | ANY_BIT |
Description: | Output bit string. |
|
Error behavior
| Error behavior
The following table shows the errors which may occur while executing the function and the value returned by the function in the corresponding error case.
Error case | Output value |
BIT < 0 | Last valid value is kept |
BIT >= bitlength(IN)(bitlength(IN) = length of the IN bit string) | Last valid value is kept |
|
Additional information
| EN/ENO behavior
The POU is only executed if TRUE is applied to the EN input. If EN = FALSE, the POU is not executed and ENO = FALSE indicates the inactivity.
If any of the errors listed under "Error behavior" occurs while executing the function, ENO is set to FALSE.
|
Example
| Example in ST
MyByteVar := INVERT_BIT(BYTE#2#10011001,USINT#5); (* stores 10111001 in MyByteVar *)
|