|
|
Line 16: |
Line 16: |
| | | |
| ==Detailed description== | | ==Detailed description== |
| + | |
| + | |
| | | |
| ''No detailed description exists yet for this component'' | | ''No detailed description exists yet for this component'' |
| | | |
| ==Examples== | | ==Examples== |
| + | |
| + | |
| | | |
| | | |
Line 751: |
Line 755: |
| |- | | |- |
| | colspan="2" | Clears the MIAC display | | | colspan="2" | Clears the MIAC display |
| + | |- |
| + | |- |
| + | | 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;" | '''LCDClear''' |
| + | |- |
| + | | colspan="2" | Clears the LCD |
| |- | | |- |
| |- | | |- |
Revision as of 10:37, 17 November 2021
Author
|
Matrix Ltd.
|
Version
|
2.1
|
Category
|
Comms: System
|
Modbus TCP Master component
Modbus component for talking to Modbus compatible hardware via Ethernet or WIFI. Ensure TCP/IP or WIFI component is initialised and connected to a network before calling the ModbusMasterTCP component macros.
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.
Modbus TCP Master Example
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.
Modbus TCP Slave Example
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.
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
|
|
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.
|
- BYTE
|
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
|
|
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.
|
- BYTE
|
SlaveID
|
The ID of the MODBUS slave - Used for TCP to Serial forwarders
|
- 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=SlaveAddress, 1=FunctionCode/ExceptionCode, 2=DataBytes, 3=data0, 4=data1, ..
|
- BYTE
|
Return
|
|
ReadCoils
|
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
|
|
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
|
3=data0, 5=data1, 7=data2, ..
|
- UINT
|
Return
|
|
SetHoldingRegisters
|
This command writes the contents of several analogue output 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
|
|
SetHoldingRegister
|
This command writes the contents of a analogue output 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
|
|
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
|
|
SetTCPAddress
|
Sets the address of the remote TCP Slave that we wish to control.
|
- STRING
|
Address
|
e.g. "192.168.1.1"
|
- VOID
|
Return
|
|
ReadDigitalInputs
|
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
|
|
SetHoldingRegister
|
Sets the state of a single holding register.
|
- UINT
|
Address
|
Coil Address
|
- UINT
|
Value
|
Analogue Value range 0 - 65535
|
- VOID
|
Return
|
|
ReadAnalogInput
|
Reads the value of a single analogue input.
|
- UINT
|
Address
|
Coil Address
|
- UINT
|
Return
|
|
ReadDigitalInputs
|
Reads the state of a single digital input. 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
|
|
SetAnalogInput
|
Sets the state of a single analogue input.
|
- UINT
|
Address
|
Coil Address
|
- UINT
|
Value
|
Analogue Value range 0 - 65535
|
- VOID
|
Return
|
|
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.
|
[[File:]] -
|
Return
|
|
SetAnalogInput
|
Sets the state of a single analogue input.
|
- UINT
|
Address
|
Coil Address
|
- UINT
|
Value
|
Analogue Value range 0 - 65535
|
- VOID
|
Return
|
|
Initialise
|
Starts up the UART to allow communications and initialises the states of the various Modbus Coils, Inputs and Registers to 0.
|
- VOID
|
Return
|
|
Initialise
|
Initialises the MIDI component and sets up the UART.
|
- VOID
|
Return
|
|
ReadAnalogInput
|
Reads a single digital input.
|
- BYTE
|
Channel
|
|
- UINT
|
Return
|
|
CommsBaud
|
Sets the Baud rate of the alt communications channel
|
- BYTE
|
Baud
|
Range: 0-7 : 0=1200 / 7=115200
|
- VOID
|
Return
|
|
LCDOptions
|
Controls some of the LCD options
|
- BYTE
|
Foreground
|
Range: 0-1
|
- BYTE
|
Background
|
Range: 0-1
|
- BYTE
|
Transparent
|
Range: 0-1
|
- VOID
|
Return
|
|
LCDVerbose
|
Controls the Verbose mode. When enabled the LCD automatically displays an account of the incoming API commands and parameters. When switched off the LCD is free for the user to control as required.
|
- BYTE
|
Mode
|
Range: 0-1 : 0=Off or User Mode / 1=API Verbose Mode
|
- VOID
|
Return
|
|
ReadDigitalInput
|
Reads a single digital input.
|
- BYTE
|
Channel
|
|
- BYTE
|
Return
|
|
PWMConfig
|
Sets the PWM configuration. Channel = 0 - 1 : 0 = EN_AB, A, B / 1 = EN_CD, C, D Period = 0 - 65535 Scaler = 0 - 3 : 0=1:1 1=1:8 2=1:64 3=1:256
|
- BYTE
|
Channel
|
Range 0-1
|
- UINT
|
Period
|
Range: 0-65535
|
- BYTE
|
Scaler
|
Range: 0-3
|
- VOID
|
Return
|
|
PWMEnable
|
Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD
|
- BYTE
|
EnableMask
|
Range 0-63 or 0b00000 to 0b111111
|
- VOID
|
Return
|
|
PWMDuty
|
Sets a single PWM channel duty. Channel = 0 - 5 : 0=EN_AB, 1=A, 2=B, 3=C, 4=D, 5=EN_CD Duty = 0 - 65535
|
- BYTE
|
Channel
|
Range 0-5
|
- UINT
|
Duty
|
|
- VOID
|
Return
|
|
LCDCursor
|
Sets the cursor position for the MIAC display
|
- BYTE
|
X
|
Range: 0-21
|
- BYTE
|
Y
|
Range: 0-4
|
- VOID
|
Return
|
|
WriteTran
|
Allows a single transistor output to be switched on or off.
|
- BYTE
|
Channel
|
Range 1-4
|
- BYTE
|
Value
|
0 = Off, 1 = On
|
- VOID
|
Return
|
|
Initialise
|
|
- VOID
|
Return
|
|
LCDClear
|
Clears the MIAC display
|
- VOID
|
Return
|
|
LCDClear
|
Clears the LCD
|
- VOID
|
Return
|
Property reference
|
Properties
|
|
Network Comms Component
|
Redirects communications via the selected component allowing different TCP/IP modules with different macros to work.
|
|
Status
|
Shows the state of the network comms component to verify everything is configured correctly.
|
|
TCP/IP Port
|
Port used for network communications Range: 0-65535
|
|
Receive Buffer Size
|
Maximum number of bytes the receive buffer can hold
|
|
Receive Timeout
|
Maximum time to wait for network reply, in mS
|
|
Label
|
A text label to appear on the Modbus panel object.
|
|
Connections
|
|
Simulations
|