BIT_TGL block

Short summary

Name

BIT_TGL

→POU type

→function

Category

IEC-block, BitstringEnh

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/add.svg not defined in IEC-standard

Graphical interface

images/download/thumbnails/414780737/BIT_TGL-version-1-modificationdate-1534860650399-api-v2.png

Available since

  • version 1.23.0 (for logi.CAD 3) – initial variant: ANY_BIT for input IN and return value

  • version 1.35.0 (for logi.CAD 3) – enhancement: ANY_INT for input IN and return value

Functionality

The block returns the result of a bitwise toggling .

At input IN, enter a value (the value at input IN is unchanged when the toggling takes place). At input N, enter the bit number (0-based) that should be toggled.

Inputs, return value


Identifier

→Data type

Description

Inputs:

IN

BOOL, BYTE, WORD, DWORD or LWORD(corresponds to →generic data type ANY_BIT)
and
USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_INT)

input value

N

USINT

the bit number (0-based) to toggle

Return value:

BOOL, BYTE, WORD, DWORD or LWORD(corresponds to →generic data type ANY_BIT)
and
USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_INT)


Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Example for usage within ST-editor

PROGRAM Test
VAR
result1 : WORD;
result2 : LWORD;
END_VAR
result1 := BIT_TGL(IN := WORD#16#8003, N := 1); (* The variable 'result1' evaluates to 'WORD#16#8001'. *)
result2 := BIT_TGL(IN := LWORD#16#0000000000000003, N := 63); (* The variable 'result2' evaluates to 'LWORD#16#8000000000000003'. *)
END_PROGRAM

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.