Jump to content

Component: Modbus Slave (SCADA) (Comms: System): Difference between revisions

From Flowcode Help
No edit summary
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(13 intermediate revisions by 2 users not shown)
Line 16: Line 16:


==Component Source Code==
==Component Source Code==
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_Modbus_Slave_SCADA.fcsx FC_Comp_Source_Modbus_Slave_SCADA.fcsx]


Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Modbus_Slave_SCADA.fcsx FC_Comp_Source_Modbus_Slave_SCADA.fcsx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Modbus_Slave_SCADA.fcsx FC_Comp_Source_Modbus_Slave_SCADA.fcsx]


==Detailed description==
==Detailed description==




Line 40: Line 48:


==Examples==
==Examples==




Line 61: Line 75:




==Macro reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadHoldingRegister'''
|-
| colspan="2" | Reads the value of a single holding register. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Address
|-
| colspan="2" | Coil Address 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetCoil'''
|-
| colspan="2" | Sets the state of a single digital coil. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Address
|-
| colspan="2" | Coil Address 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | State
|-
| colspan="2" | 0=off, 1=on 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
 
 
 
 
 
 
==Macro reference==
 
===ChangeFrameType===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetDigitalInput'''
| width="90%" class="mtx-class-macrohead" | '''ChangeFrameType'''
|-
|-
| colspan="2" | Sets the state of a single digital input. 
| colspan="2" | Default frame type is the type set in the component properties. 
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Address
|-
| colspan="2" | Coil Address 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | State
| width="90%" | Type
|-
|-
| colspan="2" | 0=off, 1=on 
| colspan="2" | 0 = Modbus RTU / 1 = Modbus ASCII 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
Line 127: Line 108:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===CheckForIncoming===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSlaveAddress'''
| width="90%" class="mtx-class-macrohead" | '''CheckForIncoming'''
|-
|-
| colspan="2" | Allows the slave address to be overridden from the default slave address specified in the component property. The number of bytes used for the address is fixed by the Slave ID Bytes property to save on RAM usage. 
| colspan="2" | Checks for an incoming message and if the data address is within range then also automatically replies with the correct reply. Returns 0 if no comms received, 1 for a succesful transaction, 255 for an error. 
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | SlaveAddress
|-
| colspan="2" |  
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===GetLastIncoming===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ChangeFrameType'''
| width="90%" class="mtx-class-macrohead" | '''GetLastIncoming'''
|-
|-
| colspan="2" | Default frame type is the type set in the component properties. 
| colspan="2" | Gets a value from the last incoming command. Index 0 = 0 Read / 1 Write Index 1 = 0 Coils / 1 DigInput / 2 AnInput / 3 Register Index 2 = Address  Index 3 = Number 
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Type
| width="90%" | Index
|-
|-
| colspan="2" | 0 = Modbus RTU / 1 = Modbus ASCII 
| colspan="2" | Range: 0-3 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===Initialise===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadCoils'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| colspan="2" | Reads the state of up to eight digital coils. Can pack a max of 8-bits together in a single operation 
| colspan="2" | Starts up the UART to allow communications and initialises the states of the various  Modbus Coils, Inputs and Registers to 0. 
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" | StartAddress
|-
| colspan="2" | Coil Address Range 0 to (NumCoils - 1) 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | AddressCount
|-
| colspan="2" | Range 1-8 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===ReadAnalogInput===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetHoldingRegister'''
| width="90%" class="mtx-class-macrohead" | '''ReadAnalogInput'''
|-
|-
| colspan="2" | Sets the state of a single holding register. 
| colspan="2" | Reads the value of a single analogue input. 
|-
|-
|-
|-
Line 199: Line 169:
| colspan="2" | Coil Address 
| colspan="2" | Coil Address 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Value
|-
| colspan="2" | Analogue Value range 0 - 65535 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===ReadCoils===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAnalogInput'''
| width="90%" class="mtx-class-macrohead" | '''ReadCoils'''
|-
|-
| colspan="2" | Reads the value of a single analogue input. 
| colspan="2" | Reads the state of up to eight digital coils. Can pack a max of 8-bits together in a single operation 
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Address
| width="90%" | StartAddress
|-
|-
| colspan="2" | Coil Address 
| colspan="2" | Coil Address Range 0 to (NumCoils - 1) 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" | AddressCount
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckForIncoming'''
|-
| colspan="2" | Checks for an incoming message and if the data address is within range then also automatically replies with the correct reply. Returns 0 if no comms received, 1 for a succesful transaction, 255 for an error. 
|-
|-
| colspan="2" | Range 1-8 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
Line 240: Line 198:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===ReadDigitalInputs===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadDigitalInputs'''
| width="90%" class="mtx-class-macrohead" | '''ReadDigitalInputs'''
|-
|-
| colspan="2" | Reads the state of up to eight digital inputs. Can pack a max of 8-bits together in a single operation 
| colspan="2" | Reads the state of up to eight digital inputs. Can pack a max of 8-bits together in a single operation 
Line 263: Line 222:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===ReadHoldingRegister===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLastIncoming'''
| width="90%" class="mtx-class-macrohead" | '''ReadHoldingRegister'''
|-
|-
| colspan="2" | Gets a value from the last incoming command. Index 0 = 0 Read / 1 Write Index 1 = 0 Coils / 1 DigInput / 2 AnInput / 3 Register Index 2 = Address Index 3 = Number 
| colspan="2" | Reads the value of a single holding register. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Address
|-
|-
| colspan="2" | Coil Address 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
Line 276: Line 241:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetAnalogInput===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetAnalogInput'''
| width="90%" class="mtx-class-macrohead" | '''SetAnalogInput'''
|-
|-
| colspan="2" | Sets the state of a single analogue input. 
| colspan="2" | Sets the state of a single analogue input. 
Line 299: Line 265:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetCoil===
|-
{| class="mtx-class-macrotable wikitable"
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
| colspan="2" | Starts up the UART to allow communications and initialises the states of the various  Modbus Coils, Inputs and Registers to 0. 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
 
 
==Property reference==
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Modbus Properties
|-
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | Frame Type
|-
| colspan="2" | Switches between RTU and ASCII forms of Modbus 
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Receive Buffer Size
|-
| colspan="2" | Maximum number of bytes the receive buffer can hold 
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Receive Timeout
|-
| colspan="2" | Length in milliseconds to wait for additional bytes to be received when checking for incoming messages. 
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Slave ID Bytes
|-
| colspan="2" | Number of bytes used when passing a slave ID, usually 1 but sometimes 2 
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Slave Address
|-
|-
| colspan="2" |  
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
|-
| width="90%" class="mtx-class-macrohead" | '''SetCoil'''
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Reply Delay
|-
| colspan="2" | Delay in micro seconds to wait before transmitting a reply 
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Maintain Stats
|-
| colspan="2" | Controls if the last command from the master is logged allowing for easier value updates. No - Do not log commands Yes - Commands are logged and available via the GetLastIncoming macro 
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Runtime Properties
|-
|-
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
| width="90%" | Label
|-
| colspan="2" | A text label to appear on the Modbus panel object. 
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Console Data
|-
| colspan="2" | Selects if the console data is automatically generated or not 
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Console Columns
|-
| colspan="2" | Number of characters that can be displayed on a single line of the console. 
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | Data Source
|-
| colspan="2" | 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. 
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | COM Port
|-
| colspan="2" | Lists all the current available COM port hardware on your PC. 
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Refresh Ports
|-
| colspan="2" |  
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Baud Rate
|-
| colspan="2" | COM port data rate in bits per second 
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Modbus Coils - Single bit values
|-
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Starting Address
|-
| colspan="2" | Start address of the Modbus coils. Referenced from 0. For example  Slave 1 might have 100 coils addressed 0-99 Start Address = 0 Slave 2 might have 100 coils addressed 100-199 Start Address = 100 
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Number of Addresses
|-
| colspan="2" | Specifies how many Coils are available on the slave. Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte. 
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Digital Inputs - Single bit values
|-
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Starting Address
|-
| colspan="2" | Start address of the Modbus digital inputs. Referenced from 0. For example  Slave 1 might have 100 inputs addressed 0-99 Start Address = 0 Slave 2 might have 100 inputs addressed 100-199 Start Address = 100 
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Number of Addresses
|-
| colspan="2" | Specifies how many Digital Inputs are available on the slave. Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte. 
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Analog Inputs - 16-bit values
|-
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Starting Address
|-
| colspan="2" | Start address of the Modbus analogue inputs. Referenced from 0. For example  Slave 1 might have 100 inputs addressed 0-99 Start Address = 0 Slave 2 might have 100 inputs addressed 100-199 Start Address = 100 
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Number of Addresses
|-
| colspan="2" | Specifies how many 16-bit analogue inputs are available on the slave. Each address consumes two RAM Bytes. 
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Holding Registers - 16-bit values
|-
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Starting Address
|-
| colspan="2" | Start address of the Modbus registers. Referenced from 0. For example  Slave 1 might have 100 registers addressed 0-99 Start Address = 0 Slave 2 might have 100 registers addressed 100-199 Start Address = 100 
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Number of Addresses
|-
| colspan="2" | Specifies how many 16-bit holding registers are available on the slave. Each address consumes two RAM Bytes. 
|}==Macro reference==
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadHoldingRegister'''
|-
| colspan="2" | Reads the value of a single holding register. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Address
|-
| colspan="2" | Coil Address 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetCoil'''
|-
|-
| colspan="2" | Sets the state of a single digital coil. 
| colspan="2" | Sets the state of a single digital coil. 
Line 498: Line 289:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetDigitalInput===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetDigitalInput'''
| width="90%" class="mtx-class-macrohead" | '''SetDigitalInput'''
|-
|-
| colspan="2" | Sets the state of a single digital input. 
| colspan="2" | Sets the state of a single digital input. 
Line 521: Line 313:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetHoldingRegister===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSlaveAddress'''
| width="90%" class="mtx-class-macrohead" | '''SetHoldingRegister'''
|-
| colspan="2" | Allows the slave address to be overridden from the default slave address specified in the component property. The number of bytes used for the address is fixed by the Slave ID Bytes property to save on RAM usage. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | SlaveAddress
|-
| colspan="2" |  
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ChangeFrameType'''
|-
| colspan="2" | Default frame type is the type set in the component properties. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Type
|-
| colspan="2" | 0 = Modbus RTU / 1 = Modbus ASCII 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadCoils'''
|-
| colspan="2" | Reads the state of up to eight digital coils. Can pack a max of 8-bits together in a single operation 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | StartAddress
|-
| colspan="2" | Coil Address Range 0 to (NumCoils - 1) 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | AddressCount
|-
| colspan="2" | Range 1-8 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetHoldingRegister'''
|-
|-
| colspan="2" | Sets the state of a single holding register. 
| colspan="2" | Sets the state of a single holding register. 
Line 603: Line 337:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SetSlaveAddress===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAnalogInput'''
| width="90%" class="mtx-class-macrohead" | '''SetSlaveAddress'''
|-
|-
| colspan="2" | Reads the value of a single analogue input. 
| colspan="2" | Allows the slave address to be overridden from the default slave address specified in the component property. The number of bytes used for the address is fixed by the Slave ID Bytes property to save on RAM usage. 
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Address
| width="90%" | SlaveAddress
|-
|-
| colspan="2" | Coil Address 
| colspan="2" |  
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckForIncoming'''
|-
| colspan="2" | Checks for an incoming message and if the data address is within range then also automatically replies with the correct reply. Returns 0 if no comms received, 1 for a succesful transaction, 255 for an error. 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadDigitalInputs'''
|-
| colspan="2" | Reads the state of up to eight digital inputs. Can pack a max of 8-bits together in a single operation 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | StartAddress
|-
| colspan="2" | Coil Address Range 0 to (NumCoils - 1) 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | AddressCount
|-
| colspan="2" | Range 1-8 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLastIncoming'''
|-
| colspan="2" | Gets a value from the last incoming command. Index 0 = 0 Read / 1 Write Index 1 = 0 Coils / 1 DigInput / 2 AnInput / 3 Register Index 2 = Address  Index 3 = Number 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetAnalogInput'''
|-
| colspan="2" | Sets the state of a single analogue input. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Address
|-
| colspan="2" | Coil Address 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Value
|-
| colspan="2" | Analogue Value range 0 - 65535 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
| colspan="2" | Starts up the UART to allow communications and initialises the states of the various  Modbus Coils, Inputs and Registers to 0. 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




==Property reference==
==Property reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Modbus Properties
| width="90%" class="mtx-class-propfolder" | Modbus Properties
|-
|-
|-
|-
Line 755: Line 403:
| colspan="2" | Controls if the last command from the master is logged allowing for easier value updates. No - Do not log commands Yes - Commands are logged and available via the GetLastIncoming macro 
| colspan="2" | Controls if the last command from the master is logged allowing for easier value updates. No - Do not log commands Yes - Commands are logged and available via the GetLastIncoming macro 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Runtime Properties
| width="90%" class="mtx-class-propfolder" | Runtime Properties
|-
|-
|-
|-
Line 794: Line 442:
| colspan="2" | COM port data rate in bits per second 
| colspan="2" | COM port data rate in bits per second 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Modbus Coils - Single bit values
| width="90%" class="mtx-class-propfolder" | Modbus Coils - Single bit values
|-
|-
|-
|-
Line 808: Line 456:
| colspan="2" | Specifies how many Coils are available on the slave. Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte. 
| colspan="2" | Specifies how many Coils are available on the slave. Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte. 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Digital Inputs - Single bit values
| width="90%" class="mtx-class-propfolder" | Digital Inputs - Single bit values
|-
|-
|-
|-
Line 822: Line 470:
| colspan="2" | Specifies how many Digital Inputs are available on the slave. Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte. 
| colspan="2" | Specifies how many Digital Inputs are available on the slave. Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte. 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Analog Inputs - 16-bit values
| width="90%" class="mtx-class-propfolder" | Analog Inputs - 16-bit values
|-
|-
|-
|-
Line 836: Line 484:
| colspan="2" | Specifies how many 16-bit analogue inputs are available on the slave. Each address consumes two RAM Bytes. 
| colspan="2" | Specifies how many 16-bit analogue inputs are available on the slave. Each address consumes two RAM Bytes. 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Holding Registers - 16-bit values
| width="90%" class="mtx-class-propfolder" | Holding Registers - 16-bit values
|-
|-
|-
|-

Latest revision as of 14:36, 13 July 2026

Author Matrix TSL
Version 1.0
Category Comms: System


Modbus Slave (SCADA) component

Modbus component for creating Modbus compatible slave hardware via RS232 or RS485.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_Modbus_Slave_SCADA.fcsx

Please click here to view the component source code (Beta): FC_Comp_Source_Modbus_Slave_SCADA.fcsx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples








Macro reference

ChangeFrameType

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


CheckForIncoming

CheckForIncoming
Checks for an incoming message and if the data address is within range then also automatically replies with the correct reply. Returns 0 if no comms received, 1 for a succesful transaction, 255 for an error. 
- BYTE Return


GetLastIncoming

GetLastIncoming
Gets a value from the last incoming command. Index 0 = 0 Read / 1 Write Index 1 = 0 Coils / 1 DigInput / 2 AnInput / 3 Register Index 2 = Address Index 3 = Number 
- BYTE Index
Range: 0-3 
- UINT Return


Initialise

Initialise
Starts up the UART to allow communications and initialises the states of the various Modbus Coils, Inputs and Registers to 0. 
- VOID Return


ReadAnalogInput

ReadAnalogInput
Reads the value of a single analogue input. 
- UINT Address
Coil Address 
- UINT Return


ReadCoils

ReadCoils
Reads the state of up to eight digital coils. Can pack a max of 8-bits together in a single operation 
- UINT StartAddress
Coil Address Range 0 to (NumCoils - 1) 
- BYTE AddressCount
Range 1-8 
- BYTE Return


ReadDigitalInputs

ReadDigitalInputs
Reads the state of up to eight digital inputs. Can pack a max of 8-bits together in a single operation 
- UINT StartAddress
Coil Address Range 0 to (NumCoils - 1) 
- BYTE AddressCount
Range 1-8 
- BYTE Return


ReadHoldingRegister

ReadHoldingRegister
Reads the value of a single holding register. 
- UINT Address
Coil Address 
- UINT Return


SetAnalogInput

SetAnalogInput
Sets the state of a single analogue input. 
- UINT Address
Coil Address 
- UINT Value
Analogue Value range 0 - 65535 
- VOID Return


SetCoil

SetCoil
Sets the state of a single digital coil. 
- UINT Address
Coil Address 
- BYTE State
0=off, 1=on 
- VOID Return


SetDigitalInput

SetDigitalInput
Sets the state of a single digital input. 
- UINT Address
Coil Address 
- BYTE State
0=off, 1=on 
- VOID Return


SetHoldingRegister

SetHoldingRegister
Sets the state of a single holding register. 
- UINT Address
Coil Address 
- UINT Value
Analogue Value range 0 - 65535 
- VOID Return


SetSlaveAddress

SetSlaveAddress
Allows the slave address to be overridden from the default slave address specified in the component property. The number of bytes used for the address is fixed by the Slave ID Bytes property to save on RAM usage. 
- UINT SlaveAddress
 
- 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 
Receive Timeout
Length in milliseconds to wait for additional bytes to be received when checking for incoming messages. 
Slave ID Bytes
Number of bytes used when passing a slave ID, usually 1 but sometimes 2 
Slave Address
 
Reply Delay
Delay in micro seconds to wait before transmitting a reply 
Maintain Stats
Controls if the last command from the master is logged allowing for easier value updates. No - Do not log commands Yes - Commands are logged and available via the GetLastIncoming macro 
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 
Modbus Coils - Single bit values
Starting Address
Start address of the Modbus coils. Referenced from 0. For example Slave 1 might have 100 coils addressed 0-99 Start Address = 0 Slave 2 might have 100 coils addressed 100-199 Start Address = 100 
Number of Addresses
Specifies how many Coils are available on the slave. Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte. 
Digital Inputs - Single bit values
Starting Address
Start address of the Modbus digital inputs. Referenced from 0. For example Slave 1 might have 100 inputs addressed 0-99 Start Address = 0 Slave 2 might have 100 inputs addressed 100-199 Start Address = 100 
Number of Addresses
Specifies how many Digital Inputs are available on the slave. Each address consumes a single bit of RAM, 8 Addresses are packed together into a single RAM Byte. 
Analog Inputs - 16-bit values
Starting Address
Start address of the Modbus analogue inputs. Referenced from 0. For example Slave 1 might have 100 inputs addressed 0-99 Start Address = 0 Slave 2 might have 100 inputs addressed 100-199 Start Address = 100 
Number of Addresses
Specifies how many 16-bit analogue inputs are available on the slave. Each address consumes two RAM Bytes. 
Holding Registers - 16-bit values
Starting Address
Start address of the Modbus registers. Referenced from 0. For example Slave 1 might have 100 registers addressed 0-99 Start Address = 0 Slave 2 might have 100 registers addressed 100-199 Start Address = 100 
Number of Addresses
Specifies how many 16-bit holding registers are available on the slave. Each address consumes two RAM Bytes.