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 : CounterDown := (presetValue := 10);
    END_VAR
    VAR_TEMP
        total : INT;
    END_VAR

    // if the light is true, load the presetValue 10
    IF light THEN
        count(loadPreset := true); // set current value to 10
        count(loadPreset := false); // set loadPreset to false, otherwise the count will stay 10 regardless of other inputs
    END_IF;

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

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

END_PROGRAM