Direct Remote-IO access with SILECS
Direct remote IO provides the ability to address analog/digital IO modules of a PLC or Ethernet Bus controller (EBC) directly, without having to deal with the PLC memory/logic.
The IO-* blocks within SILECS C++ code are treated basically the same as are the "normal (memory)" DB blocks. The IO blocks do not produce any output in the .scl file as that is only for the DB blocks.
The only difference within SILECS is at the communication end where the underlying SNAP7 functions are called. The IO-* blocks use the Cli_AB and Cli_EB functions, see
here. These functions have direct access to the HW outputs and inputs of the PLC (
IPU and IPI area).
Please note that it is required to disconnect the Output IO's from all software modules defined in the PLC memory! Otherwise the hardware will not react !
Please note that for Siemens PLC's it is not possible to read back PLC-Output values. They only can be set !
However it is no problem to use Input IO's in PLC-memory and direct IO-Communication in parallel.
Currently there is support for SIEMENS SIMATIC S7 familly (PLC) and BECKOFF BK9xxx (EBC).
Design document
For direct IO communication you need to use the Block-Types "Setting-IO-Block", "Acquisition-IO-Block" and "Command-IO-Block".
For Siemens PLC's only "Acquisition-IO-Block" and "Command-IO-Block" can be used, since it is not possible to read back PLC-output values of a Setting on Simatic PLC's.
You have different possibilities to model the access to a single module. E.g. a Siemens 32Bit DI-Module can be accessed:
- with one uint8 Register, used by 4 devices
or
- with four unit8 Registers. used by one device
Deploy document
Four new base-address attributes have been added to the deploy document in order to make use of the controller modules.
Please not that you need to arrange your modules in logical blocks of DI / DO / AI /AO in order to be able to address them all !
The base-address attributes are dependent on the address given to your module by the controller hardware configuration:
The SILECS C++ API to access I/O registers
The base API to access I/O registers is exactly the same with the one used already to access memory registers.
Connect
To connect, you will need the class name, version and the controller name
pService = Silecs::Service::getInstance(argc, argv);
pClusterS1200 = pService->getCluster("S12xxIO", "1.0.0");
pPLCS1200 = pClusterS1200->getPLC("cfp-774-csimatic-s7-04");
pPLCS1200->connect(Silecs::MASTER_SYNCHRO, true);
In the example above, we connect to the class with name "S12xxIO" and version "1.0.0". The controller name is "cfp-774-csimatic-s7-04"
Set an IO register
To write to device 0, register "DO_data_out1" a byte value, you need to make the following API call:
pPLCS1200->getDevice("0")->getRegister("DO_data_out1")->setValUInt8(data);
and than send the block "DO1" which contains "DO_data_out1":
pPLCS1200->getDevice("0")->send("DO1");
DO1 block is defined as DIGITAL/ WRITE-ONLY block in the design document.
Get an IO register
Before reading specific registers, we first need to fetch the block we are interested in:
pPLCS400->getDevice("0")->recv("DI1");
Afterwards, to read from device 0, register "DI_data_in1" a byte value, you need to make the following API call:
buffer = pPLCS400->getDevice("0")->getRegister("DI_data_in1")->getValUInt8();
DI1 block is defined as DIGITAL/ READ-ONLY block in the design document.
For more information, take a look at the full API
documentation
Data types
The I/O operations support all the data types available for memory. However, they are treated as a simple sequence of bytes from the protocol point of view.
There is no meaning to use string, float or date type with IOs and we strongly recommend to use the appropriate type in accordance with the IO modules type (uint8, uint16 and possibly arrays of that type).
Block and device mode
Same modes as for Memory area can be used to reflect the IOs addressing:
- DEVICE_MODE: A contiguous set of IO channels per class/device containing the ordered list of (IO) Blocks as defined in the Design document.
- BLOCK_MODE: A contiguous set of IO channels per class/block containing an array of corresponding (IO) Block (one array element per instance).
Please, pay attention that result of the Design (ordered blocks and registers elements) and the Deploy (number of instances) mapping must absolutely fit with the static hardware configuration of the controller.