Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

[modbus-binding] Errors when trying to access a SMA inverter #4927

Closed
Pirx99 opened this issue Dec 23, 2016 · 11 comments
Closed

[modbus-binding] Errors when trying to access a SMA inverter #4927

Pirx99 opened this issue Dec 23, 2016 · 11 comments

Comments

@Pirx99
Copy link

Pirx99 commented Dec 23, 2016

I'm using OH2 to read 2 different Modbus TCP devices.
First one, a heater is answering my requests without any problems. The Second, a SMA inverter cannot be read. When using the RMMS tool both devices are accessible. My conclusion is that the issue relies in the modbus binding.

Expected Behavior

the binding should return a value when I read a register. I expect to read the same values as RMMS can do (see the screenshot below)

Current Behavior

13:46:01.296 [ERROR] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (sma1) error getting response from slave
java.lang.ArrayIndexOutOfBoundsException

SMA definition in modbus.cfg

tcp.sma1.connection=192.168.178.3:502
tcp.sma1.type=input
tcp.sma1.id=3
tcp.sma1.start=785
tcp.sma1.length=1
tcp.sma1.valuetype=uint32

#item definition
Number SMA_DC1_ "AC-Spannung Phase 1 [%.1f V]" { modbus="sma1:0" }

#sitemap
Text item=SMA_DC1_

Possible Solution

My suspicion is that die Binding is struggling to resolve the Device ID, which must be "3" in this case

Steps to Reproduce (for bugs)

this will be hard to realize, as one would need a SMA inverter....

Context

Your Environment

OH2 Build 600,
Modbus binding 1.9.0
I'm attaching a screenshot from the tests done with RMMS. You can see the successfully read voltage values at +4 (239,76 V) +6 and +8 which correspond to the registers 30775, 30777 and 30779

pic1-rmms

@Pirx99
Copy link
Author

Pirx99 commented Dec 23, 2016

sorry, I'm using OH2 Build #660!

@ssalonen
Copy link
Contributor

You must read two registers, not one to parse single int32:

So this

tcp.sma1.length=1

Should be changed to 2

Please consult wiki for more details.

@Pirx99
Copy link
Author

Pirx99 commented Dec 23, 2016

Thanks. Changed to 2.
Now a value shows up, but it is wrong : 4294967040,0
I tried out 'uint32_swap' as well, just in case ... but it doesn't really help. I expect a value between 23800 and 24000. So something is still not OK !?

@Pirx99
Copy link
Author

Pirx99 commented Dec 23, 2016

Ok, I have I've got it now. This is a documentation bug, because it works when I provide the full register number:

tcp.sma1.start=30785

@ssalonen
Copy link
Contributor

Hi, great to hear you got it working!

So which documentation was faulty?

The binding passes the start parameter as is on the protocol level.

@Pirx99
Copy link
Author

Pirx99 commented Dec 23, 2016

Many tanks for your quick response as anytime :-)

Look at this statement in the documentation: "...For example, modbus slave definition with start=3, length=2 and type=holding will read modbus entities with the following numbers 40004 and 40005..."

In my case the register I'm reading is 30785 and I MUST enter "start=30785", otherwise it doesn't work. But the documentation is trying to tell me, a definition like start=784, length=2 and type=input will read 30785... which is not true....

@Pirx99
Copy link
Author

Pirx99 commented Dec 23, 2016

However, I'm very happy that it works now. It's like a Christmas gift.

I'm closing this is issue and wishing you all the best!

@Pirx99 Pirx99 closed this as completed Dec 23, 2016
@ssalonen
Copy link
Contributor

I think this might be related to the documentation of this particular device? Really, the start is passed as is to the protocol, see e.g.

http://www.simplymodbus.ca/FC04.htm

Please note that 30785 is perfectly valid address assuming the de facto addressing extension, see https://en.m.wikipedia.org/wiki/Modbus

input register numbers span from 300001 to 365536

So 30785 on the wire would correspond to input register 330785

Best
Sami

@Pirx99
Copy link
Author

Pirx99 commented Dec 23, 2016

no Sami, it has been a quote from https://github.com/openhab/openhab/wiki/Modbus-Binding

Best
Pirx

@ssalonen
Copy link
Contributor

Yeah I understood that but I'm just wondering if you are actually now reading "entity" with number 330785? But to my understanding the real address number that goes on the wire would be the given start number: 30785. You should be able to verify this with other tools such as pollmb.py or diagslave, for example.

Would it make it clearer if the documentation would use 400004 instead of 40004 (extra zero)?

Best
Sami

@Pirx99
Copy link
Author

Pirx99 commented Dec 24, 2016

Your first question is fair, but now I'm confused. I was thinking if one device documentation is referring to a holding register "4", then they mean the register 40004 (or sometimes 40005) which equals to entity number. Hence: "holding" and "4" make up the long-version "40004"
Another documentation is always using the long-version.
Furthermore, I was thinking a register or entity number cannot exceed 5 digits !?
Am I wrong?

... I know, this is now a conversation and should be moved elsewhere :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants