LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus over serial

Solved!
Go to solution

    I have been using GModbus over serial for a decade now without issue but I have run into licensing issues since Saphire is no longer part of the NI team.  I am now trying to use the NI Modbus tool but I am getting bad data back from my instrument which is a Watlow temperature controller.  I chose to use similar programming as I did with GModbus and have tried various methods but I still get bad data from the instrument.  I am thinking that I may not be converting it properly or not applying the tool correctly and it would be great if I had a second pair of eyes to look at it and see what I am doing wrong.  Any help would be appreciated.

0 Kudos
Message 1 of 11
(1,328 Views)

Since Modbus transmits data in u16 units you should read two inputs and type cast to single or read four inputs and cast to double, depending on the actually transmitted data. That works if the transmitted data is big endian.

For transmitting data, you can flatten to string in big endian format and typecast the output to a u16 array.

 

snip.png

0 Kudos
Message 2 of 11
(1,281 Views)

Thank you for your response and I gave that a try and I still got the same results that I did with the previous code in that I am getting bad numbers back from the Watlow which is reading room temperature (2.66E-314).  I am connecting to the instrument and I do not get any errors back on execution just the bad numbers. 

0 Kudos
Message 3 of 11
(1,240 Views)
Solution
Accepted by topic author teslac

Hi teslac,

 


@teslac wrote:

I am getting bad numbers back from the Watlow which is reading room temperature (2.66E-314). 


Are you sure you want to read DBL values?

Modbus devices typically handle floats as SGL - and your 2.66E-314 is a clear DBL value…

 

See these conversions:

The upper conversion uses a DBL value, the lower a SGL value! (All strings in hex display mode.)

 

Which "raw" data do you receive? Can you show the received string/byte array?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(1,233 Views)

And how are you reading the registres ? 

What number are you using ? 

Remember that for the NI modbus, the registres start at 0 as the first, even if the supplier has a 1 as first registre. 

0 Kudos
Message 5 of 11
(1,231 Views)

Single precision will work for our application since we will need to read back the temperature and write the set point with two decimal places.  I have attached the BD and the FP which shows the register outputs in U16.

Download All
0 Kudos
Message 6 of 11
(1,222 Views)

Hi teslac,

 


@teslac wrote:

Single precision will work for our application since we will need to read back the temperature and write the set point with two decimal places.  I have attached the BD and the FP which shows the register outputs in U16.


So you read a single U16 value from Watlow, convert that into a string (of 2 bytes) and typecast those 2 bytes into a DBL value of 8 bytes: does that sound correct to you?

 

Can you show the definition of that temperature value in a Watlow manual? That is the information you need (to provide) to be able to correctly convert the data…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 11
(1,206 Views)

In my first go at the NI tool I took the U16 array and indexed it and then joined the number (hi/low) and then type cast them to SGL to report the temperature.  This is how I did it with GModBus which was successful.  The manual is not forthcoming with the definition of temperature value other than it is set on the Modbus output as hi/low.

0 Kudos
Message 8 of 11
(1,192 Views)

Hi teslac,

 


@teslac wrote:

In my first go at the NI tool I took the U16 array and indexed it and then joined the number (hi/low) and then type cast them to SGL to report the temperature. 


Your sentence and your image describe different things!

In the image you typecast to DBL - which is wrong as explained before!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 11
(1,167 Views)

I was able to get the information on the data format from Watlow and their response was it is IEEE 754 and is 32 bit floating format.

0 Kudos
Message 10 of 11
(1,138 Views)