- 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:
Creating the EventHandler
- Create a new FB named FB_EventHandler and implement the interface CmpEventMgr.ICmpEventCallback.
The method EventCallback is created automatically with the FB:
Add the following variables to the FB_EventHandler:
Adapt the method EventCallback as follows:
Add the method FB_Init to the FB_EventHandler and adapt the code as follows:
Add the method FB_Exit to the FB_EventHandler and adapt the code as follows:
Instantiating the event handler and test the functionality
Adapt the POU PLC_PRG as follows:
- Download the project to the controller and start it.
When logging in/out and starting the project, the counters are incremented.