- Create a "Standard project" and select CODESYS Control Win V3 as the device.
- Define the target system by means of the Network scan.
- Open the Library Manager and add the following libraries:
Create a persistent variable named PersistentVars.
Adapt PersistentVars as follows:
Adapt the POU PLC_PRG as follows:
- Create a new function named taskev_StopDone with the return type DWORD.
Then adapt the function as follows:
- Open the tab in the task configuration:
Create a new event of type StopDone and assign the function taskev_StopDone to it.
Start the project and set the variable xReset to TRUE in order to index it.
The variable PersistantVars.udiCnt is incremented from the application with each restart.