Issue a complex message
Messages can be triggered in 2 ways: simple and complex.
This Sample shows how a
complex message is triggered in the PLC. The Code used for a
complex message is bigger than for a simple message, but you will
have more configuration possibilities.
2 Messages will be created - a simple message and a
quit-requiring.
They will be shown with the TcEventbar.
- Create a new PLC-Project
- Chose 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. - Add following code to the project:
- (*Variable-declaration*)
VAR
bSetEvent1 : BOOL;
bSetEvent2 : BOOL;
bQuitEvent2 : BOOL;
event1: ADSLOGEVENT;
event2: ADSLOGEVENT;
CfgEvent1 : TcEvent;
CfgEvent2 : TcEvent;
END_VAR
- (*PLC
Code*)
(* Event 1 *)
CfgEvent1.Prio := 0;
CfgEvent1.bQuitRequired := FALSE;
CfgEvent1.Flags := TCEVENTFLAG_LOG OR TCEVENTFLAG_SRCID;
CfgEvent1.StreamType := TCEVENTSTREAM_SIMPLE;
CfgEvent1.ProgId := 'TcEventFormatter.TcXmlFormatter';
CfgEvent1.Id := 1; (* Meldung 1*)
CfgEvent1.SourceId := 17001; (* 17001: Achsregelung *)
CfgEvent1.Class := TCEVENTCLASS_MESSAGE;
(* Event 2 *)
CfgEvent2.Prio := 0;
CfgEvent2.bQuitRequired := TRUE;
CfgEvent2.Flags := TCEVENTFLAG_LOG OR TCEVENTFLAG_SRCID;
CfgEvent2.StreamType := TCEVENTSTREAM_SIMPLE;
CfgEvent2.ProgId := 'TcEventFormatter.TcXmlFormatter';
CfgEvent2.Id := 2; (* Meldung 2*)
CfgEvent2.SourceId := 17001; (* 17001: Achsregelung *)
CfgEvent2.Class := TCEVENTCLASS_ALARM;
event1(
NETID:= '',
PORT:= 110,
Event:= bSetEvent1,
EventConfigData:= CfgEvent1,
TMOUT:= t#10s);
event2(
NETID:= '',
PORT:= 110,
Event:= bSetEvent2,
EventQuit:= bQuitEvent2,
EventConfigData:= CfgEvent2,
TMOUT:= t#10s); - 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.
Cause no message texts are configured you will have a error in the fields Source and Message. - Toggling bSetEvent2 wont reset the message cause it is a quit-requiring message. It must be deleted before bSetEvent2 can be reset and bQuitEvent2 must be set.
- Continue with the message text configuration
Requirements
Language / IDE |
Source code |
---|---|
TwinCAT PLC (Structured Text) |