Component: Modbus Slave (Comms: System): Difference between revisions
m Text replacement - "class="wikitable" style="width:60%; background-color:#FFFFFF;"" to "class="mtx-class-macrotable wikitable"" |
m Text replacement - "width="10%" align="center" style="background-color:#D8C9D8;" align="center"" to "width="10%" align="center" class="mtx-class-macrohead"" |
||
| Line 145: | Line 145: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ChangeBaud''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ChangeBaud''' | ||
|- | |- | ||
| Line 164: | Line 164: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ChangeFrameType''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ChangeFrameType''' | ||
|- | |- | ||
| Line 183: | Line 183: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckForIncoming''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckForIncoming''' | ||
|- | |- | ||
| Line 197: | Line 197: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLastIncoming''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLastIncoming''' | ||
|- | |- | ||
| Line 216: | Line 216: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | ||
|- | |- | ||
| Line 230: | Line 230: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAnalogInput''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadAnalogInput''' | ||
|- | |- | ||
| Line 249: | Line 249: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadCoils''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadCoils''' | ||
|- | |- | ||
| Line 273: | Line 273: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadDigitalInputs''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadDigitalInputs''' | ||
|- | |- | ||
| Line 297: | Line 297: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadHoldingRegister''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadHoldingRegister''' | ||
|- | |- | ||
| Line 316: | Line 316: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetAnalogInput''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetAnalogInput''' | ||
|- | |- | ||
| Line 340: | Line 340: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetBaudRate''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetBaudRate''' | ||
|- | |- | ||
| Line 359: | Line 359: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetCoil''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetCoil''' | ||
|- | |- | ||
| Line 383: | Line 383: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetDigitalInput''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetDigitalInput''' | ||
|- | |- | ||
| Line 407: | Line 407: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetHoldingRegister''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetHoldingRegister''' | ||
|- | |- | ||
| Line 431: | Line 431: | ||
{| class="mtx-class-macrotable wikitable" | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSlaveAddress''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSlaveAddress''' | ||
|- | |- | ||
Revision as of 14:17, 13 July 2026
| Author | Matrix Ltd. |
| Version | 2.0 |
| Category | Comms: System |
Modbus Slave component
Modbus component for creating Modbus compatible slave hardware via RS232 or RS485.
Detailed description
No detailed description exists yet for this component
Examples
Example master program to control the slave. The example reads the 8 switches connected to PortD. If the switch values change then the new value is send to the slave.
Example slave program to react to the signals from the master. The example listens for Modbus commands from the master and outputs the current coils 0-7 state to eight LEDs connected to PortD.
Master and Slave example using vNet
Example of communicating using Modbus Master and Slave using two instances of Flowcode and the vNet injector component.
Addressing
In Modbus the addressing protocol looks like this.
| Data Type | Common name | Starting address | Ending Address | Flowcode Start Address | Flowcode End Address |
| Modbus Coils | Bits, binary values, flags | 00001 | 10000 | 0 | 9999 |
| Digital Inputs | Binary inputs | 10001 | 30000 | 0 | 19999 |
| Analog Inputs | Binary inputs | 30001 | 40000 | 0 | 9999 |
| Modbus Registers | Analog values, variables | 40001 | 60000 | 0 | 19999 |
In Flowcode each section starts from 0 so the address range is as shown.
Macro reference
ChangeBaud
ChangeFrameType
| ChangeFrameType | |
| Default frame type is the type set in the component properties. | |
| Type | |
| 0 = Modbus RTU / 1 = Modbus ASCII | |
| Return | |
CheckForIncoming
GetLastIncoming
Initialise
| Initialise | |
| Starts up the UART to allow communications and initialises the states of the various Modbus Coils, Inputs and Registers to 0. | |
| Return | |
ReadAnalogInput
| ReadAnalogInput | |
| Reads the value of a single analogue input. | |
| Address | |
| Coil Address | |
| Return | |
ReadCoils
ReadDigitalInputs
ReadHoldingRegister
| ReadHoldingRegister | |
| Reads the value of a single holding register. | |
| Address | |
| Coil Address | |
| Return | |
SetAnalogInput
| SetAnalogInput | |
| Sets the state of a single analogue input. | |
| Address | |
| Coil Address | |
| Value | |
| Analogue Value range 0 - 65535 | |
| Return | |
SetBaudRate
SetCoil
| SetCoil | |
| Sets the state of a single digital coil. | |
| Address | |
| Coil Address | |
| State | |
| 0=off, 1=on | |
| Return | |
SetDigitalInput
| SetDigitalInput | |
| Sets the state of a single digital input. | |
| Address | |
| Coil Address | |
| State | |
| 0=off, 1=on | |
| Return | |
SetHoldingRegister
| SetHoldingRegister | |
| Sets the state of a single holding register. | |
| Address | |
| Coil Address | |
| Value | |
| Analogue Value range 0 - 65535 | |
| Return | |
SetSlaveAddress
Property reference
Component Source Code
Please click here to download the component source project: FC_Comp_Source_ModbusSlave.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_ModbusSlave.fcfx