Author Topic: read float from modbus driver  (Read 3892 times)

robkwan

  • Newbie
  • *
  • Posts: 44
    • View Profile
read float from modbus driver
« on: July 20, 2015, 11:53:23 AM »
I can't read float from the modbus driver. Also, can't get dataSubscriber2 to work with float either, tried "F30003.2", "F30003.1", no event.

Ex: modbusTCPCom1.Read("F30003") generates "Invalid Address F30003 - Input string was not in a correct format."

It writes float ok. Ex: modbusTCPCom1.Write("F40001", "0") works fine.

To work around, I have to read 30003 and 30004 and manually form the float.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: read float from modbus driver
« Reply #1 on: July 20, 2015, 07:25:24 PM »
The driver only supports "F4" addresses.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: read float from modbus driver
« Reply #2 on: August 28, 2015, 07:47:00 PM »
This will be implemented in version 3.99

Amro2003

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: read float from modbus driver
« Reply #3 on: October 30, 2016, 06:44:33 PM »
How I can use it in V3.99 ? is implemented ?

Amro2003

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: read float from modbus driver
« Reply #4 on: October 30, 2016, 06:47:50 PM »
I am using v3.99r now. I could not find how to display in floating point format

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: read float from modbus driver
« Reply #5 on: October 30, 2016, 07:24:45 PM »
I just did a quick test on this and it worked as expected:

- Add a BasicLabel to the form
- Set PLCAddressItem to F30001
- Run the application and the label shows a floating point value

Amro2003

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: read float from modbus driver
« Reply #6 on: October 31, 2016, 03:29:55 AM »
I bought "Basic Label Manual 2$" but it is explaining that I should add "F" to Modbus Input register address .
Is there any reference that explaining each property function?

I spent 2 days trying to convert the value that i get to IEEE 754 floating point number format (Real number).



Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: read float from modbus driver
« Reply #7 on: October 31, 2016, 11:29:37 AM »
Conversion is generally not necessary.

For as long as you have correct address in the PLCAddressValue property field (F40001 or F30001 or similar), the BasicLabel will display the floating-point value. If it doesn't display it then pull out the manual for your PLC and check the addressing scheme.

You can use specific format in the NumericFormat property field to have that value be displayed as you want to see it. More on the standard numeric formats you can read here:

https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx

Modbus should be storing floating-point values in two 16-bit integer registers. For example, the value of 12.35 will be stored as -26214 in the 1st register and 16709 in the 2nd register.

You can use MOD RSSim simulator program for testing to see these values.
« Last Edit: October 31, 2016, 11:39:55 AM by Godra »