Last modified by Iris on 2026/03/30 11:47

From version 1.2
edited by Iris
on 2025/10/22 15:28
Change comment: There is no comment for this version
To version 3.1
edited by Iris
on 2025/10/22 15:32
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1664,3 +1664,244 @@
1664 1664  This protocol is fully compatible with Modbus RTU protocol, and the address is the same as the default address of Modbus RTU protocol of LX6V PLC.
1665 1665  
1666 1666  The extended function is mainly used to communicate with PLC Editor 2.
1667 +
1668 +== [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps2.png]][[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps3.png]]**10.7 Communication function block** ==
1669 +
1670 +=== [[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps4.png]]**1. SERIAL_MODBUS_WR** ===
1671 +
1672 +SERIAL_MODBUS_WR - Modbus master serial communication
1673 +
1674 +[[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps5.jpg]]
1675 +
1676 +This function block is the setting function block for sending protocol frames by the Modbus master station (whether RTU or ASCII). When the contact in front of Enable is turned ON, according to the communication port, station number, function code, slave station address, quantity and mapped data address set by the function block, the data frame is combined and sent.
1677 +
1678 +**Device used**
1679 +
1680 +|(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="24" %)**Device**|(((
1681 +**Offset**
1682 +
1683 +**Modification**
1684 +)))|(((
1685 +**Pulse**
1686 +
1687 +**Expansion**
1688 +)))
1689 +|**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**C(bit)**|**LC(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP**
1690 +|(% rowspan="15" %)(((
1691 +SERIAL
1692 +
1693 +MODBUS_WR
1694 +)))|Enable|●|●|●|●|●| | | | | | | | | | | | |●|●| | | | | | |
1695 +|CommunicationPort| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | |
1696 +|SlaveID| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | |
1697 +|FunctionCode| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | |
1698 +|SlaveAddress| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | |
1699 +|Count| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | |
1700 +|Data| | | | | | | | | | | | | | |●|●| | | | | | | | | |
1701 +|Done| |●|●|●|●| | | | | | | | | | | | | |●| | | | | | |
1702 +|Busy| |●|●|●|●| | | | | | | | | | | | | |●| | | | | | |
1703 +|InVelocity| |●|●|●|●| | | | | | | | | | | | | |●| | | | | | |
1704 +|Busy| |●|●|●|●| | | | | | | | | | | | | |●| | | | | | |
1705 +|Active| | | | | | | | | | | | | | |●|●| | | | | | | | | |
1706 +|CommandAborted|●|●|●|●|●| | | | | | | | | | | | |●|●| | | | | | |
1707 +|Error| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | |
1708 +|ErrorID| | | | | | | | | | | | |●|●|●|●|●| | | | | | | | |
1709 +
1710 +**Variable Type Used**
1711 +
1712 +|**Instruction**|(((
1713 +**Pin**
1714 +
1715 +**Type**
1716 +)))|**Parameter**|(((
1717 +**Variable**
1718 +
1719 +**Type**
1720 +)))|(((
1721 +**Can you**
1722 +
1723 +**Is empty**
1724 +)))|**Range**|**Description**
1725 +|(% rowspan="12" %)(((
1726 +SERIAL
1727 +
1728 +MODBUS_WR
1729 +)))|(% rowspan="7" %)Input|Enable|BOOL|No|TRUE/FALSE|Enable sending Modbus master serial communication data
1730 +|CommunicationPort|UINT|No|[0,1]|(((
1731 +Communication port
1732 +
1733 +0: Serial port 1
1734 +
1735 +1: Serial port 2
1736 +)))
1737 +|SlaveID|UINT|No|[0,255]|Station number of slave station
1738 +|FunctionCode|UINT|No|1/2/3/4/5/6/15/16|Function code
1739 +|SlaveAddress|UINT|No|[0,65535]|The slave address ( the address provided by the slave station) will read or write data from this address of the slave station.
1740 +|Count|UINT|No|-|(((
1741 +Number
1742 +
1743 +The number of Modbus reads or writes, and the unit is determined by the function code.
1744 +)))
1745 +|Data|ANY|No|-|The starting address for reading or writing data
1746 +|(% rowspan="5" %)Output|Done|BOOL|Yes|TRUE/FALSE|Instruction completed
1747 +|Busy|BOOL|Yes|TRUE/FALSE|Serial port busy
1748 +|Active|BOOL|Yes|TRUE/FALSE|Instruction working
1749 +|Error|BOOL|Yes|TRUE/FALSE|Error
1750 +|ErrorID|DWORD|Yes|Refer to ErrorID for details|Error code
1751 +
1752 +**Function**
1753 +
1754 +​Enable the MB_SERIAL function block to send the specified Modbus master serial communication data for reading from or writing to a slave station.
1755 +
1756 +**Notice**
1757 +
1758 +(1) If and only if the function block Enable is enabled, update the current serial communication instruction sending status;
1759 +
1760 +(2) If two or more serial port instructions use the same serial port in the scanning program, the corresponding serial port instructions will wait for the execution of the previous serial port instruction to be completed according to the instruction order, and then execute their own communication instructions;
1761 +
1762 +(3) If two or more serial port instructions use different serial ports in the scanning program, the corresponding serial port instructions will be executed in sequence according to the instruction order without affecting each other;
1763 +
1764 +(4) Busy means that the serial port is busing and Active means that the current instruction is being executed.
1765 +
1766 +**Modbus protocol**
1767 +
1768 +When the protocol is set to Modbus master protocol (whether RTU or ASCII). When the contact in front of the MB_SERIAL function block is ON, the MB_SERIAL function block will send a combined data frame at the designated communication port according to the station number, function code, slave station address, quantity, and data starting address.
1769 +
1770 +**Error code**
1771 +
1772 +|**Error code**|**Content**
1773 +|4084H|CommunicationPort input error (0: Serial port 1, 1: Serial port 2).
1774 +|408FH|The firmware does not support this instruction, and needs to be upgraded.
1775 +|4096H|The settings of Count and Data are outside the range of variables.
1776 +|3180H|COM2 reception error There may be interference on the communication cable, it is recommended to connect GND.
1777 +|3181H|COM2 data reception timeout. Check the wiring, whether the serial port parameter settings correspond to master and slave, and whether there is interference. Check whether it is caused by the late response from the slave station. It is recommended to increase the sending interval SD2546.
1778 +|3182H|COM2 CRC parity error. There may be interference on the communication cable, it is recommended to connect GND.
1779 +|3183H|COM2 LRC parity error. There may be interference on the communication cable, it is recommended to connect GND.
1780 +|3184H|The COM2 station number is configuration error Check the slave station number setting, and check whether there is any problem with the receiving and sending mechanism from slave station.
1781 +|3185H|COM2 send buffer overflow If this error message appears, please contact technical personnel.
1782 +|3186H|COM2 function code is error. Check whether the set function code is a function code supported by PLC.
1783 +|3187H|COM2 address error. Check whether the slave station has this address. (Please refer to Modbus exception 02)
1784 +|3188H|The length of COM2 is wrong. Check whether the communication length exceeds the length range specified by Modbus protocol or user-defined protocol.
1785 +|3189H|COM2 data error. Check whether parameters of the command are wrong. Check whether the set value is supported by the slave station. (Please refer to Modbus exception 03).
1786 +|318AH|COM2 slave station is busy. Slave station return information: Slave station is busy (Please refer to Modbus exception 06).
1787 +|318BH|COM2 slave station does not support function codes. Check whether this function code is supported by the slave station. (Please refer to Modbus exception 01)
1788 +|318CH|COM2 slave failure. Slave station return information: Slave station failure, please check whether the slave station fails. (Please refer to Modbus exception 04)
1789 +|318DH|COM2 slave station confirmation. Slave station return information: Slave confirmation (Please refer to Modbus exception 05)
1790 +|318EH|At present, COM2 does not support this command or function. When the slave protocol is set, the communication commands related to master station or master station functions cannot be used. Please change the protocol or close the contact in front of the corresponding command or close the corresponding communication function.
1791 +|318FH|COM2 sending timeout. If this error message appears, please contact technical personnel.
1792 +|31A0H|No available gateway for COM2 Slave station return information: Unavailable gateway (Please refer to Modbus exception 0A)
1793 +|31A1H|COM2 indicates that no response was obtained from the target device. Slave station return information: The device is not in the network. (Please refer to Modbus exception 0B)
1794 +
1795 +
1796 +**Example**
1797 +
1798 +**Application example**
1799 +
1800 +Set the COM2 communication parameters through the SD device.
1801 +
1802 +[[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps6.jpg]]
1803 +
1804 +Enable the function block and its Enable pin, send Modbus serial port master data and wait for the slave respond. Done indicates that the current instruction has been executed, Busy indicates that the serial port is busy, and Active indicates that the current instruction is running (waiting for data to be returned from the slave station).
1805 +
1806 +[[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps7.jpg]]
1807 +
1808 +
1809 +1. **SERIAL_WR**
1810 +
1811 +[[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps8.png]]SERIAL_WR - Custom protocol serial communication
1812 +
1813 +[[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps9.jpg]]
1814 +
1815 +This function block is a setting function block for user defined protocol serial port to send protocol frames. When the contact in front of Enable is turned ON. According to the communication port, sending data mapping address, sending data length, receiving data mapping address, and receiving data length set by the function block, the data frame is sent and waits for the data of the specified length to be returned.
1816 +
1817 +**Device used**
1818 +
1819 +|(% rowspan="2" %)**Instruction**|(% rowspan="2" %)**Parameter**|(% colspan="22" %)**Device**|(((
1820 +**Offset**
1821 +
1822 +**Modification**
1823 +)))|(((
1824 +**Pulse**
1825 +
1826 +**Expansion**
1827 +)))
1828 +|**X**|**Y**|**M**|**S**|**SM**|**T(bit)**|**HSC(bit)**|**D.b**|**KnX**|**KnY**|**KnM**|**KnS**|**T**|**C**|**D**|**R**|**SD**|**LC**|**HSC**|**K**|**H**|**E**|**[D]**|**XXP**
1829 +|(% rowspan="11" %)SERIAL_WR|Enable|●|●|●|●|●| | | | | | | | | | | | | | | | | | |
1830 +|CommunicationPort| | | | | | | | | | | | |●|●|●|●|●| | | | | | |
1831 +|SendData| | | | | | | | | | | | | | |●|●| | | | | | | |
1832 +|SendDataLength| | | | | | | | | | | | |●|●|●|●|●| | | | | | |
1833 +|ReceiveData| | | | | | | | | | | | | | |●|●| | | | | | | |
1834 +|ReceiveDataLength| | | | | | | | | | | | |●|●|●|●|●| | | | | | |
1835 +|Done| |●|●|●|●| | | | | | | | | | | | | | | | | | |
1836 +|Busy| |●|●|●|●| | | | | | | | | | | | | | | | | | |
1837 +|Active| |●|●|●|●| | | | | | | | | | | | | | | | | | |
1838 +|Error| |●|●|●|●| | | | | | | | | | | | | | | | | | |
1839 +|ErrorID| | | | | | | | | | | | | | |●|●| | | | | | | |
1840 +
1841 +**Variable Type Used**
1842 +
1843 +|**Instruction**|**Pin Type**|**Parameter**|**Variable Type**|**Can it be empty**|**Range**|**Description**
1844 +|(% rowspan="11" %)SERIAL_WR|(% rowspan="6" %)Input|Enable|BOOL|No|TRUE/FALSE|Enable sending protocol-less serial communication data
1845 +|CommunicationPort|UINT|No|[0,1]|Communication port, 0: Serial port 1, 1: Serial port 2
1846 +|SendData|ANY|No|-|Starting address for sending data
1847 +|SendDataLength|UINT|No|[0,523]|Send data length, in bytes
1848 +|ReceiveData|ANY|No|-|Starting address for receiving data
1849 +|ReceiveDataLength|UINT|No|[0,523]|Length of received data, in bytes
1850 +|(% rowspan="5" %)Output|Done|BOOL|Yes|TRUE/FALSE|Instruction completed
1851 +|Busy|BOOL|Yes|TRUE/FALSE|Serial port busy
1852 +|Active|BOOL|Yes|TRUE/FALSE|Instruction working
1853 +|Error|BOOL|Yes|TRUE/FALSE|Error
1854 +|ErrorID|DWORD|Yes|Refer to ErrorID for details|Error code
1855 +
1856 +**Function**
1857 +
1858 +* Enable the PROTOCOLLESS_SERIAL function block, which can send the serial communication data of the specified custom protocol master station and wait for the data return of the slave station.
1859 +
1860 +**Notice**
1861 +
1862 +* If and only if the function block Enable is enabled, updating the current serial communication instruction sending state;
1863 +* If two or more serial communication instructions are used simultaneously in the scanning program, the corresponding communication instructions are sequentially executed according to the instruction sequence;
1864 +* Busy indicates that the serial port is busy, and Active indicates that the current instruction is being executed.
1865 +
1866 +**User-defined protocol**
1867 +
1868 +When the protocol is set to a custom protocol. When the contact in front of the PROTOCOLLESS_SERIAL function block is ON,The PROTOCOLLESS_ SERIAL function block will send the data starting address and sending data length in the specified communication port to send the combined data frame, and wait for the data of the received data length to be filled in the received data starting address.
1869 +
1870 +* When the length of the transmitted data is set to 0, the mapping address of the transmitted data may not be filled in. At this time, the PROTOCOLLESS_SERIAL function block only receives data;
1871 +* When the received data length is set to 0, the received data mapping address may not be filled in. At this time, the PROTOCOLLESS_SERIAL function block only sends data.
1872 +
1873 +**Error code**
1874 +
1875 +|**Error code**|**Content**
1876 +|4084H|CommunicationPort input error (0: Serial port 1, 1: Serial port 2).
1877 +|5:|The setting of SendDataLength and SendData or ReceiveDataLength and ReceiveData is outside the scope of the variable.
1878 +|3181H|Data reception timeout
1879 +|318EH|(((
1880 +At present, COM2 does not support this command or function.
1881 +
1882 +When set to the slave protocol, the communication instructions related to the master station or the master station function cannot be used.
1883 +
1884 +Please change the protocol or close the contact in front of the corresponding command or close the corresponding communication function.
1885 +)))
1886 +|318FH|(((
1887 +COM2 data reception timeout.
1888 +
1889 +* Check wiring;
1890 +* Check whether the serial port parameter settings are master-slave corresponding;
1891 +* Check whether there is any interference;
1892 +* Check whether it is caused by the late response from the slave station.
1893 +
1894 +It is recommended to increase the sending interval SD2546.
1895 +)))
1896 +|3190H|COM2 receives data beyond the cache limit.
1897 +
1898 +
1899 +**Example**
1900 +
1901 +**Application example**
1902 +
1903 +* Set the COM2 communication parameters through the SD device.
1904 +
1905 +[[image:file:///C:\Users\Administrator\AppData\Local\Temp\ksohtml2512\wps10.jpg]]
1906 +
1907 +Enables the function block and the Enable pin of the function block, sends custom protocol data and waits for the slave to respond. Done indicates that the current instruction has been executed, Busy indicates that the serial port is busy, and Active indicates that the current instruction is running (waiting for data to be returned from the slave station).