Karabo PLC interface¶
PLC Structure and Functions¶
Most of the control hardware in the European XFEL facility is managed by PLC modules produced by Beckhoff GmbH and installed and configured by the Advanced Electronics (AE) group. A real-time equipment protection system can be implemented only in the PLC layer.
The PLC System consists of multiple modules connected via the EtherCAT network protocol and is connected in a redundant loop to an Industrial PC that implements all the communication and interlock logic in a common Framework (European XFEL internal link).
PLC-TCP Interface¶
The PLC program comprises multiple software elements, sometimes referred to as equipment or soft-devices to organize the interactions of one or more terminals (e.g. 2 inputs and one output to define the state of a Valve). Each soft-device implements an Interface (XFEL internal link) to the control network using the TCP protocol.
BeckhoffCom¶
In order to simplify the TCP server architecture in the PLC, only one
client is allowed to connect at a time.
Message decoding and Message dispatching to and from the PLC is implemented
in a specific device called BeckhoffCom
.
This Karabo device will receive the list of soft-devices and their respective classes declared by the PLC on connection and will start communication with the corresponding BeckhoffDevices.
After the connection is established, each device will go to a NORMAL state and poll all its configuration from the PLC. From this moment, it will follow the remote state of the associated PLC device. More information on devices is available in the section Beckhoff Device.
BeckhoffSim - PLC Simulation¶
The PLC simulation is implemented in a Karabo device called BeckhoffSim
that implements the following features:
- Compatibility the same protocol (i.e. Interface) that the PLC uses is adopted. An equivalent FIFO Buffer is also employed to mimic PLC behavior.
- PLC Based the code of the BeckhoffSim is based on the PLC device code and input from the code’s authors.
- Modular the classes of PLC soft-devices can be implemented one at a time and features can be added when missing.
- Independent BeckhoffSim is a Karabo device but is completely independent from BeckhoffCom and BeckhoffDevices. It has been demonstrated that it can run in a completely independent broker topic on a different Karabo version.
By its nature, the provided simulation is not capable of predicting the multitude of possible configurations (physics) required to properly simulate a beamline infrastructure. There is however a way to implement user-specific (physical) simulations.
Getting Simulation environment started¶
Create yourself a project with a beckhoffCom and beckhoffSim instance as shown in the following example.
Set the server Uri from the beckhoffCom instance to localhost:1234
and createGenericDevices
to true
before instantiating the device.
You can define the type and number of soft-devices in the BeckhoffSim device configuration by following these steps
- click on edit table in the deviceTable property of beckhoffSim
- in the dialog, rightclick over the row number and select in the cotext menu add a row below
- Each row represents a single soft-device for the simulation environment.
In this example a DigitalOutput and a StepperAxis have been defined in the table element.
Instantiating all devices should provide you a running hardware emulation. The
hardware (PLC) properties for each soft-device are exposed in the BeckhoffSim
device under a node element called Devices
.
This device node element provides additional node elements, one for each added
PLC soft-device with the specific device name (deviceId). Following the
property tree you will find the node elements PLC Properties
and
Hardware IO's
. The PLC properties are send via tcp to beckhoffCom while
the hardware IO’s are internally used for emulation behavior, e.g. setting
errorbits or hardware based properties like end switches for motors.