Issue a simple message
Messages can be triggered in 2 ways: simple and complex.
This Sample shows how a
simple message is triggered in the PLC. The Code used for a simple
message is shorter than for a complex message, but you will have
less configuration possibilities.
- Create a new PLC-Project.
- Choose PC (i386) as Target System
- Keep the standard task-settings.
- Create a new ST-program.
- Open the menu Window
-> Library Manager and add TcSystem.lib to the
project.
Now you have access to the ADSLOGEVENT function block. - Use the TcEventConfigurator to create a quit-requiring message with the SourceID 17001 and EventID 1
- Add following code to the project:
- (*Variable-declaration*)
VAR
event : FB_SimpleAdsLogEvent;
bEvent : BOOL;
bQuitEvt : BOOL;
END_VAR
- (*PLC
Code*)
Event( SourceID := 17001,
EventID := 1,
bSetEvent := bEvent,
bQuit := bQuitEvt); - Start the PLC Program.
- Start the TcEventbar ('TwinCAT/Eventlogger' directory).
- By toggling bSetEvent1 the message will be triggered. Rising edge starts the message, otherwise it will be reset.
- Toggling bSetEvent won't reset the message cause it is a quit-requiring message. It must be deleted before bSetEvent can be reset and bQuitEvent must be set.
Requirements
Language / IDE |
Source code |
---|---|
TwinCAT PLC (Structured Text) |