32.16.4.4 System Variables Indicating Execution Results - BCNT/BCNTP

Program Example

BCNT

Counts the number of bits that are ON, and saves the number in an integer variable.

  1. When the positive transition instruction turns ON, the BCNT instruction will be executed. When the BCNT instruction is executed, the ON bits in the value 10 (binary 1010) are counted and the result of 2 is saved in the result data. The result data is configured in D1.
    When using a normally-open instruction, as long as the instruction variable is ON, the BCNT instruction is always executed.

BCNTP

  1. BCNTP and BCNT instructions differ in when they run. In the BCNTP instruction, when using a normally open instruction, only the upward transition is detected and the BCNT instruction is executed. Even if the normally open instruction variable remains ON, the BCNTP instruction is executed only for one scan.