Sometimes a piece counter with an automatic restart is required. To achieve this we use the system variables that returns the internal clock data (in Okuma is VDTIM).
It is important to remark the variable use to store the part number must be keep free, and not be used by any other program.
In our example we will use the variable VC10. The counter format is YYMMXXX, for instance 2303010 represents the 10th part produced in march 2023.
This counter keeps storing the part number and each time compares the month and year to be the same. When a different year or month is detected, the counter is restarted. Example, if parts from march 2023 are being counted, the string that represents the year-month is 2303, while the strins keeps unchanged the counter will be increased, otherwise, the program will detect the change and the counter will be restarted. For example if it changes to april the string will change to 2304
In Okuma, it is necessary to call the function VDTIM[1] (year) to refresh the control internal clock.Example: