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: 

modbus-example for receive

This gets weirder and weirder...

 

If I attempt extracting one register at a time(quantity=1), I get what I want (even if in a crazy format, but it's there, and I can get it out), BUT echo is still there...

 

...so LV extracts and decodes the registers even with the echo present, but ONLY for a registry at a time...

 

My question is 'why?' ...I reckon tha's supposted to work for quantities larger than 1...

 

 

 this is all for now,

 

Adrian

Message Edited by clohars on 11-20-2009 10:45 AM
0 Kudos
Message 11 of 15
(1,181 Views)

Question:

 

What version of the NI modbus library are you using?  I've been using V1.1 for a couple years.  But I think a newer version has come out since then.  I'm not sure what differences there are between the two.

 

What command/function code do you use for multiple registers and what do you use for a single register?

 

Looking in MB Serial String to Modbus Data Unit, it takes the incoming string strips off the first two bytes (slave address and function) and the last two bytes(CRC).  Then typecasts what is left a U16 array.  With the echoed data, you still have the original request present (the array and a CRC) and then the response (slave address, function code, and data with the final CRC stripped off).  So the original data request, CRC, response slave address and function code, are all getting typecast as well and would show up in the U8 array of data but wouldn't be real data.  Later in MB Decode Data, it is typecast into a U16 array.  The real data may show up in the array later on, or may turn out to be mismatched if there are an odd number of bytes among the "extra" information that isn't stripped at the end of the echoed query and the beginning of the real response.  But I'm not sure why one register vs. multiple registers would change that because they should be using the same function code.

0 Kudos
Message 12 of 15
(1,170 Views)

It's 1.2.1 from http://sine.ni.com/devzone/cda/epd/p/id/4756.

 

And when I say it doesn't work for quantities larger than 1, I mean that for 3 register, for examples, the VI runs continuosly until it 'times out'. For a single register it returns back information right away.

 

I use the 'Read Holding Registers' command (code 03, like one can see from the packages I've shown in previous posts).

 

I've tested the MB Serial String to Modbus Data Unit with packages I already checked (seen the 'stripping' happenning too), so I agree with your analisys. But still I don't understand why it's not working for several 'quantities' (registers).

 

Do you think it's possible to get in touch with the guy that wrote this library? It's a lot to ask, but one never knows.

 

 

Adrian

 

0 Kudos
Message 13 of 15
(1,153 Views)

I don't know if this is the place to ask this as well, but is there a way of transforming ASCII coded information into real data in LV?... cause this is what I read from the registers.

 

I would like to avoid having to implement a full ASCII table using a 'case'  function os something alike 🙂

 

thanks in advance for any answer,

 

Adrian

Message Edited by clohars on 11-24-2009 05:21 AM
0 Kudos
Message 14 of 15
(1,141 Views)
On the numeric >>  data conversion palette, there are two functions  "byte array to string" and "string to byte array".  Those are ones that are equivalent to ASC() and CHR$() in Basic.  The conversion from characters to the ASCII values.  The TypeCast function in the numeric >> data manipulation palette can also do this, and also work with more complicated data structures like converting 2 bytes into an I16 or U16,  8 bytes into a double floating point,  and other manipulations.
Message 15 of 15
(1,133 Views)