Jump to content

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

From Flowcode Help
No edit summary
No edit summary
 
(14 intermediate revisions by the same user not shown)
Line 14: Line 14:
==Modbus Master (SCADA) component==
==Modbus Master (SCADA) component==
Modbus component for talking to Modbus compatible hardware via RS232 or RS485.  
Modbus component for talking to Modbus compatible hardware via RS232 or RS485.  
==Component Source Code==
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_Modbus_SCADA.fcsx FC_Comp_Source_Modbus_SCADA.fcsx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Modbus_SCADA.fcsx FC_Comp_Source_Modbus_SCADA.fcsx]


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


''No detailed description exists yet for this component''
''No detailed description exists yet for this component''


==Examples==
==Examples==




Line 25: Line 75:




==Downloadable 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" | 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. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | SlaveID
|-
| colspan="2" | The ID of the MODBUS slave 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegAddress
|-
| colspan="2" | Address: 0=40001, 1=40002, ... 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegCount
|-
| colspan="2" | Number of consecutive registers to read, starting from RegAddress 
|-
| 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;" | '''ReadCoil'''
|-
| colspan="2" | 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. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | SlaveID
|-
| colspan="2" | The ID of the MODBUS slave 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | CoilAddress
|-
| colspan="2" | Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ... 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | CoilCount
|-
| colspan="2" | Number of consecutive coils to try and read 
|-
| 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''
|}




==Macro reference==
===ChangeFrameType===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetCoil'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ChangeFrameType'''
|-
|-
| colspan="2" | 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. 
| 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%" | SlaveID
|-
| colspan="2" | The ID of the MODBUS slave 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | CoilAddress
|-
| colspan="2" | Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ... 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | CoilState
| 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-u8-icon.png]] - BYTE
| 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''
|}
|}




===GetResponse===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
Line 124: Line 120:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===GetResponseByte===
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetCoils'''
|-
| colspan="2" | 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. 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | SlaveID
|-
| colspan="2" | The ID of the MODBUS slave 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | CoilAddress
|-
| colspan="2" | Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ... 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | CoilCount
|-
| colspan="2" | Number of consecutive coils to try and read 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | CoilData
|-
| colspan="2" | An array of bytes each containing 8 1-bit coil values 
|-
| 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;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
Line 175: Line 139:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===GetResponseInt===
|-
| 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;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
Line 211: Line 158:




===Initialise===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetHoldingRegisters'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
|-
| colspan="2" | This command writes the contents of several 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. 
| colspan="2" | Starts up the UART to allow communications 
|-
|-
|-
|-
| 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%" | SlaveID
|-
| colspan="2" | The ID of the MODBUS slave 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegAddress
|-
| colspan="2" | Address: 0=40001, 1=40002, ... 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegCount
|-
| colspan="2" | Number of consecutive registers to write, starting from RegAddress 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegValue
|-
| colspan="2" | Array of values to send to the registers 
|-
| 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''
|}
|}




===ReadAnalogInput===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
Line 272: Line 201:




===ReadCoil===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetHoldingRegister'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadCoil'''
|-
|-
| colspan="2" | This command writes the contents of a holding register at the location RegAddress. Returns 0 for success, 1 for CRC fail and 255 for no reply. 
| colspan="2" | 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. 
|-
|-
|-
|-
Line 286: Line 216:
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegAddress
| width="90%" | CoilAddress
|-
|-
| colspan="2" | Address: 0=40001, 1=40002, ... 
| colspan="2" | Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ... 
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegValue
| width="90%" | CoilCount
|-
|-
| colspan="2" | Value to send to the selected register 
| colspan="2" | Number of consecutive coils to try and read 
|-
|-
| 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 300: Line 230:




===ReadDigitalInput===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
Line 328: Line 259:




===ReadHoldingRegister===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadHoldingRegister'''
|-
|-
| colspan="2" | Starts up the UART to allow communications 
| colspan="2" | 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. 
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" | SlaveID
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| colspan="2" | The ID of the MODBUS slave 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadByteFromBuffer'''
|-
|-
| colspan="2" | Reads a byte of data from the local sector buffer. Return = Data byte read from the local sector buffer.  
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegAddress
|-
|-
| colspan="2" | Address: 0=40001, 1=40002, ... 
|-
|-
| 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%" | RegCount
|-
|-
| colspan="2" | 0 - 511 - Contains the position of the byte to be read 
| colspan="2" | Number of consecutive registers to read, starting from RegAddress 
|-
|-
| 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 359: Line 288:




===SetCoil===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileLength'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetCoil'''
|-
|-
| colspan="2" | Returns the number of bytes in the current sector that are used by the current open file. Return = 512 - Sector is filled with file data Return < 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector&nbsp;
| colspan="2" | 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.&nbsp;
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -  
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" | SlaveID
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| colspan="2" | The ID of the MODBUS slave&nbsp;
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''OpenFile'''
|-
|-
| colspan="2" | Searches for and opens a file for reading or writing from within the current directory on the disk. Returns 0 for success.&nbsp;
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | CoilAddress
|-
|-
| colspan="2" | Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ...&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Filename
| width="90%" | CoilState
|-
|-
| colspan="2" | 8.3 filename of the file we are trying to open e.g. "file.txt"&nbsp;
| colspan="2" | 0=Off, 1=On&nbsp;
|-
|-
| 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 390: Line 317:




===SetCoils===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteFileSector'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetCoils'''
|-
|-
| colspan="2" | Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function. Return = 0 - File sector written successfully. Return > 0 - File sector write error&nbsp;
| colspan="2" | 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.&nbsp;
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" | SlaveID
|}
|-
 
| colspan="2" | The ID of the MODBUS slave&nbsp;
 
