LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI MODBUS 1.2 Dword ( U32 )

Solved!
Go to solution

Hi,

I'm trying to develop an application to communicate with a controller, for now I can read all the variables (bool / word / float for discretes input / coils / input Registers / holding Registers ) but for Dword the values are at 0, I assume that the library ( NI MODBUS 1.2 ) does not read the U32. How to make it able to read the DWord (u32) and is that there is not another version of this library that allows to do this.

 

cordially

 

 

 

0 Kudos
Message 1 of 9
(6,804 Views)

As MODBUS only knows about words, to get a 32 bit integer usually you read two input registers and combine them via the Join Numbers function

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 9
(6,794 Views)

Exactly, this is what I do with the floats, but the problem is when I read the value it is always 0, I tested with the NI OPC evaluation version it gives me the same value when I do word (U16) and when I chose Dword it works I can read the values.

0 Kudos
Message 3 of 9
(6,754 Views)

Please check if the word order of your salve and of your master are the same. Eventually the NI OPC modbus master mixes up the word (byte) oder for DWORD representation

Gernot Hanel
IONICON Analytik Gesellschaft m.b.H.
0 Kudos
Message 4 of 9
(6,741 Views)

A non-zero integer value remains non-zero in any byte order.

There must be a bug somewhere.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 9
(6,739 Views)

I agree but the fundamental question is what is written into the two 16bit modbus registers as plain data.

It is not clear what conversion is done by the NI OPC evaluation version.

 

To point this out I would suggest to build a minimal modbus master to see if the data are in the registers and then join the numbers as requested above.

 

You can use the sample master from the NI modbus library 1.1.5.39 to test this in detail.

Gernot Hanel
IONICON Analytik Gesellschaft m.b.H.
0 Kudos
Message 6 of 9
(6,734 Views)

I have already made a program for communication, I always have 0 like a value for Dword but the Floats work well Knowing that are also coded in 2 bytes.

In the vi MB Ethernet Transmit.VI, when I read a Dword  holding register  as single quantity and 35 like address, so the function code is 3 (holding registers) and the data array is (0/35/0/1). The message sent on the TCP is "0000 0000 0006 0003 0023 0001", and on reception I have the MB Ethernet Receive.VI which receive the information twice the first time to detect the size of the data ("0000 0000 0005 00" after conversion string to U8 and the join number we have the size to 4), finally to have Data "0302 0000" after conversion of String to modbus format  I have an array with these values 2/0/0  the register is a 0.

 

Do I have to modify the VI to make a request to the PLC in U32 format for DWORD? 

 

If you have an example that reads a DWORD registre I am interested .

 

0 Kudos
Message 7 of 9
(6,725 Views)
Solution
Accepted by topic author yeito

In this example, you are reading only one register (2 bytes). How you would get a 4 byte value from this?

You should read 2 registers (0/35/0/2) and combine them together into a single U32 integer.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 8 of 9
(6,719 Views)

Ah yes exactly, I did well reading the two registers for the floats but not for the Dword, It's good I rectified the error it works :). thanks for the help

0 Kudos
Message 9 of 9
(6,705 Views)