Abel_Souza Posted April 5, 2018 Report Share Posted April 5, 2018 LabVIEW 2016 Modbus Communication with a PLC Siemens SIMATIC ET 200SP Windows 7 Ultimate Hi, When I run my code it return error 66 at Read Holding Registers function. I ran this code as a VI on the development virtual machine and as a *.exe on real machine, but received the same error. Try in another computer and receive the same error. As PLC code was developer by other programmer I ask him if this communication was working on his machine, he showed me a LAbVIEW code running with Modbus communication with the same PLC. He was using a LabVIEW 2013 with old Modbus Library, but I had taken his code and ran on my PC with LV 2016 and receive the same error on MB Ethernet MAster Query Read Holding Registers(Poly).vi. Also generate an exe file and run on my real machine and still receiving error 66. In all scenarios I can ping PLC and receive answers, but cannot read or write any data with LabVIEW. First picture is my code with LV 2016 VIs. Second picture is error message. Third one is the other programmer code with old Modbus Library. On the first code, if I remove Read Holding Registers VI and connct wires directly or put a property node to set any property it runs without errors. If change this function for any other modbus function return error 66. Any idea what I am doing wrong? Thanks in advance! ni_support.zip Comunicação CLP.vi Main_MB_2.vi Quote Link to comment
Francois Normandin Posted April 5, 2018 Report Share Posted April 5, 2018 Have you tried shifting your register address by 1? Depending on the library you use, it might not shift it automatically. Holding register addresses range from 40001-49999. (The library will prepend the 4xxxx to your register address) Quote Link to comment
smithd Posted April 6, 2018 Report Share Posted April 6, 2018 (edited) Both libraries use zero indexing, so you should be able to use the same value for starting register and number of registers in both libraries. The 4xxxx (or 4xx,xxx) is not important at the protocol level. Its difficult verify whats going on because one function has a bunch of constants and the other is dynamic, but I'm assuming when your coworker tested it you've verified that: They have the same IP address and port you have They are using the same holding register start address and length They are hitting the button to make sure it actually reads the holding register rather than skipping that code If I'm understanding correctly, you ran the old code on your machine as well, and it failed? It sounds to me like the PLC has some sort of access control list, and your coworker added his machine to the list, but yours is not on it. This would make the most sense to me given that: His machine works and yours doesn't with identical code and settings The connection is being closed by the PLC The closure appears to be immediate (note that the error occurs at the "write" function, which is the very first TCP function called after connecting. This would indicate that the connection is opened and then closed before you even enter the while loop). Edited April 6, 2018 by smithd 1 Quote Link to comment
Abel_Souza Posted April 6, 2018 Author Report Share Posted April 6, 2018 Talking with my coworkers, this PLC don't have an access control list. Code working if a use two PCs and modbus examples on LabVIEW as a modbus server. When Ido this I can read with my code. Cheking with Wireshark, with PLC, the communication was disconnected before transfer any modbus packet. When running with two PCs I could see modbus packets on wireshark. My challage is how identify what cause this disconnection. Quote Link to comment
Abel_Souza Posted April 12, 2018 Author Report Share Posted April 12, 2018 My coworkers told me that this PLC did not have access authorization, but we need input PC IP on PLC to communicate, so it have access authorization setting. Now using IP setting configured on PLC its working well. Thanks! 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.