Bit Set, Bit Clear, Bit Test in Advanced Ladder

See also: Bitwise in Advanced Ladder

See also: Project Toolbox for Advanced Ladder

 

Topic Menu

Bit Set

The Bit Set function sets a single bit high in a long string of bits. The string of bits may be many Words in length.

Bit Set Parameters

  • IN: The In parameter is a variable that will be the first Word in the string of bits this function will operate upon. For Variable Based editing, this must be the first element of an array. See Move in Advanced Ladder for more details.

  • LEN: The number of Words in the string of bits from 1 to 256 (for a maximum total of 4096 bits). Can be either a variable or static value.

  • BIT: The number of the bit to set, from 1 to 4096. Should not exceed a value of LEN * 16

Power Flow

The Bit Set function executes immediately and entirely as soon as it receives power from the incoming rung. The bit being set is recognized by any remaining logic in the scan as being set. Any physical output affected will take effect at the next output stage of the scan. The Bit Set function will execute on every scan that it has received power from the incoming rung. The Bit Set function will pass power to the next function on the rung if the BIT parameter does not exceed the LEN parameter * 16.

There is no need for any further functions to exist to the right of the Bit Set function on the rung. The function’s action is considered an output.

Bit Set Example

 

Word 3

Word 2

Word 1

IN

1110 0000 0000 0111

1100 0000 0000 0000

1111 1111 0000 0000

LEN

3

BIT

21

Resulting IN

1110 0000 0000 0111

1100 0000 0001 0000

1111 1111 0000 0000

Power Flow

True

Return to the Top: Bit Set, Bit Clear, Bit Test in Advanced Ladder

Bit Clear

The Bit Clear function clears, or resets, a single bit low in a long string of bits. The string of bits may be many Words in length.

Bit Clear Parameters

  • IN: The In parameter is a variable that will be the first Word in the string of bits this function will operate upon. For Variable Based editing, this must be the first element of an array. See Move in Advanced Ladder for more details.

  • LEN: The number of Words in the string of bits from 1 to 256 (for a maximum total of 4096 bits). Can be either a variable or static value.

  • BIT: The number of the bit to clear, from 1 to 4096. Should not exceed a value of LEN * 16

Power Flow

  • The Bit Clear function executes immediately and entirely as soon as it receives power from the incoming rung. The bit being reset is recognized by any remaining logic in the scan as being reset. Any physical output affected will take effect at the next output stage of the scan.

  • The Bit Clear function will execute on every scan that it has received power from the incoming rung.

  • The Bit Clear function will pass power to the next function on the rung if the BIT parameter does not exceed the LEN parameter * 16.

  • There is no need for any further functions to exist to the right of the Bit Clear function on the rung. The function’s action is considered an output.

Bit Clear Example

 

Word 3

Word 2

Word 1

IN

1110 0000 0000 0111

1100 0000 0000 0000

1111 1111 0000 0000

LEN

3

BIT

35

Resulting IN

1110 0000 0000 0011

1100 0000 0000 0000

1111 1111 0000 0000

Power Flow

True

Return to the Top: Bit Set, Bit Clear, Bit Test in Advanced Ladder

Bit Test

The Bit Test function tests the state of a single bit in a long string of bits. The string of bits may be many Words in length.

Bit Test Parameters

  • IN: The In parameter is a variable that will be the first Word in the string of bits this function will operate upon. For Variable Based editing, this must be the first element of an array. See Move in Advanced Ladder for more details.

  • LEN: The number of Words in the string of bits from 1 to 256 (for a maximum total of 4096 bits). Can be either a variable or static value.

  • BIT: The number of the bit to test, from 1 to 4096. Should not exceed a value of LEN * 16

Power Flow

  • The Bit test function executes immediately and entirely as soon as it receives power from the incoming rung.

  • The Bit Test function will execute on every scan that it has received power from the incoming rung.

  • The Bit Test function will pass power to the next function on the rung if the bit being tested is TRUE and the BIT parameter does not exceed the LEN parameter * 16.

  • The Bit Test function requires an output coil or further logic to the right of it on the rung. This output or logic will receive power if the bit tested is TRUE and will not receive power if the bit tested is FALSE.

Bit Test Example 1

 

Word 3

Word 2

Word 1

IN

1110 0000 0000 0111

1100 0000 0000 0000

1111 1111 0000 0000

LEN

3

BIT

31

Power Flow

True

Bit Test Example 2

 

Word 3

Word 2

Word 1

IN

1110 0000 0000 0111

1100 0000 0000 0000

1111 1111 0000 0000

LEN

3

BIT

8

Power Flow

FALSE

Return to the Top: Bit Set, Bit Clear, Bit Test in Advanced Ladder