I'm still very new to OOP and TwinCat so please bear with me. I'm currently developing the software for a small machine that will be used combined with the TF2000 HMI. Because the Event Grid takes away a lot of work I want to set up the TC3 EventLogger. I understand how you create alarms etc. and I can display them in the HMI Event Grid.
It works great with single events, but now I want to take it further and add the errors of every function block. For example FB_TemperatureController can report overheat, FB_Motor can report a stop error and so on.
How do I setup the event logger so I can send the same error from every instantiated FB?
I thought of creating a FB_FaultHandler:
FUNCTION_BLOCK FB_FaultHandler
VAR
fbEventLogger : FB_TcEventLogger;
aMessages : ARRAY [0..100] OF Fb_TcMessage;
aAlarms : ARRAY [0..100] OF Fb_TcAlarm;
END_VAR
METHOD init
VAR_INPUT
END_VAR
aAlarms[0].CreateEx(Tc_Events.AlarmEvents.Error_Overtemp, TRUE, 0);
aAlarms[1].CreateEx(Error2, TRUE, 0);
aAlarms[2].CreateEx(Error3, TRUE, 0);
aAlarms[3].CreateEx(Error4, TRUE, 0);
aAlarms[4].CreateEx(, TRUE, 0);
aAlarms[5].CreateEx(, TRUE, 0);
aAlarms[6].CreateEx(, TRUE, 0);
There's a few things I don't like about this tho:
- The source of the event would always be FB_FaultHandler but I want it to display the concerning FB
- I'm not sure how to raise an alarm from different instances twice. For example: fbTemp1 and fbTemp 2 are both instances of FB_TemperatureController. Now if I create a "SetFault" Method in the FB_FaultHandler, which raises and confirms an alarm it would raise the same error twice without me knowing the source.
METHOD setError
VAR_INPUT
nErrorId: INT;
bErrorActive: BOOL;
END_VAR
- I'd prefer if the array would be set up with the id of an event. So "Error_Overtemp" has id 96 and the
FB_FaultHandler
will put it inaAlarms[96]
I haven't really found any real samples about this anywhere. I watched the Webinar but it honestly is described very poorly. I'd be thankful for any help, input or examples of a good event logger.