The following instructions are for both Modbus RTU (TModBusRTUDriver class) and Modbus TCP (TModBusTCPDriver class). To configure a protocol+tag connections you have to do:
- Insert a communication port appropriate for the chosen Modbus protocol:
- Insert the chosen protocol component;
- Connect the protocol to the port, through the “CommunicationPort” property;
- Insert the tags manually or through the “Tag builder” tool
- If you insert the tags manually, set the properties as described below;
- Connect the tag to the protocol driver through the ProtocolDriver property present in each tag.
Both protocol classes support the following tag classes:
To configure a tag to use Modbus, you must configure the following tag properties:
- PLCStation: Modbus equipment address. For Modbus TCP, this property has its value set to 1, it usually depends on the Modbus Server implementation.
- MemAddress: Address of the input/output/register that you want to read/write. The addresses start from zero, always. Do not use the address notation 1xxxxx, 2xxxxx, 3xxxxx, 4xxxxx, as it is not supported.
- MemReadFuntion: Function that will be used to read the tag. See table below.
- MemWriteFuntion: Function that will be used to write tag values. See table below.
For the MemReadFunction and MemWriteFunction properties the following values are accepted according to the desired memory area:
|Coils (digital outputs)||1||
15 (TPLCTagNumber TPLCBlock TPLCStruct TPLCString)
16 (TPLCTagNumber TPLCBlock TPLCStruct TPLCString)
|Analog registers (analog inputs)||4||0|
You need to know the ModBus functions your device supports.