10-25-2023 10:46 AM
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.
Solved! Go to Solution.
10-25-2023 05:40 PM
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.
10-26-2023 07:08 AM
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.
10-26-2023 07:27 AM - edited 10-26-2023 07:28 AM
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?
10-26-2023 07:27 AM
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.
10-26-2023 07:48 AM
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.
10-26-2023 08:16 AM
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…
10-26-2023 09:19 AM
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.
10-27-2023 01:48 AM
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!
10-30-2023 07:51 AM
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.