LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus Communication failure

Hi,

I am new to labview. I used Modbus session to write and read the holding registers of external device. There is no error but communication is failing randomly while reading holding register. Most oftenly when the value goes to 255. data received is 2 bytes hex value ( 1 higher bit and 1 lower bit). Any idea ?

0 Kudos
Message 1 of 7
(3,172 Views)

No idea because you didn't attach any VI to show us how you tried to communicate.

0 Kudos
Message 2 of 7
(3,141 Views)

Please find the attachment. 

The attached VI is based on the Plasmionique Modbus comm Tester VI. 

0 Kudos
Message 3 of 7
(3,125 Views)

I would try an NI version of the Modbus library rather than the Plasmionique.

 

I know NI's libraries work.  I don't have that Plasmionique  library to even be able to look into it to see if there is something different about it.

 

Instead of running your full application, test with something simpler that just opens, reads in a loop, and closes.  Don't even do all of that manipulation with the data.  Just see if you get consistent values that make sense.

 

That instruction manual you posted a picture of is a little suspect.  "8 pieces data bits"?  I'm guessing it is a translation to English from another language.  The table they show doesn't make sense because the way the first column talking about CRC low and high order bytes are misaligned with the 3rd column.  And what do they mean by the "flag bit" for the first data byte?  If the data is supposed to be a signed 16-bit integer, then you can typecast or unflatten the two bytes into an I16 without a whole lot of data manipulation.

 

 

0 Kudos
Message 4 of 7
(3,119 Views)

Thank you.

I would try in NI version of modbus library. Manual is little older and is in english language. The instrument is INSIZE Linear Gage ( http://www.insizeindia.in/linear-gage.html#linear-gage-and-display-unit ). column three is not misaligned, It indicates the inquiry command is lesser than the linear gage response.

Linear gage response is 

address code, function code, Number of data bytes : 4, 

1st byte : flag bit is 00(00) or FF (256) Which indicate the value is either positive or negative

2nd byte : Empty

3rd and 4th byte indicates the value of the linear movement. 

 

lastly, i will try typecast too...

 

0 Kudos
Message 5 of 7
(3,114 Views)

Yes.  It is in English now.  But I bet who ever originally wrote that manual didn't do it in English and whoever translated it didn't really understand English.  "Pieces of data bits" is not a phrase that any true English speaker would ever say or write.

 

 I don't know how you can say that first table looks aligned.  It looks like a mess to me.

 

com%20details-1

 

If the protocol is like you describe, then you can use typecast on the 3rd and 4th bytes.  (You might not even need that.  At worst you might just need to do a byte swap on the U16 for that register.)  Use the value of the 1st byte to set your sign.  All of the integer to string tp integer to string to double is just crazy.  (And if the values are integer, then the final conversion and indicators should be integers and not doubles.)

 

Below is what the code should look like.

linear%20gage-05-1_BD

 

 

Download All
Message 6 of 7
(3,109 Views)

Hi

I accept what you said, Manual may be translated. As I said earlier (I am new to labview ), I do not know modbus, databits etc.,.and  your code worked well. Thanks . . . 

0 Kudos
Message 7 of 7
(3,085 Views)