Example - Manual - SIMATIC AX - System Counters Library - System.Counters,library

System.Counters library

Portfolio
SIMATIC AX
Product
SIMATIC AX
Software version
8.0.8
Edition
08/2025
Language
English (original)
Package Name
@ax/system-counters
USING System.Counters;

PROGRAM SampleProgram
    VAR_EXTERNAL
        pushButton : BOOL;
        light : BOOL;
    END_VAR
    VAR
        count : CounterUp := (presetValue := 10);
    END_VAR
    VAR_TEMP
        total : INT;
    END_VAR

    // increment counter by 1 for every push of the button
    count(up := pushButton);

    // pushButton created a rising edge 10 times
    IF count.presetReached THEN
        light := true;
    END_IF;

END_PROGRAM