ADSLOGEVENT
The function block permits the sending and the acknowledgement of messages to the TwinCAT Eventlogger.
VAR_INPUT
VAR_INPUT
NETID : STRING(23);
PORT : UINT;
Event : BOOL;
EventQuit : BOOL;
EventConfigData : TcEvent;
EventDataAddress : UDINT;
EventDataLength : UDINT;
FbCleanup : BOOL;
TMOUT : TIME;
END_VAR
NETID : Is a string containing the AMS network identifier of the target device to which the ADS command is directed.
PORT : Contains the port number of the ADS device. The TwinCAT Eventlogger has the port number 110.
Event : With a rising edge the "coming" of the event is signaled, with a falling edge the "going" of the event.
EventQuit : With a rising edge the event is acknowledged.
EventConfigData : Data structure in the event parameters.
EventDataAddress : Address with the data, which sould be sent with the event.
EventDataLength : Length of the data, which should be sent with the event.
FbCleanup : At TRUE the function block is initialised completely.
TMOUT : States the time before the function is cancelled.
VAR_OUTPUT
VAR_OUTPUT
EventState : UDINT;
Err : BOOL;
ErrId : UDINT;
Quit : BOOL;
END_VAR
EventState : State of the events.
ERR : This output is switched to TRUE if an error occurs during the execution of a command. The command-specific error code is contained in ‘ErrorId’. If the block has a timeout error, ‘Error’ is TRUE and ‘ErrorId’ is 1861 (hexadecimal 0x745). Is reset to FALSE by the execution of a command at the inputs.
ERRID : Contains the command-specific error code of the most recently executed command. Is reset to 0 by the execution of a command at the inputs.
Quit : The Event is acknowledged.
The picture above shows the fundamental construction.
At non obligatory acknowledge messages, the event is reported with the rising edge at the event input of the function block and therewith active in the Eventlogger. The falling edge at the event input triggers the reset. With this signal the event is cancelled again in the Eventlogger.
At obligatory acknowledge messages the event is again activated wtih the rising edge at the event input. The event can be deactivated
* with a falling edge at the event input (if before an acknowledgement signal has come from the PLC with the quit input, or from the visualisation) or
* with a rising edge at the quit input ( if before a reset was released by a falling edge at the event input)
If a reset occurs between event activation and occurence of the acknowledgement, the next occurence of the event input is called "signal". Therewith a request is reported at already active event.
Stepwise flow:
- Configurate an Event:
- Parameterise EventConfigData sructure.
- transfer of parameter
Create an address to a structure, an array or a single variable with ADS to EventDataAddress. Determine the length of the structure, the array or the single variable with the SIZEOF operator, and supply the length to the input EventDataLength. If for example a structrue with an INT and LREAL variable should be transferred with an event, a structure with these two components has to be created and instantiated. The address and the length of this instance must be transferred. - Set an event:
Rising edge at the event input - Reset an event:
Falling edge at the event input - Acknowledge an event:
Rising edge at the quit input - Complete delete of the instance:
With the rising edge at the input FbCleanup the content of the instance is completely deleted. Therewith not straight an existing event is deleted from the Eventlogger.
After an event was sent to the Eventlogger, the Status of the event changes visibly at the eventstate output.
Example:
Configuration of the event:
Call FB ADSLOGEVENT:
The sample consists of
- An Event Configuration.ecp which can be opened and activated using the TcEventConfigurator
- A PLC sample Program
Requirements
Development environment | Target system type | PLC libraires to include |
---|---|---|
TwinCAT v2.7.0 | PC or CX (x86) | PLCEvent.Lib |
TwinCAT v2.8.0 | PC or CX (x86) | TcSystem.Lib |
TwinCAT v2.10.0 Build >= 1301 | CX (ARM) | TcSystem.Lib |