Difference between revisions of "Component: Modbus TCP Master (Comms: System)"

From Flowcode Help
Jump to navigationJump to search
(XML import)
 
Line 15: Line 15:
  
  
==[[File:Component Icon 019e3dbb_2bfa_44a7_baf0_17b672d9b8f4.png|Image]] Modbus TCP Master component==
+
==[[File:Component Icon 47f6b39b_ead7_40f5_9931_8a79aa54014a.png|Image]] Modbus TCP Master component==
 
Modbus component for talking to Modbus compatible hardware via Ethernet or WIFI.
 
Modbus component for talking to Modbus compatible hardware via Ethernet or WIFI.
 
Ensure TCP/IP or WIFI component is intialised and connected to a network before calling the ModbusMasterTCP component macros.
 
Ensure TCP/IP or WIFI component is intialised and connected to a network before calling the ModbusMasterTCP component macros.

Revision as of 15:56, 25 May 2018


Author Matrix Ltd.
Version 2.0 (Release)
Category Comms: System


Image Modbus TCP Master component

Modbus component for talking to Modbus compatible hardware via Ethernet or WIFI. Ensure TCP/IP or WIFI component is intialised and connected to a network before calling the ModbusMasterTCP component macros.


Examples

No additional examples


Downloadable macro reference

ReadHoldingRegister

This command requests the analogue holding register values starting from the start RegAddress and going through to RegAddress plus RegCount.

Returns 0 for success, 1 for CRC fail and 255 for no reply.

Parameters

UINT SlaveID
The ID of the MODBUS slave
UINT RegAddress
Address: 0=40001, 1=40002, ...
UINT RegCount
Number of consecutive registers to read, starting from RegAddress


Return value

BYTE


ForceMultipleCoils

This command writes the contents of a series of discrete coils at the location starting at CoilAddress through to CoilAddress + CoilCount.

Returns 0 for success, 1 for CRC fail and 255 for no reply.

Parameters

BYTE SlaveID
The ID of the MODBUS slave - Used for TCP to Serial forwarders
UINT CoilAddress
Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ...
UINT CoilCount
Number of consecutive coils to try and read
BYTE CoilData
An array of bytes each containing 8 1-bit coil values


Return value

BYTE


ForceSingleCoil

This command writes the contents of a discrete coil at the location CoilAddress.

Returns 0 for success, 1 for CRC fail and 255 for no reply.

Parameters

BYTE SlaveID
The ID of the MODBUS slave
UINT CoilAddress
Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ...
BYTE CoilState
0=Off, 1=On


Return value

BYTE


ReadCoilStatus

This command requests the ON/OFF status of discrete coils starting from the start CoilAddress and going through to CoilAddress plus CoilCount.

Returns 0 for success, 1 for CRC fail and 255 for no reply.

Parameters

UINT SlaveID
The ID of the MODBUS slave
UINT CoilAddress
Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ...
UINT CoilCount
Number of consecutive coils to try and read


Return value

BYTE


GetResponseByte

Reads a byte from the last received response. The Index parametes specifies which byte to read back.

Parameters

BYTE Index
0=NumBytes, 1=SlaveAddress, 2=FunctionCode/ExceptionCode, .....


Return value

BYTE


ReadInputStatus

This command requests the ON/OFF status of discrete inputs starting from the start DataAddress and going through to DataAddress plus DataCount.

Returns 0 for success, 1 for CRC fail and 255 for no reply.

Parameters

UINT SlaveID
The ID of the MODBUS slave
UINT DataAddress
Input Address: 0=10001, 1=10002, 2=10003, ...
UINT DataCount
Number of consecutive inputs to read, starting from RegAddress


Return value

BYTE


PresetSingleRegister

This command writes the contents of a analogue output holding registerl at the location RegAddress.

Returns 0 for success, 1 for CRC fail and 255 for no reply.

Parameters

UINT SlaveID
The ID of the MODBUS slave
UINT RegAddress
Address: 0=40001, 1=40002, ...
UINT RegValue
Value to send to the selected register


Return value

BYTE


GetResponseInt

Reads a 16-bit value from the last received response.

The Index parametes specifies the byte index of the value to read back.

Parameters

BYTE Index
0=NumBytes, 1=SlaveAddress, 2=FunctionCode/ExceptionCode, .....


Return value

UINT


ReadInputRegister

This command requests the analogue input register values starting from the start RegAddress and going through to RegAddress plus RegCount.

Returns 0 for success, 1 for CRC fail and 255 for no reply.

Parameters

UINT SlaveID
The ID of the MODBUS slave
UINT RegAddress
Input Address: 0=10001, 1=10002, 2=10003, ...
UINT RegCount
Number of consecutive inputs to read, starting from RegAddress


Return value

BYTE


PresetMultipleRegisters

This command writes the contents of several analogue output holding registers starting at the location RegAddress through to location RegAddress + RegCount .

Returns 0 for success, 1 for CRC fail and 255 for no reply.

Parameters

UINT SlaveID
The ID of the MODBUS slave
UINT RegAddress
Address: 0=40001, 1=40002, ...
UINT RegCount
Number of consecutive registers to write, starting from RegAddress
UINT RegValue
Array of values to send to the registers


Return value

BYTE


SetTCPAddress

Sets the address of the remote TCP Slave that we wish to control.

Parameters

<- STRING Address
e.g. "192.168.1.1"
This parameter may be returned back to the caller


Return value

This call does not return a value


Simulation macro reference

This component does not contain any simulation macros


Property reference

TCP/IP Component

This property is of type Panel object and can be referenced with the variable name NetworkComms1::Component.

Property to point to the TCP/IP or WIFI component you want to use.

If unconnected then default to simulated TCP/IP network communications using the PC network adapter.

Status

This property is of type Line of text and can be referenced with the variable name NetworkComms1::Status.

No additional information


TCP/IP Port

This property is of type Unsigned integer and can be referenced with the variable name Port.

Port used for network communications

Range: 0-65535

Receive Buffer Size

This property is of type Unsigned integer and can be referenced with the variable name ReceiveBufferSize.

Maximum number of bytes the receive buffer can hold

Label

This property is of type Line of text and can be referenced with the variable name label.

A text label to appear on the Modbus panel object.