You are on page 1of 10

Event Table Quick Start Guide

**This was created by a Beckhoff Support Engineer. This is not official Beckhoff documentation**

Link to the Infosys.beckhoff.com Event Table resource page:


https://infosys.beckhoff.com/content/1033/tc3_plc_intro/27021601288389131.html?id=5447827414708620738

In this guide, we will first setup the PLC project. Then we will setup the events.

1. To start, we open up a new TwinCAT XAE project and add a new PLC project to the PLC node.
2. Right click on VISU and add a new visualization file.
3. Select the checkbox for symbol access:

4. We then need to add the library for the event table, which is located in an unusual spot.
a. Right click on your Project node and go to properties.
b. Then go to the Visualization profile and check the box for an available EventTable.
i. If you see multiple, choose the newest.

5. Once that library has been added to your References, you will then be able to add the table to
your visualization from the Toolbox > Special Controls > Event Table and can be dragged and
dropped:
6. Now we need to add the library for the function blocks.
a. Right click on your References and add the Tc2_Utilites library.

7. Navigate to your MAIN program; we will be adding some demo code for triggering a test event.
a. There are two types of function blocks we will be using…
b. FB_AdsReadEvents
https://infosys.beckhoff.com/content/1033/tc3_plc_intro/9007202778935947.html?id=
387429214125873882
i. To be called cyclically, this will monitor for an event trigger and facilitates with
delivering the message to the event table.
c. FB_SimpleAdsLogEvent
https://infosys.beckhoff.com/content/1033/tcplclib_tc2_system/54043196325365643.h
tml?id=735191998087452643
i. One block per alarm, to match the event ID and Source ID. Will take a bool
trigger to raise or lower event message to table.

8. Below I have some starter code for raising a single event for demo.
a. Notice how the Source ID and Event ID are both 1, which will be referenced again later.
b. Below is a picture of the MAIN program with code sample included for easy copy/paste.
c. Copy and Paste the code below, into your MAIN program.
DECLARATION:
PROGRAM MAIN
VAR
fbAdsReadEvents : FB_AdsReadEvents;
fbSimpleAdsLogEvent1 : FB_SimpleAdsLogEvent;
bReadEvents : BOOL := TRUE;
bEvent1 : BOOL;
END_VAR

IMPLEMENTATION:
fbAdsReadEvents(sNetId:= '',
bReadEvents:= bReadEvents,
nLanguageId:= 1033,
eDateAndTimeFormat:= E_DateAndTimeFormat.en_US,
tRefreshTime:= T#1S,
tTimeout:= T#5S,
aEvents=> ,
nNumberOfEvents=> ,
bBusy=> ,
bDone=> ,
bError=> ,
nErrId=> );

fbSimpleAdsLogEvent1( SourceID:= 1,
EventID:= 1,
bSetEvent:= bEvent1,
bQuit:= TRUE,
ErrId=> ,
Error=> );
9. Now we can navigate to our Visualization and its toolbox. The Event Table is listed under Special
Controls.
a. Drag and drop it into your visualization.

10. The Event table only requires one property (Event Data Array).
a. A link to the array in the AdsReadEvents function block.
b. See the images below for an example of this property and its link to the AdsReadEvents
array.

c. This is what that linking looks like in the input assistant.


11. Next, you will want to add a button that will be tied to the Boolean trigger for the test event.
a. This can also be done in the PLC code, we simply want something that will trigger the
alarm and a button is an easy way to demo that.
b. Add the MAIN.bEvent1 Boolean to the toggle property for the button.

The Visual studio project is now ready but we still need to configure our events in the Event
Configurator before the table will actually work.
12. First, we need to make a new .ecpx file with the event configurator.
a. Open a folder and navigate to
C:\TwinCAT\3.1\Components\TcEventLogger\EventConfigurator
b. Double click the TcEventConfigurator.exe program.
c. A wizard will start, guiding you through setting up a new event configuration. Click next
through the menus keeping everything default except when you get to the language
screen.
d. Add the 1033 English language and delete the 1031 (unless you want to keep the
German option). Then keep pressing next.

