From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need a little modbus TCP help

Solved!
Go to solution
Solution
Accepted by topic author _Faust

Are you seeing any changes in the analog output when you measure it with a multimeter?

 

Are you sure you are writing/reading to the correct register?

Message 11 of 46
(2,740 Views)

The system is proven to work, I have previously used Beckhoff's own software (Twincat), from that I have made an activeX link which I could read/write from from labview.

This rather slow and their software doesnt work on 64 bit so thats why I switched to modbus. So to answer if I measure with a multimeter, no, but it works from Twincat.

 

To answer the second, no, It is probably not the correct register and I think I will just try to write from 800 up to 8FF (their documentation says those are the analog out registers) to be sure

Ive had all registers.

 

According to Beckhoff their numbering is from left to right, starting with digitals then all the analogs. Does numbering restart for the analog modules and does it matter

whether its an in- or output analog? I also have a PT100 temperature sensor module attached. It reports correct temperatures as far as I can see until I start writing analog outs :D, then it reports weird values.

 

I

 

 

 

0 Kudos
Message 12 of 46
(2,733 Views)

Ok things are working now. For everybody thats using Wago or Beckhoff with modbus:

 

All their analog modules -in or out, also PT100 sensors- are by default configured as 'complex'

This means every channel has 2 registers, the first one is status, the second is the actual value.

 

All modules on your fieldbus get a number of registers from left to right when it is powered on. Digitals have their own numbering.

 

In my case I had first 4 analog input signals and a 2xpt10. This resulted in the standard offset of 2048 +13 to be the register for the first analog output value.

 

Thanks again ravens fan for the help!!

 

0 Kudos
Message 13 of 46
(2,707 Views)

You're welcome.  I'm happy to hear you got it working and glad to be able to help.

0 Kudos
Message 14 of 46
(2,700 Views)

Hey folks,

 

I know this thread is ~2years old, but I am running into the same error using modebus to talk to an Acromag DIO ethernet device and I'm hoping you guys are subscribed still to this thread...

 

I have two Acromags, one is a 96ch IO and the other a 16ch.  I am told the modbus interface protocol (which I have little experience with) is exactly the same other than a num-of-channels indicator).

 

The code and modbus vis I have in place work great for the 96ch, however when I attempt to initialize and check the connection between my software and the 16ch I get Modbus error 6002 (which you mentioned is illegal address).  The 16ch is powered, connected and pings just fine from my laptop.

 

I searched the document linked in one of the earlier replies, but did not get any results for "illegal address"...   

 

googling a bit I did find:

 

"The data address received in the query is not an allowable address for the slave. More specifically, the combination of reference number and transfer length is invalid. For a controller with 100 registers, a request with offset 96 and length 4 would succeed, a request with offset 96 and length 5 will generate exception 02."

@http://www.simplymodbus.ca/exceptions.htm

 

This seems to suggest that there is something within the code I was given has the "data addess" sized improperly (which makes sense)... I guess at this point I'm just posting here for the record haha ... hopefully I'll find my answer in quick hunt for whatever constant is wired to "data address"... wish me luck

 

thanks


 

 

0 Kudos
Message 15 of 46
(2,401 Views)

If you have a list of modbus addresses to read and write, I can help you. I am an expert on Modbus; have been using it succesfully for over 2 years. Great and easy

Message 16 of 46
(2,398 Views)

I had just founnd my issue- turns out there was a type-def'd control that needed a default value changed.  

 

I was given a driver and didn't get to develop my own, so I'm still kind of clueless on modbus- I would love to get down into the modbus vis to understand them, but as usual I don't have time as of now.  

 

But if you don't mind a noob asking questions: When you refer to modbus "addresses" to read/write are you referring to IP addresses? or is Modbus and Modbus "over TCPIP" two different applications of modbus?  

 

Also, I've always wondering about interfacing LV with standard PLCs like the AB or Siemens resources that use modbus- is this what you use it for?  What's it like?

 

Thanks!

0 Kudos
Message 17 of 46
(2,395 Views)

Modbus addresses generally refer to the register where a piece of data is stored.  For example 40001,  30001, 10004, ....  The first number indicates the type of register it is: holding register, input register, coil, ...

 

Another important address is the slave address which is a single byte number to identify different slaves from each other on the same bus.  The number might be from 0 to 255, but 0 is generally reserved for the master (or possibly a broadcast message, I can't remember).  And I think generally the highest numbers aren't used.  So a valid range might be from 1 to 247. 

 

And of course you are aware of the IP address which should only come into play when you are dealing with Modbus over TCP/IP.  I have actually never used that.  All of my modbus devices are strictly serial.

 

For more information on modbus, look at http://www.modbus.org/tech.php.

Message 18 of 46
(2,393 Views)

You are writing wrong register. Labview starts numbering registers at 0, some documentation does not.

Try to write 1 register lower (2047).

 

That you can write it  and read it means you ahve succesfully written the command.
 
Does the documentation show how the setpoint has to be written? A lot of the modbus instruments I use take sometimes single precision floats as setpoint, these have to be written over 2 registers.

 

Let me know if it works

 

 

EDIT: I see someone has already suggested the same thing, sorry didnt read carefully

Message 19 of 46
(2,387 Views)

If you would like to try Modbus TCP or RTU on LV I would recommend the NI Modbus Library.  I'm a noob to Modbus as well and it's been working well for me (and it's free) and the examples are pretty straight forward.  Also the address input in the NI MB-library VIs make things very easy the only thing that is tricky at all is when converting the data into an actual readable number requires knowing how many bytes/words are in that address and switching the high and the low bits from the output array. 

Message 20 of 46
(2,372 Views)