10-31-2023 06:14 AM
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
Solved! Go to Solution.
10-31-2023 06:37 AM
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…
10-31-2023 06:44 AM
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.
10-31-2023 07:32 AM
@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.
10-31-2023 08:54 AM
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.
11-01-2023 11:51 PM
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.
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
11-02-2023 02:54 AM
Cast the Single value to an array of U16 (or I16).
11-02-2023 03:07 AM