How to use Modbus communication in LabVIEW

Source: Internet
Author: User

main software:
Major software releases:
2010
Major Software revision:N/A
Minor software:LabVIEW Development Systems>>labview Professional Development System

Questions:(1) What is Modbus communication protocol? (2) What software should be installed in LabVIEW for Modbus communication? (3) A question frequently asked by customers: in my understanding, the address form of Modbus should be 40202,... So, but the address inside NI seems to be all 6-bit? (4) How to realize modbus communication in LabVIEW? (5) When running Modbus installer, error 1550 "Invalid license", how to resolve?

Answer:(1)     Modbus was invented in 1979 by Modicon (now a brand of Schneider Electric), the First Bus protocol in the world to be truly used for industrial sites. In NI's products, Modbus is mainly used to realize the communication of PLC. The simplest way to communicate with LabVIEW and PLC is in two ways: Modbus or NI OPC Server. The former requires a plc to install the Modbus module, the latter requires a specific PLC device support to ensure normal connection, http://zone.ni.com/devzone/cda/tut/p/id/10857 URL for the OPC server supported device list. In the realization aspect, the physical interface of the Modbus realization Way has the Ethernet and the serial port two kinds, in the LabVIEW programming also obtains the embodiment.   (2)     need to install LabVIEW datalogging and supervisory Control module,ni The official website can now only search DSC-2011 and DSC-8.6 Module download, customers can click to download, will be the last change to 2010 to download version 2010.   (3)     Modbus address is a numeric value that contains a data type and an offset of 6 characters. The two characters on the left determine the data type, and the four characters to the right are the ordinal numbers in that data type. The 40001~4xxxx described by the customer is the Modbus address used by the US Modicon Company and GE plc, which is based on the 1 address, which is the first address of the homogeneous component 1. The Modbus address of Siemens PLC is based on the 0 address. The Modbus address in the United States is the 2nd digit to indicate the type of component, for example, the Modbus address of i0.0 is 010001. Because the data type is already included in the function code, the Modbus address of Siemens's i0.0 is actually 000000,i2.0 's modbus address of 000016 (or hexadecimal number 16#0010) instead of 010017. At some point, the latter 4 bits of the Modbus address are marked as biased. At this point, a 0 may be added between the first and second bits, causing the 5-bit address to become 6 bits. For example, if you are advised to use address 40001 and a register communication in your user manual, you can use 400001来 to communicate with it in LabVIEW DSC or on the Modbus I/O server.   (4)     How to create a modbus I/O Server first? The steps are as follows: First, create a new project, named "ModbusServer ". Then create a new I/O server by selecting "I/O Server" in the new one, as shown in Figure 1.

Figure 1 Creating a new I/O Server  Then select "Modbus", set up "Modbus Server", see Figure 2.

Figure 2 Modbus Server  If you need to establish Ethernet communication, you can select "Modbus Ethernet" in the dialog box below. Set the required configuration information, IP address if it is the local set to 127.0.0.1. Here the customer may have a question: how to set the Modbus port in DSC, why only the IP address number and no port number? The answer here is that the default port number under DSC is 502, and the user is not allowed to configure under DSC. Customers can refer to the NI official online "MODBUS Libraries for LabVIEW" Free Library, which provides examples for further configuration.

Figure 3 Modbus Server  The next step is to create the Modbus register address, which is the constraint variable. In the constraint variable, select "Add Scope" to add the required number of constraint variables, the corresponding number of constraint variables will be created in the I/O server, corresponding to the 6-bit modbus address, see Figure 4. Then, in the New VI, drag the constraint variable into the. At this point, Modbus server is created. Next, in order to verify that the communication is successful, you can use the example "Modbus Simulator", as shown in Figure 5. In Figure 5, can be seen through the Modbus protocol modbus server constraint variable 000001 can control the Modbus simulator in the indicator display red, and Modbus The simulator constraint variable 400001 turntable can control 400001 controls in Modbus server.

Figure 4 Creating a constraint variable   Figure 5 Communication between Modbus Simulator and Modbus server  Next is how to create the Modbus I/o slave? The problem arises from the need to establish the "Modbus Simulator" in the paradigm itself. The example of "Modbus Simulator" is actually a "Modbus Slave", the creation steps are as follows: The previous steps are the same as "Modbus server", just select "Modbus Slave" after I/O server is created, 6. In the slave address setting, the configuration needs to be the same as the server communication address, set to 1, as shown in Figure 7. The next way to create the constraint variable is the same as "Modbus Server", the final communication effect is shown in Figure 8.

Figure 6 Modbus Slave   Figure 7 Modbus slave address settings   Figure 8 Communication between Modbus slave and Modbus server  (5) This error occurs because a LabVIEW executable that uses a DSC module and an I/O server is run on a computer that does not have DSC Run-time system installed. Unlike LabVIEW, the DSC module requires a separate run license to allow you to install the DSC run-time System on other computers. Once you have purchased the license and installed the Run-time system on the target computer, the error will disappear.

How to use Modbus communication in LabVIEW

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.