Hi, i’m new to OH. I need help with the modbus binding in OH2. im using the modicon m221 schneider plc with twidosuite software. im trying to make cloud controlling for the plc and im using the %M for every input and output so that i can simulate it with virtual simulation without making any house miniature. so far im only using 1 m221 without any addons with 8 input and 8 output (from 24 I/0 that can be used). my question is :
which tcp.slave1.type should i use ? because, input type can only read (without write) and coil type will write straight to the coil while i want to read and write in the input contacts and then activate the output coil after that.
how could i call the function %M in OH2 ? i use it in every input and output because if im using the normal output (%Qx.x) i can only put up to 24 output.
pls help me. i already stuck on it about 3 weeks now. thanks a lot
At the bottom, OpenHAB can only read and write data over Modbus to the PLC. What that PLC provides as data that can be read, or how it responds to data written into it, is up to the PLC programming. You may want to seek help with this on forums specialised in that PLC
Yes, Modbus will only read input registers. There is no way to write to inputs. A way round that would be to use holding registers instead, which Modbus can read and write to. Again, this down to what the PLC provides in the way of registers, and what it does about them when written.
I’ve no idea what %M and %Q are.
If you can define your query in terms of “I would like to write to coil 7 and read from holding register 22” then we can turn that into OpenHAB configuration.
what I want to ask is, in the tcp.slave1.type parameter there is 4 choices which is input, discrete, coil and holding register.
coil type will read and write only on the coil itself.
input type will read the input data but cannot write in it.
while what I want to do is, I want to read and write the input register first and then trigger the coil on the output. so I can control it and do the monitoring on the PLC at any state. (it’s like I want to use the holding register on the input as trigger to activate the coil. I’ll try to attach my PLC ladder diagram here so you can see it better).
so what you recommend is to use holding register instead of using the input register so it can read and write in the input section ?
I don’t really know how to explain about %M. but from what I know, %M is like a memory word and another way to call input or output using remote or cloud control (such as web server or using another PLC application from your phone like TeslaModbusScada, etc).
because there is only 24 input (%Ix.x) and 16 output (%Qx.x) (so there is %I0.0-%I0.23 and %Q0.0-%Q0.15) on the modicon M221. while in %M we can use 256 memory for input and output (%M0-%M255).
sorry for my very bad grammar and english. I hope you can understand what I mean and what I actually want to tell.
It is true that it is impossible to write to a Modbus input register type from OpenHAB.
I do not understand why you want to write to an input register, what are you expecting to happen? Are you trying to communicate to the program in the PLC, or are you trying to affect the input or coil wires at the PLC?
I don’t know the capabilities of your PLC at all, I’m guessing that you can write a PLC program that reads its physical input wires into a holding register. OH can read that holding register over Modbus into an OH Item.
If you want to write to the holding register from OH, you can, by sending an OH command to the Item. That will get sent over Modbus.
Then program your PLC to do whatever it is you want it to do when the holding register is changed from Modbus.
You can write OpenHAB rules that look at the Item representing the holding register, and send commands to other Items representing coils and/or holding registers, which will get passed to the PLC over Modbus.
+1 to @rossko57’s comments. Learn how to use holding registers and write your PLC logic according to that.
I am using Siemens PLCs to control my floor heating system. PLC is programmed to put anything needed in OH to holding registers and they are served through modbus. For example temperatures and valve states.
I have no personal experience with schneider PLCs but with Siemens it took me a while to get everything up and running. I think every manufacturer has their own offsets and mappings regarding transformation from internal memories etc. to modbus.
Hi @rossko57, yes I’m trying to communicate to the input on the PLC so it can activate the coil. and thanks for your advice to use the holding register for the input. It helps a lot (but I’m still trying to figure out how to use it to do controlling and monitoring the program ).
Hi @jcurado thanks for your advice. I’ll try to find out about that %MW too
Hi @gitMiguel thanks for your advice. I’m learning how to use holding register now. Both in the PLC and the OH. Btw, what bindings that you use for the siemens PLC ? I’m using the Modbus Bindings for my PLC. and actually I’m confused. It said use the number 40001 to 49999 for the holding register, FC3 command to read the holding register and FC6 to write on it. can you give me some example about that ? and can you give me some short simple explanation on the modbus binding configuration ? this is what I’m trying to make :
4 lightings with parallel switch (manual switch and holding register) (so I can turn it on/off from both switch, using holding register on the input)
4 electricity terminal (using only 4 coil without holding register on the input)
using only the modicon M221 PLC
I’m trying to make something that simple first to understand about modbus and PLC bindings.
Sorry for asking so much from you guys. I’m very new to this OpenHAB. And my other friends who’s working with OH too can’t do nothing with my project. Since they are working with arduino and stuff. While I’m the only student that try to make home automation using PLC and OH
That’s exactly what this forum and community is for. To ask and learn.
If you are using the older 1.x binding I can’t help you much. Havn’t used it at all. I went straight to 2.x binding whitch is still under some final developement. You can find discussion about it in here: Modbus openHAB2 binding available for alpha testing. I know it’s a long thread but if you go with 2.x binding it’s worth reading. For example there you can find hints how to read single bits from holding registers.
Thanks @gitMiguel. I’ll try to read that thread first. I already read it once, but I don’t really understand. But I’ll try to read it again. Thanks a lot