CODESYS V2.3 internal PLC provides support for communication with Modbus TCP Ethernet I/Os.
It is possible to select devices from 3 producers: Beckhoff, Wago and Weidmuller, and provides also a generic model called STD_MODBUS.
Modbus physical addressing of I/O resources for predefined producers is fixed but in case you require to set a specific Modbus starting address for the I/O resources it is possible, by selecting STD_MODBUS model, to define such addresses at application side.
This can be done by using an apposite Codesys Function block called EXOR_IO_CTRL, included into the EXOR.lib library.
The below table specifies the correspondence between the I/O type and the specific Modbus resource.
I/O | Modbus memory resource | Data type |
---|---|---|
Analog Input | Input Register | 16 bit |
Analog Output | Holding Register | 16 bit |
Digital Input | Input bit | 1 bit |
Digital Output | Output Coil | 1 bit |
The EXOR_IO_CTRL function block must be recalled by the CODESYS application to set the Modbus addressing, the function block can be recalled for each board configured into the PLC configuration of CODESYS application.
res := EXOR_IO_CTRL( wNodeNumber , diFunctionCode , diArgument );
Below you can find a description of each parameter involved into the EXOR_IO_CTRL call.
wNodeNumber = Each board in the CODESYS V2.3 PLC Configuration editor has a progressive Node Number starting from zero; this is assigned by CODESYS and can be seen in the board “Base Parameters”. This parameter identifies the board to which the “diFunctionCode” and “diArgument” parameters will be passed
diFunctionCode
diArgument
This parameter is passed to the specified board; its significance varies from board to board.
In this specific case the diArgument specifies the number of the Modbus starting address for the specified data area, the possible range is 0 -65535.
diIoCtrlResult
This is the return value; the function returns 0 if the execution was successful, 1 if value is out
of range, 2 if function code is unknown
In attachment you can find a simple CODESYS application that shows the use of this function block.
eTOP400 serie, eTOP500 series, CODESYS V2.3 internal PLC.
Type: application/octet-stream
Name: Generic_ModbusETH_IO.zip