Difference between revisions of "Component: Modbus Slave USB (Comms: System)"
Line 142: | Line 142: | ||
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 148: | Line 150: | ||
==Macro reference== | ==Macro reference== | ||
+ | ===ReadHoldingRegister=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 166: | Line 169: | ||
+ | ===SetCoil=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 189: | Line 193: | ||
+ | ===SetDigitalInput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 212: | Line 217: | ||
+ | ===SetSlaveAddress=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 230: | Line 236: | ||
+ | ===ChangeFrameType=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 248: | Line 255: | ||
+ | ===ReadCoils=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 271: | Line 279: | ||
+ | ===SetHoldingRegister=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 294: | Line 303: | ||
+ | ===ReadAnalogInput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 312: | Line 322: | ||
+ | ===CheckForIncoming=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 325: | Line 336: | ||
+ | ===ReadDigitalInputs=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 348: | Line 360: | ||
+ | ===GetLastIncoming=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 366: | Line 379: | ||
+ | ===SetAnalogInput=== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
|- | |- | ||
Line 389: | Line 403: | ||
+ | ===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 USB component
Modbus component for creating Modbus compatible slave hardware via USB Serial.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_ModbusSlaveUSB.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_ModbusSlaveUSB.fcfx
Detailed description
No detailed description exists yet for this component
Examples
Example master program to control the slave. The example sets coil address 0, clears coil address 0, reads an input register and outputs to the LCD. Be sure to set the IP address of the slave device at the top of the program. If you are simulating then use the IP address of the PC running the Slave simulation. Both programs can be simulated on the same PC using two instances of Flowcode.
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 state to an LED connected to PortA. The input register is loaded with a value which is incremented on each Modbus transaction.
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. | |
![]() |
Address |
Coil Address | |
![]() |
Return |
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 |
SetSlaveAddress
ChangeFrameType
![]() |
ChangeFrameType |
Default frame type is the type set in the component properties. | |
![]() |
Type |
0 = Modbus RTU / 1 = Modbus ASCII | |
![]() |
Return |
ReadCoils
SetHoldingRegister
![]() |
SetHoldingRegister |
Sets the state of a single holding register. | |
![]() |
Address |
Coil Address | |
![]() |
Value |
Analogue Value range 0 - 65535 | |
![]() |
Return |
ReadAnalogInput
![]() |
ReadAnalogInput |
Reads the value of a single analogue input. | |
![]() |
Address |
Coil Address | |
![]() |
Return |
CheckForIncoming
ReadDigitalInputs
GetLastIncoming
SetAnalogInput
![]() |
SetAnalogInput |
Sets the state of a single analogue input. | |
![]() |
Address |
Coil Address | |
![]() |
Value |
Analogue Value range 0 - 65535 | |
![]() |
Return |
Initialise
![]() |
Initialise |
Starts up the UART to allow communications and initialises the states of the various Modbus Coils, Inputs and Registers to 0. Returns 1 if USB is started ok. | |
![]() |
Return |