Modbus openHAB2 binding available for alpha testing

There is no difference between adresses on binding level - all are passed as is on the line.

Depending on the source, different numbers are used to refer to same thing. See https://github.com/ssalonen/openhab2-addons/blob/modbus-openhab2-native-binding/addons/binding/org.openhab.binding.modbus/README.md#comment-on-addressing

It’s a matter of understanding what the real address is… In the worst case (when it’s not clear) you try out different alternatives and see which one produces the value you want.

For example, in your case input register at 30773 might mean entity number 30773 which translates to 772 entity address (with entity type of input register). Binding uses entity addresses.

Or, it’s possible that it refers to entity address of 30773. After all, it does fit into range limitation of entity address (quoting Wikipedia)

Entity address is the starting address, a 16-bit value in the data part of the Modbus frame. As such its range goes from 0 to 65,535

What is worse, some use entity address + 1 (first address would be then 1, not zero). For example, the program modpoll uses one-based addressing.

So it’s possible your 30773 refers to entity address 30772.

This the general problem: the “number” alone does not tell what is really meant. A bit like talking about money (9.99) without specifying currency (eur? Usd?).

Best
Sami

I think that’s the case. Because when I try using binding version 2, M221 PLC not responding to any input from openHAB. But with version 1, the PLC respond to input from openHAB.

I don’t know if it’s really not compatible with M221 PLC or there is something wrong in things configuration. But I’m using the configuration that you make in this thread.

Thanks,

Randi

If you can share your v1 configuration (items, modbus.cfg) and v2 configuration (items, things), I might be able to help.

Please also explain what command is not working, so I can try it out

Best
Sami

I tried today converting my modbus V1 configuration to the new binding, only worked when i configured things in paperui.
V1 config,modbus.cfg:

poll=100
#Uitgangen P24-55
serial.slave1.connection=/dev/ttyUSB-1000:115200:8:none:1:rtu:35:500:none:none
serial.slave1.type=coil
serial.slave1.id=1
serial.slave1.start=24
serial.slave1.length=32

#Merkers
serial.slave2.connection=/dev/ttyUSB-1000:115200:8:none:1:rtu:35:500:none:none
serial.slave2.type=coil
serial.slave2.id=1
serial.slave2.start=4096
serial.slave2.length=10

items file sample:

Switch Light_GF_Keuken_Plafond  	"Keuken hoofd" 		<light>	(GF_Keuken, Lights) 	{modbus="slave1:0"}
Switch Blindering_N_Up				"Blindering_NU"			(FF_Niels) {modbus="slave2:2"}

new config things file:

Bridge modbus:serial:cubloc [ port="/dev/ttyUSB-1000", baud=115200, id=1, stopBits="1", parity="none", dataBits=8, echo=false, encoding="rtu", flowControlIn="none", flowControlOut="none", receiveTimeoutMillis=500, timeBetweenTransactionsMillis=35 ] {
	Bridge poller coils [ start=24, length=32, refresh=100, type="coil" ] {
		Bridge data P24 [ readStart="24", readValueType="bit", writeStart="24", writeValueType="bit", writeType="coil" ]
    }    
}

In New Item file:

Switch Light_GF_Keuken_Plafond  	"Keuken hoofd" 		<light>	(GF_Keuken, Lights) 	{channel="modbus:data:P24:switch"}

this does not work.
if i configure the things in paperui i can get stuff working. But don’t want to do things like that. can someone help me.
Thanks Jan

found the problem some typo’s
works great now :slight_smile:

Sorry for the late reply sir. I was testing the configuration for a few days to make sure it’s working.

here the V1 configuration:
modbus.cfg

poll=500

tcp.slave2.connection=192.168.0.105
tcp.slave2.type=coil
tcp.slave2.start=0
tcp.slave2.length=9

tcp.slave3.connection=192.168.0.105
tcp.slave3.type=holding
tcp.slave3.start=0
tcp.slave3.length=9

version1.items

