goburrow / modbus

Fault-tolerant implementation of modbus protocol in Go (golang)
BSD 3-Clause "New" or "Revised" License
925 stars 359 forks source link

How to not loose values or not read values twice (synchronisation) #52

Open ToM-MaS opened 4 years ago

ToM-MaS commented 4 years ago

The Energy meters made by www.janitza.de update their internal modbus registers every 0.2 seconds. When I poll these values each 0.2 seconds over TCP, I want to:

( https://www.janitza.de/betriebsanleitungen.html?file=files/download/manuals/current/UMG96RM/EL/Janitza-Manual-UMG96RM-EL-Modbus-adress-list-and-formulary-en.pdf )

Serhioromano commented 4 years ago

I understand what you mean, and this is not an answer to how to do that but rather suggestions.

From what you describe I understand that you want to calculate energy. I have to say that the method you've chosen is not used for that purpose. That one is more lime monitoring purposes. Imagine your request for some reason is longer than 0.2? First, you must use ticker to send requests, in that case, you can send a new request while you did not get a previous one. You must handle that. And what does connection lose for a minute? Then your data is not reliable. It is never reliable. Then what is the purpose to get data if you cannot reliably estimate it?

The solution on meter there is impulse output. For instance, one pulse is 100W. It is very hard to miss impulse. So, you use PLC and calculate impulses. You can also measure the time between impulses, and you can also show current consumption and other valuable and reliable data.