Chapter 4. Ladder Diagram (LD) Programming
GFK-2950C February 2018 69
4.2.2 Bit Position
The Bit Position function locates a bit set to 1 in a bit string.
Each scan that power is received, the function scans the bit string starting at IN. When the function
stops scanning, either a bit equal to 1 has been found or the entire length of the string has been
scanned.
POS is set to the position within the bit string of the first non-zero bit; POS is set to zero if no non-
zero bit is found.
A string length of 1 to 256 WORDs or DWORDs can be selected. The function passes power flow to
the right whenever it receives power.
Operands of Bit Position
The number of WORDs or DWORDs in the bit
string. 1 Length 256.
All. Constants may only be
used when Length is 1.
Energized if a bit set to 1 is found
An unsigned integer giving the position of the first
nonzero bit found, or zero if no non-zero bit is
found
All except constants and
variables located in %S - %SC
Examples
When V_I00001 is set, the bit string starting at V_M00001 is searched until a bit equal to 1 is found,
or 6 words have been searched. Coil V_Q00001 is turned on. If a bit equal to 1 is found, its location
within the bit string is written to V_AQ0001 and V_Q00002 is turned on. For example, if V_00001 is
set, bit V_M00001 is 0, and bit V_M0002 is 1, the value written to V_AQ0001 is 2.