Switch digital1 "Digital 1 [%d]" {modbus="slave2:0"}
Switch digital2 "Digital 2 [%d]" {modbus="slave2:1"}
Switch digital3 "Digital 3 [%d]" {modbus="slave2:2"}
Switch digital4 "Digital 4 [%d]" {modbus="slave2:3"}
Switch digital5 "Digital 5 [%d]" {modbus="slave2:4"}
Switch digital6 "Digital 6 [%d]" {modbus="slave2:5"}
Switch digital7 "Digital 7 [%d]" {modbus="slave2:6"}
Switch digital8 "Digital 8 [%d]" {modbus="slave2:7"}
Switch digital9 "Digital 9 [%d]" {modbus="slave2:8"}

Number analog1 "Analog 1 [%.0f]" {modbus="slave3:0"}
Number analog2 "Analog 2 [%.0f]" {modbus="slave3:1"}
Number analog3 "Analog 3 [%.0f]" {modbus="slave3:2"}
Number analog4 "Analog 4 [%.0f]" {modbus="slave3:3"}
Number analog5 "Analog 5 [%.0f]" {modbus="slave3:4"}
Number analog6 "Analog 6 [%.0f]" {modbus="slave3:5"}
Number analog7 "Analog 7 [%.0f]" {modbus="slave3:6"}
Number analog8 "Analog 8 [%.0f]" {modbus="slave3:7"}
Number analog9 "Analog 9 [%.0f]" {modbus="slave3:8"}

and here is for the V2 configuration:
onsite.things

Bridge modbus:tcp:localhostTCP [ host="192.168.0.105", port=502, id=1 ]
{
    Bridge poller coils [ start=0, length=9, refresh=500, type="coil" ]
		{
        Thing data digital1 [ readStart="0", readValueType="bit", writeStart="0", writeValueType="bit", writeType="coil" ]
		Thing data digital2	[ readStart="1", readValueType="bit", writeStart="1", writeValueType="bit", writeType="coil" ]
		Thing data digital3	[ readStart="2", readValueType="bit", writeStart="2", writeValueType="bit", writeType="coil" ]
		Thing data digital4	[ readStart="3", readValueType="bit", writeStart="3", writeValueType="bit", writeType="coil" ]
		Thing data digital5	[ readStart="4", readValueType="bit", writeStart="4", writeValueType="bit", writeType="coil" ]
		Thing data digital6	[ readStart="5", readValueType="bit", writeStart="5", writeValueType="bit", writeType="coil" ]
		Thing data digital7	[ readStart="6", readValueType="bit", writeStart="6", writeValueType="bit", writeType="coil" ]
		Thing data digital8	[ readStart="7", readValueType="bit", writeStart="7", writeValueType="bit", writeType="coil" ]
		Thing data digital9	[ readStart="8", readValueType="bit", writeStart="8", writeValueType="bit", writeType="coil" ]
		}
		
		Bridge poller coils [ start=0, length=9, refresh=500, type="holding" ]
		{
        Thing data analog1 	[ readStart="0", readValueType="float32", writeStart="0", writeValueType="float32", writeType="holding" ]
		Thing data analog2	[ readStart="1", readValueType="float32", writeStart="1", writeValueType="float32", writeType="holding" ]
		Thing data analog3	[ readStart="2", readValueType="float32", writeStart="2", writeValueType="float32", writeType="holding" ]
		Thing data analog4	[ readStart="3", readValueType="float32", writeStart="3", writeValueType="float32", writeType="holding" ]
		Thing data analog5	[ readStart="4", readValueType="float32", writeStart="4", writeValueType="float32", writeType="holding" ]
		Thing data analog6	[ readStart="5", readValueType="float32", writeStart="5", writeValueType="float32", writeType="holding" ]
		Thing data analog7	[ readStart="6", readValueType="float32", writeStart="6", writeValueType="float32", writeType="holding" ]
		Thing data analog8	[ readStart="7", readValueType="float32", writeStart="7", writeValueType="float32", writeType="holding" ]
		Thing data analog9	[ readStart="8", readValueType="float32", writeStart="8", writeValueType="float32", writeType="holding" ]
		}
}

onsite.items

