Jump to content

Component: Modbus Master (SCADA) (Comms: System)

From Flowcode Help
Revision as of 14:42, 16 January 2023 by Wiki bot (talk | contribs)
Author Matrix TSL
Version 2.1
Category Comms: System


Modbus Master (SCADA) component

Modbus component for talking to Modbus compatible hardware via RS232 or RS485.

Component Source Code

Please click here for the component source code: FC_Comp_Source_Modbus_SCADA.fcsx

Detailed description

No detailed description exists yet for this component

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. 
- 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 
- BYTE Return


ReadCoil
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. 
- 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 
- BYTE Return


SetCoil
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. 
- UINT SlaveID
The ID of the MODBUS slave 
- UINT CoilAddress
Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ... 
- BYTE CoilState
0=Off, 1=On 
- BYTE Return


GetResponse
Collects as much incoming data as possible and stored into the response buffer. The number of bytes received will be stored into location 0 of the response buffer. Return value indicates validity of incoming CRC. 0 = OK, 1 = CRC fail, 255 = No Data 
- BYTE Return


SetCoils
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. 
- 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 
- BYTE CoilData
An array of bytes each containing 8 1-bit coil values 
- BYTE Return


GetResponseByte
Reads a byte from the last received response. The Index parametes specifies which byte to read back.  
- BYTE Index
0=NumBytes, 1=SlaveAddress, 2=FunctionCode/ExceptionCode, 3=DataBytes, 4=data0, 5=data1, .. 
- BYTE Return


ChangeFrameType
Default frame type is the type set in the component properties. 
- BYTE Type
0 = Modbus RTU / 1 = Modbus ASCII 
- VOID Return


GetResponseInt
Reads a 16-bit value from the last received response. The Index parametes specifies the byte index of the value to read back.  
- BYTE Index
4=data0, 6=data1, 8=data2, .. 
- UINT Return


SetHoldingRegisters
This command writes the contents of several 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. 
- 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 
- BYTE Return


ReadAnalogInput
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. 
- 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 
- BYTE Return


SetHoldingRegister
This command writes the contents of a holding register at the location RegAddress. Returns 0 for success, 1 for CRC fail and 255 for no reply. 
- UINT SlaveID
The ID of the MODBUS slave 
- UINT RegAddress
Address: 0=40001, 1=40002, ... 
- UINT RegValue
Value to send to the selected register 
- BYTE Return


ReadDigitalInput
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. 
- 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 
- BYTE Return


Initialise
Starts up the UART to allow communications 
- VOID Return



Property reference

Properties
Modbus Properties
Frame Type
Switches between RTU and ASCII forms of Modbus 
Receive Buffer Size
Maximum number of bytes the receive buffer can hold 
Slave ID Bytes
Number of bytes used when passing a slave ID, usually 1 but sometimes 2 
Silent Interval
Configures how much time to wait after each master modbus command before another command can be sent. A silent interval of 60ms minimum is required in order to guarentee successful reception of the next transmission. 0=No Delay 60 = 60mS - Default Range : 0 - 65535 
UART Receive Timeout
Amount of time to wait before timing out when listening for a slave's response. Range: 0 - 255. 0 = Don't Wait 1 - 254 = X ms 255 = Wait Forever 
Receive Timeout Count
Number of timeouts in a row to wait for until we decide the slave is not responding or finished responding to a message. Range: 0 - 255 0 = First Timeout Only 1 = First Timeout + 1 2 = First Timeout + 2 
Runtime Properties
Label
A text label to appear on the Modbus panel object. 
Console Data
Selects if the console data is automatically generated or not 
Console Columns
Number of characters that can be displayed on a single line of the console. 
Data Source
Simulation data source used to allow the component to connect to various remote devices Nothing - Simulation data is ignored COM port - Routes the communication data to and from a physical or virtual COM port Injector - Routes the communication data via a data injector component on the Panel. 
COM Port
Lists all the current available COM port hardware on your PC. 
Refresh Ports
 
Baud Rate
COM port data rate in bits per second