Llisas Posted April 14, 2014 Report Share Posted April 14, 2014 Hi, first of all I want to say that I'm new to Labview, so I'm in the studying phase and I may have very basic questions. There's a tool that's basically a big screwdriver with a controller that can be programmed to make certain jobs using desired speed and torque, it's called Handy2000. You can save in different channels the configurations for the different jobs. The controller has its own software, and I can already connect to it and read/write with no problem using an ethernet cable. I was asked to make an interface in labview to select the channels, show in a graphic way (with photos of the electronic components) what screws correspond to that channel, and show when the steps of a job are done. All of this will be in a panel pc connected to the tool's controller. Since I'm new to labview and to the modbus protocol, I took some time to study the basics. I understand how the protocol works and the very basics of labview programming, so I have an idea of how the front panel will be and what things needs to be modified. But now it's time to start the implementation, and I'm a little lost on how to make the basic configuration to setup the connection and start writing the addresses on labview. By the way I don't have the DSC module, I only have to use the NI Modbus library. I already checked the example functions to use my pc as master and slave and watched the codes for the different type of data (coil, input, input register, holding register), but I don't know how I should start programming, and the most important thing is how to make some tests in the process to check that I'm having the communication between the pc and the controller. I already read in the forum and learned a lot, but failed to see as a completely newbie how to make and change the basic setups to make the thing work. So any help is welcome, specific answers about how to make the basic setup and how to test it, vi examples or basic tutorials to read. Thanks in advance, Stefan Christiansen p.s: I attached the manual that specifies the addresses for the modbus communication, so if you could give me an example of where I should change the address in the labview code and what should I put to make a basic read or write it would be very helpful Estic Touch Panel Comm. Spec _010-E_.pdf Quote Link to comment
Llisas Posted April 14, 2014 Author Report Share Posted April 14, 2014 I can't even know if it's connected right First I opened the Master Ethernet Example and the Slave Ethernet Example, and everything worked fine. Now I tried to do it connected with ethernet cable to the controller using the Master Ethernet Example, and set the "Remote IP Address" to the address of the controller (which I already tested with ping and the connection with my PC is fine, and also I have no problem reading and writing with the controller's software). And when I run it, I get the error 56. The error tells me that it happens at TCP Read in MB Ethernet receive.vi:5. I attached the photo of that vi. I really hope you can help, I need to establish the connection and being able to read/write at least something. Quote Link to comment
Tim_S Posted April 14, 2014 Report Share Posted April 14, 2014 Start with a TCP Open Connection followed by a TCP Close Connection (Modbus listens to port 502). If you can get that working, then stick the VI "MB Ethernet Master Query" in between the open and close. After that, you can put a while loop around the MB Ethernet Master Query. After that it is integrating the bit of code into your larger application. Quote Link to comment
Llisas Posted April 14, 2014 Author Report Share Posted April 14, 2014 I tested doing just the TCP Open Connection (with port 502 and the IP address of the controller) and TCP Close Connection, and it worked fine. But then I have problems when I enter the Ethernet Master Query. I also checked in the Master Ethernet Example I wanted to use, using the lightbulb troubleshooting feature, that the starting connection works fine, and the problem occurs when the read of discrete inputs starts. So my main problem is probably making the setup of that, with the addresses, the MBAP header, the Modbus command, etc . It would be great if someone could tell me the basic setup of addresses and that stuff according to the manual I attached previously, to for example read a single coil (let's say the signal "SET CH1"), so I can figure out the basics and then it would be just a matter of making the big code according to what I need. Quote Link to comment
Tim_S Posted April 15, 2014 Report Share Posted April 15, 2014 I've found the manuals for the Modbus addresses to be invariably wrong (I've even had a technical rep tell me this). The addresses may be correct internally, but externally they can be 1 or 2 addresses different from the published. I also have run into the address published needed x40000 added to it to work. I recommend contacting the equipment supplier and picking their brains about how their product works, and prepare to search around on your own. A little routine that checks for a known input pattern (e.g., bits 0, 2 and 3 are on and the rest are off) can help hunt-and-peck the correct address out. Quote Link to comment
Llisas Posted April 15, 2014 Author Report Share Posted April 15, 2014 (edited) Thanks a lot. I made a little vi to see if I could read some coils. Finally after changing some things it shows no errors. In the MBAP header it doesn't works if I set the Unit ID as 0, but with any other value it works fine. And the Transaction ID shows no problem if I leave it as 0 or change it to anything. And for the Starting Address, with anything below of 80 it shows an error, but from 80 and above it works. This could indicate that in fact the addresses in the manual are right, since for the coils the first address shown is 80 (the signal START). But the problem is that my indicators never turn on, even when I'm doing something that I know that my indicators should turn on. I don't know if I'm doing it right, but if you watch the attachment, I chose to read starting from address 80 and the next 7 addresses, and I put the indicators hoping that the first one should turn on when the START signal is ON, the last one to turn on when the DATA OUTPUT is ON, etc. That thinking is right or I'm doing it wrong? So before contacting the supplier, I would like to ask some simple questions about using the MB Master Query: 1) The numbers in the MBAP Header are relevant? What should I exactly put there? 2) The MB Master Query works as I thought? (the "Starting Address is the address of the first signal I want to read, and "Quantity" is how many signals right after the Starting Address I want to read? And those coils are individuals according to the signals and should turn on when certain signal is ON? By the way what you meant about the little routine with known input pattern is what I did? (for example having those 8 indicators and knowing that the first one should be on when I start the fastening and the last one to turn on is the fastening was ok?) *edit: Now I attempted reading some input registers. I used 8448 as the Starting Address and put Quantity 4, and that should should me the last fastening Year, month, day and hour. It still reads nothing. I tend to think that the address is right and the problem could be something else *edit2.0: I checked the same I did before about the addresses. The first address for input registers according to the manual is 512. If I put anything below that I get an error, but for my surprise when I put 512 as the starting address it reads something, but I have no idea what it means. In fact the addresses that reads are 513 and 515, which doesn't appear in the manual. Edited April 15, 2014 by Llisas Quote Link to comment
Llisas Posted April 15, 2014 Author Report Share Posted April 15, 2014 (edited) Finally I could read something that's right. I made a fastening and the last torque achieved was 0.55 I used 9472 as Starting Data, which corresponds to RESULT TRQ DATA1, and indeed it shows "55" So now I think that definitely the address stuff in the manual is weird and I should contact the supplier. Edited April 15, 2014 by Llisas 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.