Switch digital1		   		  "Digital 1 [%d]"			{ channel="modbus:data:localhostTCP:coils:digital1:switch" }
Switch digital2		   		  "Digital 2 [%d]"			{ channel="modbus:data:localhostTCP:coils:digital2:switch" }
Switch digital3		   		  "Digital 3 [%d]"			{ channel="modbus:data:localhostTCP:coils:digital3:switch" }
Switch digital4		   		  "Digital 4 [%d]"			{ channel="modbus:data:localhostTCP:coils:digital4:switch" }
Switch digital5		   		  "Digital 5 [%d]"			{ channel="modbus:data:localhostTCP:coils:digital5:switch" }
Switch digital6		   		  "Digital 6 [%d]"			{ channel="modbus:data:localhostTCP:coils:digital6:switch" }
Switch digital7		   		  "Digital 7 [%d]"			{ channel="modbus:data:localhostTCP:coils:digital7:switch" }
Switch digital8		   		  "Digital 8 [%d]"			{ channel="modbus:data:localhostTCP:coils:digital8:switch" }
Switch digital9		   		  "Digital 9 [%d]"			{ channel="modbus:data:localhostTCP:coils:digital9:switch" }

Number analog1				  "Analog 1 [%.1f]"			{channel="modbus:data:localhostTCP:holding:analog1:number" }
Number analog2				  "Analog 2 [%.1f]"			{channel="modbus:data:localhostTCP:holding:analog2:number" }
Number analog3				  "Analog 3 [%.1f]"			{channel="modbus:data:localhostTCP:holding:analog3:number" }
Number analog4				  "Analog 4 [%.1f]"			{channel="modbus:data:localhostTCP:holding:analog4:number" }
Number analog5				  "Analog 5 [%.1f]"			{channel="modbus:data:localhostTCP:holding:analog5:number" }
Number analog6				  "Analog 6 [%.1f]"			{channel="modbus:data:localhostTCP:holding:analog6:number" }
Number analog7				  "Analog 7 [%.1f]"			{channel="modbus:data:localhostTCP:holding:analog7:number" }
Number analog8				  "Analog 8 [%.1f]"			{channel="modbus:data:localhostTCP:holding:analog8:number" }
Number analog9				  "Analog 9 [%.1f]"			{channel="modbus:data:localhostTCP:holding:analog9:number" }

Any command’s not working for the v2 configuration.

Hope this can help.

Thanks,

Randi

Can you have the same name for both pollers?

/Mike

1 Like

You are correct! Same name is not good and the whole file is parsed wrong by openHAB I think. It came up earlier in this thread…

Also, there is something with the analog things:

  • new configuration tries to read two consecutive registers as 32 bit float. Old configuration did not have value type set so by default it reads individual registers as integers.
  • new configuration tries to interpret overlapping registers from the data, that is, registers 0&1 form the first float, registers 1&2 the next etc. I think this does not make sense. Check documentation on read start and addressing differences between versions with 32 bit value types. And please check if you really want to have this over parsing individual registers (see above).
  • item configuration refers to nonexistent Poller named “holding”. Probably related to the accidentally having the same name “coils” with both pollers

Best
Sami

Installed this and it worked perfect on a Rasberry PI 3 BUT after a while i had to stop it depending on consuming to much CPU. I read 40 values each minute.

When i instead get the values each minute with http get and parse them in a rule i have no problem with CPU.

my things