e. When prompted, add a title for your event with a message for the HMI:

f. Click finish.

13. Now you will get something that looks like the image below.
a. Notice the options to set the class, alter message text, alter event and source IDs. None
of this needs to be altered right now (or at least the source ID and Event ID should be
kept at 1 until the demo is over).
b. Another side note: The wizard is helpful for the initial setup but does not need to be
used every time. You can also open the event configuration file once it has been saved,
for future configuring.
c. Notice how the Source ID and Event ID are both 1? That is what we reference in our PLC
code via the FB_SimpleAdsLogEvent block. This tells the block which event to trigger.
14. Now do a File > Save As and save it in the TwinCAT\3.1 folder:
a. The reason why we save it here is for conformity. Since all PLC runtimes will have the
C:\TwinCAT\3.1 folder, it is recommended then to choose this file location to save too.

15. Click the File dropdown and select Activate Current Config
a. The configurator prompts you to activate the configuration after a save. If you were
prompted to activate and said yes, then this step can be skipped.
b. Side note: this does not activate the TwinCAT configuration but instead it activates the
Event Configuration.
16. You can now minimize or close the Event Configurator.

17. Now open a windows folder and navigate to this path: C:\TwinCAT\3.1\Target\Resource
a. Open the TcEventSourceLocation.xml file
b. We need to add our file path to the event configuration file and our configured source
IDs.
c. Scroll down to the bottom of the file and just before the closing
</TcEventSourceLocation> tag, add the text that is being displayed in the image below.
d. This tells the event logger where our event configuration file is located and what Source
IDs we have configured.

<Location user="-1">
<Path>C:\TwinCAT\3.1\Event Configuration.ecpx</Path>
<SourceId>1</SourceId>
</Location>

e. Once that XML code has been added, make sure to save the file so it overwrites.

18. Finally, go back to your Visual Studio application and Activate the configuration.
a. Log into the PLC and try clicking the button we setup to trigger the event.
b. If everything was done correctly, you should now see your message text show up in the
event table.
c. Back in our MAIN, you will see the bEvent1 Boolean go true, triggering the read. The
block matches the source ID and Event ID to the configured .ecpx file where it pulls the
message text.

This concludes the Event Table walk through.

Some side notes and troubleshooting tips:


 To add more events, simply add more instances of the SimpleAdsLogEvent function block for
each configured event. Remember that the blocks require a bool trigger as well.
o Then open and alter the event configurator file. Right clicking on your events or event
IDs will give the ability to add additional events in the configurator. Make sure to re-
save it and re-activate the event configurator when done.
o Then alter the TcEventSourceLocation file to add/match the additional source IDs. Re-
activate TwinCAT configuration to take effect.

 Are you targeting a PLC runtime for this application (not running locally)?
o The TcEventSourceLocation.xml file will need to be transferred over to the PLC PC and
placed in its respective folder location (overwriting the default existing one).
o The event configurator (.ecpx) file will need to be transferred to the PLC PC in its
respective folder location as well.
o You then need to open the TcEventConfigurator on the PLC PC and open the .ecpx file.
 After it has been opened and saved in the Event Configurator, re-activate the
event configuration.
o Once those files have been added and event configurator activated, you can now
activate your PLC TwinCAT configuration.

 If you trigger an event and it is not being found/showing inside the event table:
o Is the PLC code triggering the correct SimpleAdsLogEvent block?
o Does the PLC function block have the correct source and event IDs for the configured
event?
o Check the event configurator:
 Are the configured event IDs + Source IDs matching your PLC function block?
 Try re-saving it and re-activating the event configurator. This step can be easy to
forget sometimes.
o Double check the TcEventSourceLocation file:
 Do we have the correct source IDs added?
 Did we make sure to place them before the closing </TcEventSourceLocation>
tag?
 Is the path location is correct?
 Try re-saving the file in case this step was forgotten.
o Did we re-activate the TwinCAT configuration?

You might also like