LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading power values via serial Modbus RTU power meter (slave) at LabView

Hi all 🙂

I'm kinda new to computer communications and also Modbus. It took me already a month already and still couldn't make it work. After whole other problems that were solved, now I'm dealing with a (probably simple) problem of reading holding registers correctly, and it drives me nuts. I have a power meter (SIMEAS P50 by Siemens) connected to an 3-phase electrical heater. The device has its own parametrization programme and I can read the values from there. So I assume there is no issue about the connection and the configuration of SIMEAS P50. However, I need to read the active power usage in LabView. I'm trying to use ModBus library for this, since I don't have the DSC module. I'm using the small exemplary vi that I made to read out holding registers. I think I only get the initial part of the response from the device. The value shown is always "Register Address X 256". The rest is not visible. I couldn't even come to this post's level: https://forums.ni.com/t5/LabVIEW/modbus-example-for-receive/td-p/1015357.  What am I missing here?

 

-I've tried all different supported communication protocols Modbus ASCII and IEC 60870-5-103, but I have the same issue.

 - I have tried all Modbus examples on internet and they all give the same issue.

 

I use LabView 2011.

 

I'd very much appreciate your help.

Kind regards,

Kaya

0 Kudos
Message 1 of 25
(6,395 Views)

changing the quantity might help

bp
0 Kudos
Message 2 of 25
(6,370 Views)

The vi in itself has no errors and is probably working, provided that you input the correct serial settings, base address and quantity, which I don't know.

The real issue is how the power usage is supposed to be encoded in the register values. I don't understand your claim <<The value shown is always "Register Address X 256">>. You are probably reading a bunch of U16 values (two bytes unsigned integers), one for each register. What's the number of registers you are reading? What are their read values? How they should be interpreted (usually to be found in the power meter documentation, but can be guessed in simple cases)?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 25
(6,365 Views)

Thank you for your replies!

@bharathp1, which quantity do you mean?

 

The addresses and the serial settings should be fine, since I can read the power values at the SIMEAS software. By the way, I also do not forget to close that (or any other) program that might interfere with the serial port. I make it sure that the serial port is free.

 

I mean, in the Modbus manual of the SIMEAS P50, the address for the "Active power" is 40233. So I type 232 for Starting address (drop the 4xx and subtract 1 since the addresses start from 0). And the value I get is, 232 x 256 = 59392. If I type for example 201, I get 201 X 256 = 51456. If I type 1, I get 256... As far as I can see from the thread I mentioned at the first thread, it is normal that the holding registers start with "Address X 256". However the part of the holding register that contains the necessary information does not show up. Moreover, as default the registers should be in float format.

 

I need to read only one register (even if I try reading multiple consecutive registers, it will still show the first one anyway). I am now running on 57.21 kW, for example. And the shown value 59392 has nothing to do with it.

Download All
0 Kudos
Message 4 of 25
(6,356 Views)

The manual says the active power data is stored in two 16 bit registers(40233&40234). I don't think reading 232 is correct. Try to read the mentioned address and extract the data as given in the manual(40233and 7bits from 40234 will represent mantissa and the rest represent exponent and last bit from 40234 will indicate sign ). And why you're skipping 40 in the starting while reading. 

bp
0 Kudos
Message 5 of 25
(6,343 Views)

So you get always a single register value which is a sort of echo of the register address, whatever quantity you require.

This sounds similar (although not identical) to the problem of the quoted thread. However it is not normal to get such a value.

In the other thread, the problem was that the RS-232/RS-485 converter was configured to receive an echo of the sent command before the answer. The NI Modbus vi, however, are not able to filter out the echo, so the returned data were indeed parto of the command and not the answer.

Are you using RS485 too? If the problem is the same, you should get an answer also when the device is disconnected.

Moreover, as bharathp10 already pointed out, you need to read two consecutive registers and combine them together by means of the Join Numbers function: a float value is 4 bytes long, while a single register is 2 bytes as I said before.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 25
(6,331 Views)

I'm using RS485 indeed. I tried if the echoing occurs even the cable is unplugged, and the MB Serial Init won't initialize. So I kept the cable connected.

I updated the vi according to your advice and now it performs two consecutive Read Holding Registers (I did like this since the "Quantity" won't have any effect) with two consecutive addresses. I join them with Join Numbers. I don't see any logical explanation of the resulting number (it is neither an order of both joined numbers nor 256). It definitely does not look like the 4 byte float as described. You can see both numbers and the resulting number from the probes I placed.

Dropping the 40's at the beginning is something I saw in various NI threads about Modbus. Many people said that the initials are offset numbers to indicate the holding registers etc. I personally do not understand why, and also nothing like this is indicated in the manual. However the issue is still there whether I write 40233 or 233, with just different numbers (different orders of 256)

Download All
0 Kudos
Message 7 of 25
(6,314 Views)

You need to fix the read before. Try the vi with the cable connected and the meter turned off, stopping the while structure with a button instead of the error wire. See what happens.

Once you can read properly, it's not needed to read two times; just set Quantity=2, extract the two returned values from the array, Join the numbers, Type Cast the result to a Single (SGL) numeric value and throw it into a Single Precision indicator.

 

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

This is your vi modified.

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

Thanks a lot for the vi update Paolo, I really appreciate it!

- I tried it with the cable connected and device turned off, and the Read Holding Registers give a timeout error. The MB Serial Init proceeds further as before.

- I turned the device back on and now I'm getting a different power value now (7,10543E-15) for the register address 40232. When I consider the given float formula to calculate the measured value, this number still won't make any sense. I know that at the moment the power reading should be sth like 57 W (I wrote kW before but it was mistyped).

0 Kudos
Message 10 of 25
(6,294 Views)