Bridge modbus:tcp:myheatpump [ host="192.168.192.68", port=502, id=1 ]
{
	Bridge poller values [ start=1, length=97, refresh=0, type="holding" ]
		{
        Thing data nibe1 	[ readStart="1", readValueType="int16" ]
        Thing data nibe2 	[ readStart="2", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe3 	[ readStart="3", readValueType="int16", writeStart="3", writeValueType="int16", writeType="holding" ]
        Thing data nibe4 	[ readStart="4", readValueType="int16", writeStart="4", writeValueType="int16", writeType="holding" ]
        Thing data nibe5 	[ readStart="5", readValueType="int16", writeStart="5", writeValueType="int16", writeType="holding" ]
        Thing data nibe6 	[ readStart="6", readValueType="int16", writeStart="6", writeValueType="int16", writeType="holding" ]
        Thing data nibe7 	[ readStart="7", readValueType="int16", writeStart="7", writeValueType="int16", writeType="holding" ]
        Thing data nibe8 	[ readStart="8", readValueType="int16" ]
        Thing data nibe9 	[ readStart="9", readValueType="uint16" ]
        Thing data nibe10 	[ readStart="10", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe11 	[ readStart="11", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe12 	[ readStart="12", readValueType="int16", writeStart="12", writeValueType="int16", writeType="holding" ]
        Thing data nibe13 	[ readStart="13", readValueType="int16", writeStart="13", writeValueType="int16", writeType="holding" ]
        Thing data nibe14 	[ readStart="14", readValueType="int16", writeStart="14", writeValueType="int16", writeType="holding" ]
        Thing data nibe15 	[ readStart="15", readValueType="int16", writeStart="15", writeValueType="int16", writeType="holding" ]
        Thing data nibe16 	[ readStart="16", readValueType="int16", writeStart="16", writeValueType="int16", writeType="holding" ]
        Thing data nibe17 	[ readStart="17", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe18 	[ readStart="18", readValueType="int16", writeStart="18", writeValueType="int16", writeType="holding" ]
        Thing data nibe19 	[ readStart="19", readValueType="int16" ]
        Thing data nibe20 	[ readStart="20", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe21 	[ readStart="21", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe22 	[ readStart="22", readValueType="int16", writeStart="22", writeValueType="int16", writeType="holding" ]
        Thing data nibe23 	[ readStart="23", readValueType="int16", writeStart="23", writeValueType="int16", writeType="holding" ]
        Thing data nibe24 	[ readStart="24", readValueType="int16", writeStart="24", writeValueType="int16", writeType="holding" ]
        Thing data nibe25 	[ readStart="25", readValueType="int16", writeStart="25", writeValueType="int16", writeType="holding" ]
        Thing data nibe26 	[ readStart="26", readValueType="int16", writeStart="26", writeValueType="int16", writeType="holding" ]
        Thing data nibe27 	[ readStart="27", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe28 	[ readStart="28", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe29 	[ readStart="29", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe30 	[ readStart="30", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe31 	[ readStart="31", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe32 	[ readStart="32", readValueType="uint16" ]
        Thing data nibe33 	[ readStart="33", readValueType="int16" ]
        Thing data nibe34 	[ readStart="34", readValueType="uint16" ]
        Thing data nibe35 	[ readStart="35", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe36 	[ readStart="36", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe37 	[ readStart="37", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe38 	[ readStart="38", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe39 	[ readStart="39", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe40 	[ readStart="40", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe41 	[ readStart="41", readValueType="int16", writeStart="41", writeValueType="int16", writeType="holding" ]
        Thing data nibe42 	[ readStart="42", readValueType="int16", writeStart="42", writeValueType="int16", writeType="holding" ]
        Thing data nibe43 	[ readStart="43", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe44 	[ readStart="44", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe45 	[ readStart="45", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe46 	[ readStart="46", readValueType="int16" ]
        Thing data nibe47 	[ readStart="47", readValueType="uint16" ]
        Thing data nibe48 	[ readStart="48", readValueType="int16", writeStart="48", writeValueType="int16", writeType="holding" ]
        Thing data nibe49 	[ readStart="49", readValueType="int16", writeStart="49", writeValueType="int16", writeType="holding" ]
        Thing data nibe50 	[ readStart="50", readValueType="int16", writeStart="50", writeValueType="int16", writeType="holding" ]
        Thing data nibe51 	[ readStart="51", readValueType="int16", readTransform="JS(mbussub1.js)", writeStart="51", writeValueType="int16", writeTransform="JS(mbusadd1.js)", writeType="holding" ]
        Thing data nibe52 	[ readStart="52", readValueType="int16", writeStart="52", writeValueType="int16", writeType="holding" ]
        Thing data nibe53 	[ readStart="53", readValueType="int16", writeStart="53", writeValueType="int16", writeType="holding" ]
        Thing data nibe54 	[ readStart="54", readValueType="int16", writeStart="54", writeValueType="int16", writeType="holding" ]
        Thing data nibe55 	[ readStart="55", readValueType="int16", writeStart="55", writeValueType="int16", writeType="holding" ]
        Thing data nibe56 	[ readStart="56", readValueType="int16" ]
        Thing data nibe57 	[ readStart="57", readValueType="int16", writeStart="57", writeValueType="int16", writeType="holding" ]
        Thing data nibe59x01 [ readStart="59.0", readValueType="bit" ]
        Thing data nibe59x04 [ readStart="59.2", readValueType="bit" ]
        Thing data nibe59x08 [ readStart="59.3", readValueType="bit" ]
        Thing data nibe59x10 [ readStart="59.4", readValueType="bit" ]
        Thing data nibe59x20 [ readStart="59.5", readValueType="bit" ]
        Thing data nibe59x40 [ readStart="59.6", readValueType="bit" ]
        Thing data nibe60x01 [ readStart="60.0", readValueType="bit" ]
        Thing data nibe60x08 [ readStart="60.3", readValueType="bit", readTransform="JS(mbusinv.js)" ]
        Thing data nibe62 	[ readStart="62", readValueType="int16", writeStart="62", writeValueType="int16", writeType="holding" ]
        Thing data nibe69 	[ readStart="69", readValueType="int16", readTransform="JS(divide10.js)" ]
        Thing data nibe77 	[ readStart="77", readValueType="int16", writeStart="77", writeValueType="int16", writeType="holding" ]
        Thing data nibe97 	[ readStart="97", readValueType="int16" ]
		}
}

/Mike

Thanks for the report!

I’m quite interested hearing CPU reports as well. What is “too much” here?

Best,
Sami

With to high i mean that openhab stops working normal, getting errors, problem with z-wave, habpanel does not work, but when i stop both modbus bindings everything goes back to normal.

I will collect this information for you during the next couple of days.

/Mike

1 Like

OK haven’t experienced anything this bad certainly. Thanks for the help debugging this.

Now i have this installed and it works good. I think it was some problem whit the ipcamera binding that was the problem.

/Mike

1 Like

@randipandu, have you had to chance to see my comments?

Hi I try to configure my binding to work with Fatek FBs over Modbus RTU via serial.
http://www.fatek.com/en/data%2Fftp%2FPLC%2FFBs_Manual%2FManual_1%2FInstruction%2FChapter_2.pdf
http://www.esea.cz/support/fatek/FBs_Manual/Manual_2/Chapter_13.pdf
I configured poll for markers (coils) with range from 0 to 2001.
Then I added things for each marker and configured items as switches.
I’m getting:
[WARN ] [ternal.ModbusManagerImpl.PollMonitor] - Many (676) tasks queued in callbackThreadPool! This might be sign of bad design or bug in the binding code.
and increases in time
[WARN ] [ternal.ModbusManagerImpl.PollMonitor] - Many (3099) tasks queued in callbackThreadPool! This might be sign of bad design or bug in the binding code.

Haven’t had issues with previous modbus binding with length of 2001 for poll.
How to deal with this case?

Is there a better way to poll multiple markers?

Dear all

I’m new to the Modbus binding. I try to get it running, however so far no success. I use a USR-TCP232-410S with following configuration:

My things file looks liket that:

Bridge modbus:tcp:Pool [ host="192.168.178.30", port=26, id=1 ] {
	Bridge poller holding [ start=1, length=1, refresh=500, type="holding"]{
        Thing data holding1 [ readStart="1", readValueType="int16", writeStart="1", writeValueType="int16", writeType="holding" ]
    }
}

I get following errors (smarthome:things list):

modbus:tcp:Pool (Type=Bridge, Status=ONLINE, Label=Modbus TCP slave, Bridge=null)
modbus:poller:Pool:holding (Type=Bridge, Status=OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: null, Label=Regular poll, Bridge=modbus:tcp:Pool)
modbus:data:Pool:holding:holding1 (Type=Thing, Status=OFFLINE (COMMUNICATION_ERROR): Error (ModbusSlaveIOExceptionImpl) with read. Request: ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1c21836[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=1,length=1,maxTries=3]. Description: ModbusSlaveIOException(cause=ModbusIOException, EOF=false, message='I/O exception: SocketTimeoutException Read timed out', cause=null). Message: null, Label=Modbus data, Bridge=modbus:poller:Pool:holding)

or in the log:tail:

12:00:18.874 [ERROR] [.wimpi.modbus.io.ModbusTCPTransaction] - execute try 1/1 error: I/O exception: SocketTimeoutException Read timed out. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@9d3b40 (unit id 1 & transaction 11648). Address: /192.168.178.30:26
12:00:18.918 [ERROR] [.wimpi.modbus.io.ModbusTCPTransaction] - execute reached max tries 1, throwing last error: I/O exception: SocketTimeoutException Read timed out. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@9d3b40 (unit id 1 & transaction 11648). Address: /192.168.178.30:26

Could anyone please help me. I’m somehow stuck.

Many thanks for your help
Best regards
Rolf

Hi,

Can you please paste here your configuration?

  • If you are using textual configuration, please paste the contents of items and things files
  • If you are using paper UI, please paste pages OPENHAB:8080/rest/items and OPENHAB:8080/rest/things

Please use proper formatting when pasting the config: How to use code fences

Finally, some further questions:

  • does the warning message come on openHAB startup? Does the number in parentheses decrease (in your example, 676 and 3099). The reason might be that openHAB automatically tries to REFRESH all data things, generating many read requests in a queue. With 2001 data things, it would generate 2001 modbus requests to the queue.

Best,
Sami

Hi,
(…) - I limited marker things to 200 for this post

modbus.things

Bridge modbus:serial:fatekplcusb0  "FatekPLC_USB0" [ baud=115200, timeBetweenTransactionsMillis=35, connectMaxTries=3, stopBits="1.0", parity="none", receiveTimeoutMillis=1500, dataBits=8, echo=false, encoding="rtu", flowControlIn="none", port="/dev/ttyUSB0", flowControlOut="none", connectTimeoutMillis=10000, id=1 ] {
    Bridge poller coils_Y0_to_Y255 "FatekPLC_Poller_Y0_to_Y255" [ start=0, length=256, refresh=100, type="coil" ] {
        // Note the zero based indexing: first coil is index 0.
        Thing data FatekPLC_Modbus_Y0 "FatekPLC_Modbus_Y0" @ "Modbus" [ readStart="0", readValueType="bit", writeStart="0", writeValueType="bit", writeType="coil" ]
        Thing data FatekPLC_Modbus_Y1 "FatekPLC_Modbus_Y1" @ "Modbus" [ readStart="1", readValueType="bit", writeStart="1", writeValueType="bit", writeType="coil" ]
    }
//M0 to M2001
    Bridge poller markers_M0_to_M199 "FatekPLC_Poller_M0_to_M199" [ start=2000, length=200, refresh=5000, type="coil" ] {
        // Note the zero based indexing: first coil is index 0.
        Thing data FatekPLC_Modbus_M0 "FatekPLC_Modbus_M0" @ "Modbus" [ readStart="2000", readValueType="bit", writeStart="2000", writeValueType="bit", writeType="coil" ]
        Thing data FatekPLC_Modbus_M1 "FatekPLC_Modbus_M1" @ "Modbus" [ readStart="2001", readValueType="bit", writeStart="2001", writeValueType="bit", writeType="coil" ]
        Thing data FatekPLC_Modbus_M199 "FatekPLC_Modbus_M199" @ "Modbus" [ readStart="2199", readValueType="bit", writeStart="2199", writeValueType="bit", writeType="coil" ]
    }
}

modbus.items

Group gModbus (All)
Switch FatekPLC_Modbus_M0 "FatekPLC_Modbus_M0" (gModbus) { channel="modbus:data:fatekplcusb0:markers_M0_to_M199:FatekPLC_Modbus_M0:switch" }
Switch FatekPLC_Modbus_M1 "FatekPLC_Modbus_M1" (gModbus) { channel="modbus:data:fatekplcusb0:markers_M0_to_M199:FatekPLC_Modbus_M1:switch" }
Switch FatekPLC_Modbus_M2 "FatekPLC_Modbus_M2" (gModbus) { channel="modbus:data:fatekplcusb0:markers_M0_to_M199:FatekPLC_Modbus_M2:switch" }
Switch FatekPLC_Modbus_M3 "FatekPLC_Modbus_M3" (gModbus) { channel="modbus:data:fatekplcusb0:markers_M0_to_M199:FatekPLC_Modbus_M3:switch" }

(…) up to M199

Answering your question. On the beginning I have had poll refresh set to 1000 for 2001 things. First I limited amount of things to 200. Then I was getting the message and the amount of tasks was quicky increasing. I started increase poll refresh to the moment when amount of tasks started to decrease and I finished at about 5000. Poll refresh at 5000 is unfortunately much to high and is meaningless for any of my home purposes.
With the old binding I didn’t have such kind of issue. It just worked.
The question I have is, what is the best way to poll high amount of coils when I use them only for “Switch” type?

Hi ,

thanks for the configs. In your config you have length=200 with the “markers”. What is the true configuration? Most importantly, how many data things you have? How many pollers with what configuration? I don’t understand how the true configuration has been modified for the thread post?

I have seen similar issue with my testing but there the queue sizes were much smaller and thus not an real issue (see explanation below).

I presume the queue is getting large due to openHAB requesting refresh on startup, when the things are introduced to the system. Basically, all the data things receive REFRESH command to the channels bound to items.

Can you provide verbose logs (see logging guide in docs), starting from openHAB startup, so I can confirm this “theory”?

The openHAB core sends REFRESH command to each of the data things. Each command translates to one modbus request, explaining the large queue size.

The queue size should decrease over time. In your case with 35ms between requests, queue of 3000 requests takes around 1.5 minutes to clear. This is quite a long time.

The poll period should not make a difference here, I think. However, if you are sending commands to modbus items (writing to modbus) within rules with fast pace, the queue can and will increase as well.

Can you observe that queue size decreases over time? Check how the number in the log message evolves using this console command `log:tail | grep ‘tasks queued’

Old binding does not have this issue since it did not support concept of REFRESH at all.

Unfortunately, I don’t have a workaround for you in this case. I appreciate if you can provide the logs and provide answer to the above points so we get a comfirmation on this. I probably need to consult the openHAB maintainers as well the best/cleanest way to solve this.

Best
Sami

Hi,

I’m new to this modbus binding and could need some help. The last few days I played around with connecting my arduino via modbus with my raspberry pi. With the old modbus1 binding, I didn’t get it to work.
Now I tried this modbus2 binding and it works way better than before.
Unfortunately, there is one thing which I don’t understand. Here is my Setup:

  1. Openhab on Raspberry PI
  2. USB to RS485 converter
  3. Max485 IC
  4. Arduino with a modbus library and 16 outputs configured as coils

I did all configuration in the paper UI, because it has been very easy :slight_smile:

These are my things:

  1. Modbus Serial Slave with Port /dev/ttyUSB0, Baud 38400, ID 2

  2. Regular Poll, Intervall 500, start 0, length 16 (because of the 16 coils on the arduino), type coil

  3. 16 times Modbus data. one for each coil.

    1. read address 0, write address 0, write type coil
    2. read address 1, write address 1, write type coil
    3. read address 2, write address 2, write type coil
    4. read address 15, write address 15, write type coil
  4. Each Modbus data has one switch linked to control the outputs

Now the fun part:
coil 0-6 are working fine
coil 7 can’t be changed. Everytime I switch to “on” it immediately switches back to off
coil 8-14 are working fine
coil 15 can’t be changed. Everytime I switch to “off” it immediately switches back on

It feels strange that always the last of 8 coils is not working fine? Is there a special case, because the 8th is using the highest bit in a byte? Just speculating…

Btw. No errors in the logs.

So Long

Sven