Difference between revisions of "Component: Modbus Slave (Comms: System)"
Line 135: | Line 135: | ||
In Flowcode each section starts from 0 so the address range is as shown. | In Flowcode each section starts from 0 so the address range is as shown. | ||
+ | |||
+ | |||
Line 140: | Line 142: | ||
==Macro reference== | ==Macro reference== | ||
+ | ===ReadHoldingRegister=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 158: | Line 161: | ||
+ | ===SetCoil=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 181: | Line 185: | ||
+ | ===SetDigitalInput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 204: | Line 209: | ||
+ | ===SetSlaveAddress=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 222: | Line 228: | ||
+ | ===ChangeFrameType=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 240: | Line 247: | ||
+ | ===ReadCoils=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 263: | Line 271: | ||
+ | ===SetBaudRate=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 281: | Line 290: | ||
+ | ===SetHoldingRegister=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 304: | Line 314: | ||
+ | ===ReadAnalogInput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 322: | Line 333: | ||
+ | ===CheckForIncoming=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 335: | Line 347: | ||
+ | ===ChangeBaud=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 353: | Line 366: | ||
+ | ===ReadDigitalInputs=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 376: | Line 390: | ||
+ | ===GetLastIncoming=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 394: | Line 409: | ||
+ | ===SetAnalogInput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 417: | Line 433: | ||
+ | ===Initialise=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- |
Revision as of 11:51, 3 February 2023
Author | Matrix Ltd. |
Version | 2.0 |
Category | Comms: System |
Contents
Modbus Slave 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_ModbusSlave.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_ModbusSlave.fcfx
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
ReadHoldingRegister
ReadHoldingRegister | |
Reads the value of a single holding register. | |
- UINT | Address |
Coil Address | |
- UINT | 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 |
SetSlaveAddress
ChangeFrameType
ChangeFrameType | |
Default frame type is the type set in the component properties. | |
- BYTE | Type |
0 = Modbus RTU / 1 = Modbus ASCII | |
- VOID | Return |
ReadCoils
SetBaudRate
SetHoldingRegister
SetHoldingRegister | |
Sets the state of a single holding register. | |
- UINT | Address |
Coil Address | |
- UINT | Value |
Analogue Value range 0 - 65535 | |
- VOID | Return |
ReadAnalogInput
ReadAnalogInput | |
Reads the value of a single analogue input. | |
- UINT | Address |
Coil Address | |
- UINT | Return |
CheckForIncoming
ChangeBaud
ReadDigitalInputs
GetLastIncoming
SetAnalogInput
SetAnalogInput | |
Sets the state of a single analogue input. | |
- UINT | Address |
Coil Address | |
- UINT | Value |
Analogue Value range 0 - 65535 | |
- VOID | 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 |