|-
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | CoilAddress
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| colspan="2" | Coil Address: 0=Coil1, 1=Coil2, 2=Coil3, ...&nbsp;
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetFileIndex'''
|-
|-
| colspan="2" | Sets the current file index and used to switch between several open file streams. Default = 0. &nbsp;
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | CoilCount
|-
|-
| colspan="2" | Number of consecutive coils to try and read&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | File_Index
| width="90%" | CoilData
|-
|-
| colspan="2" | File index ranges from 0 to (Max Concurrent Files - 1)&nbsp;
| colspan="2" | An array of bytes each containing 8 1-bit coil values&nbsp;
|-
|-
| 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-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




===SetHoldingRegister===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AppendStringToFile'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetHoldingRegister'''
|-
|-
| colspan="2" | Adds the contents of the data string parameter to the end of the currently open file. Returns 0 for success.&nbsp;
| colspan="2" | This command writes the contents of a holding register at the location RegAddress. Returns 0 for success, 1 for CRC fail and 255 for no reply.&nbsp;
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Data_String
| width="90%" | SlaveID
|-
|-
| colspan="2" | Data to append to the end of the file&nbsp;
| colspan="2" | The ID of the MODBUS slave&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" | RegAddress
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| colspan="2" | Address: 0=40001, 1=40002, ...&nbsp;
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadFileSize'''
|-
|-
| colspan="2" | Reads the entire size of the current file in bytes.&nbsp;
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegValue
|-
|-
| colspan="2" | Value to send to the selected register&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
| 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''
|}
|}




===SetHoldingRegisters===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTimeAndDate'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetHoldingRegisters'''
|-
|-
| colspan="2" | Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat&nbsp;
| colspan="2" | This command writes the contents of several 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.&nbsp;
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Time
| width="90%" | SlaveID
|-
|-
| colspan="2" | Sets the current Time in FAT Time format hhhhhmmmmmmsssss - S=Secs/2&nbsp;
| colspan="2" | The ID of the MODBUS slave&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Date
| width="90%" | RegAddress
|-
|-
| colspan="2" | Sets the current Date in FAT Date format yyyyyyymmmmddddd - Y=Years since 1980&nbsp;
| colspan="2" | Address: 0=40001, 1=40002, ...&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" | RegCount
|}
 
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| colspan="2" | Number of consecutive registers to write, starting from RegAddress&nbsp;
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
|-
| colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns 0 for success. &nbsp;
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | RegValue
|-
|-
| colspan="2" | Array of values to send to the registers&nbsp;
|-
|-
| 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
| 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" | Initialise the comms to the Arduino board ready for commands to be sent.&nbsp;
|-
|-
| 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''
|}




Line 509: Line 420:
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| 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
|-
|-
|-
|-
Line 540: Line 455:
|-
|-
| colspan="2" | Number of timeouts in a row to wait for until we decide the slave is not responding or finished responding to a message. Range: 0 - 255 0 = First Timeout Only 1 = First Timeout + 1 2 = First Timeout + 2&nbsp;
| colspan="2" | Number of timeouts in a row to wait for until we decide the slave is not responding or finished responding to a message. Range: 0 - 255 0 = First Timeout Only 1 = First Timeout + 1 2 = First Timeout + 2&nbsp;
|-
| 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="10%" align="center" | [[File:Fc9-type-10-icon.png]]
Line 575: Line 494:
|-
|-
| colspan="2" | COM port data rate in bits per second&nbsp;
| colspan="2" | COM port data rate in bits per second&nbsp;
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''
|-
|}
|}

Latest revision as of 13:12, 7 February 2023

Author Matrix TSL
Version 2.1
Category Comms: System


Modbus Master (SCADA) component

Modbus component for talking to Modbus compatible hardware via RS232 or RS485.

Component Source Code

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

Please click here to view the component source code (Beta): FC_Comp_Source_Modbus_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


GetResponse

GetResponse
Collects as much incoming data as possible and stored into the response buffer. The number of bytes received will be stored into location 0 of the response buffer. Return value indicates validity of incoming CRC. 0 = OK, 1 = CRC fail, 255 = No Data 
- BYTE Return


GetResponseByte

GetResponseByte
Reads a byte from the last received response. The Index parametes specifies which byte to read back.  
- BYTE Index
0=NumBytes, 1=SlaveAddress, 2=FunctionCode/ExceptionCode, 3=DataBytes, 4=data0, 5=data1, .. 
- BYTE Return


GetResponseInt

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
4=data0, 6=data1, 8=data2, .. 
- UINT Return


Initialise

Initialise
Starts up the UART to allow communications 
- VOID Return


ReadAnalogInput

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


ReadCoil

ReadCoil
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


ReadDigitalInput

ReadDigitalInput
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


ReadHoldingRegister

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

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. 
- UINT 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

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. 
- 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 CoilData
An array of bytes each containing 8 1-bit coil values 
- BYTE Return


SetHoldingRegister

SetHoldingRegister
This command writes the contents of a 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


SetHoldingRegisters

SetHoldingRegisters
This command writes the contents of several 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


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 
Slave ID Bytes
Number of bytes used when passing a slave ID, usually 1 but sometimes 2 
Silent Interval
Configures how much time to wait after each master modbus command before another command can be sent. A silent interval of 60ms minimum is required in order to guarentee successful reception of the next transmission. 0=No Delay 60 = 60mS - Default Range : 0 - 65535 
UART Receive Timeout
Amount of time to wait before timing out when listening for a slave's response. Range: 0 - 255. 0 = Don't Wait 1 - 254 = X ms 255 = Wait Forever 
Receive Timeout Count
Number of timeouts in a row to wait for until we decide the slave is not responding or finished responding to a message. Range: 0 - 255 0 = First Timeout Only 1 = First Timeout + 1 2 = First Timeout + 2 
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