LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview 8 as modbus master help needed

Hello ! CAn some body help me with modbus. I have Labview 8 and I have downloaded NI Modbus.lib (MGIModbus).
I am trying to connect to a messung plc which supports modbus as slave. I am able to connect using a third party
demo software called modlink.
But when I want to use the NI Modbus MB Master Serial Example.vi I am not able to get any output
I am a bit new to Labview. I am developing a Vision application. I am ok with that. Only the commn. part troubles.
My requirement is quite simple.
The Messung has the following memory areas to be accessed
%MW2, %MW4, %MW6, %MW8
The corresponging Modbus holding registers are
40001, 40002, 40003, 40004

I am able to access the same with the modlink. I have to read and write into %MW4, %MW6 . The plc shall leave a value of 0 (decimal) in the variable.
Labview should read that and then write 1 into the same variable. Thats all.


But under labview, I am not able to get much out. Can someone pls modify the mb server example for me with 1 read and 1 write sample.
I can get a fair idea of the things if some one is grateful enough to help, pls add comments if you the time.
Thanks a lot in advance
NOTE: Serial settings : Mode RTU, Slave Address 1 , 9600, Odd, 8 Bit, 1 Stop

Pls help me.
Thanks

0 Kudos
Message 1 of 5
(3,295 Views)
Hello,
Could I get some more information from you? When you say you are not getting much from the LabVIEW example, what exactly do you mean? Also what variable are you referring to when you say "The plc shall leave a value of 0 (decimal) in the variable."? The example you are looking at already performs a write and a read, and you should be able to use that with some modification. Let me know the answers to the questions above, and I'll try to help out some more. Thanks!

Regards,

Ebele O.
National Instruments
0 Kudos
Message 2 of 5
(3,277 Views)
Hi !
At last a reply here. I was losing hope ! Thanks ! I am getting real desperate ! I had this tight delivery schedule. Thanks a lot
Pls donot bother the memory area of the plc. Let me explain why. First of all, there has been a  development. I am able to write to the registers of the plc. I used a Fatek...vi found elsewhere in this forum. It gave a good idea. Now I am able to write to the holding registers. I have to write a decimal number which is happening with that vi. (I have uploaded the original vi)
Now my problem is how to read a specific holding register. I am getting time outs.
Another problem is: When I close the vi the serial port does not get released. I have to close down labiew completely before another software can access that serial port. I found someone addressing this in another part of this forum http://forums.ni.com/ni/board/message?board.id=170&message.id=135694&query.id=44321#M135694
So if you help me by modifying the above vi which writes to holding register, to read from holding registers (read single holding register) I shall  be highly grateful.
Thanks a lot
Suresh

0 Kudos
Message 3 of 5
(3,268 Views)
I've done quite a bit of Modbus stuff with Labview, and generally, you leave out the 40000 from the register number.  If you need 40001, you just use 1 (at least in the apps I have written).  You also need to be careful with the difference between register and address.  I get them confused, but one of them starts counting at 0 and the other starts at 1.  If you start getting replies and your responses look "funny", try adding or subtracting 1 from your register number.
 
I've used Modscan with the devices I talk to, and if I remember correctly, the register number I use in Labview is usually 1 less than what I use in Modscan.
0 Kudos
Message 4 of 5
(3,265 Views)

Hi,

Most of the time I don't use the MB vi's in LV. I make them myself specific for my application. It's a bit more work but I have better control and view over the data in my situation.

In the zip there is a vi (MB.vi) that read the registers you mentioned and write back the one's. I it works you can use this as a start I think. There should be more error checking and you can make this VI useable for different application if you wire things to the outside world.

Let me know if it works

0 Kudos
Message 5 of 5
(3,253 Views)