LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PLC not reading real data through Modbus TCP/IP

Solved!
Go to solution

 

 

I am trying to write the single/double data type from LabVIEW through Modbus TCP/IP, but i am not able to read the same on my PLC (Scheider PLC HVAC M172) program.

Can anyone suggest which data type I have to use to write real data to PLC (Data type in PLC register are Real). I am having this issue only with real data type, and for integer data types it works fine.

 

Attached are some pictures for reference.

Regards,

Holas

0 Kudos
Message 1 of 8
(1,976 Views)

Hi Holas,

 


@Holas1505 wrote:

Can anyone suggest which data type I have to use to write real data to PLC (Data type in PLC register are Real). I am having this issue only with real data type, and for integer data types it works fine.


"Real" in a PLC typically means SGL in LabVIEW: I would NOT use DBL datatype…

Best regards,
GerdW


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

I have already tried SGL. But it is not working, when I check that data in PLC it show very small value around 0.000084(I try to write 60 in PLC through LabVIEW but it show 0.000084 in PLC). I am not able to understand the why this is happing.

0 Kudos
Message 3 of 8
(1,951 Views)

@Holas1505 wrote:

I have already tried SGL. But it is not working, when I check that data in PLC it show very small value around 0.000084(I try to write 60 in PLC through LabVIEW but it show 0.000084 in PLC). I am not able to understand the why this is happing.


Unfortunately Schneider requires a user account to access their manual so you will need to provide the eyeballs for reading it.  However,  every time I have ever written a holding register over MODBUS I had to read the manual and find the scale and offset to convert the 16 bits sent across the serial physical layer, (and held in the physical memory of the PLC) to or from floating point.  PLCs do not have floating point coprocessors so you generally take a huge hit on processing time to do floating point math and an off-the-shelf solution, such as you HVAC controller, would be unlikely to make direct use of a float.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 8
(1,935 Views)

There are two ways how Modbus devices handle floating point values.

 

1) As JbB explains, they could use a single 16-bit integer that is then scaled to floating point number with a scale and offset. The scale and offset is device and often also channel specific.

 

2) The other way is to use 2 adjacent 16-bit register that are interpreted as a single 4-byte floating point number, usually but not necessarily according to the IEEE-754 floating point standard.

 

Type 1) requires the scale and offset constants for a particular value from the manual. This can sometimes depend on the value of another register which for instance defines the range, such as 0-10V, 0-1V corresponding to the 0-65535 value range of an unsigned integer.

 

Type 2) has a little complication since there exist Big Endian and Little Endian data models in computer tech. Which of the two your device uses often depends on the CPU it internally uses, but can also depend on a particular preference of the company or the original programmer for that device.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 8
(1,924 Views)

Thanks Rolf and All,

 

2) The other way is to use 2 adjacent 16-bit register that are interpreted as a single 4-byte floating point number, usually but not necessarily according to the IEEE-754 floating point standard.

 

I have used this concept wrote the following code and i am getting the data.

 

Holas1505_0-1698900531305.png

Can anyone help to do the opposite of this code, i want to write the Real floating data and want to convert it to

the two 16-bit integer value.

 

Thanks,

holas

0 Kudos
Message 6 of 8
(1,852 Views)
Solution
Accepted by topic author Holas1505

Cast the Single value to an array of U16 (or I16).

 

example.png

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 8
(1,823 Views)
Solution
Accepted by topic author Holas1505

There are several ways, including for the conversion to a float.

 

Modbus Float.png

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 8
(1,817 Views)