Pb with COIL Wite in MODBUS
My name is Nicolas, I've set up 3 years ago a home network based on modbus, it works pretty well with a PLC acting as Master and 4 others as slaves.
Of course it doesn't make very funny things, reason why i'm looking at a SCADA/HMI solution particulary to interact with internet.
I really find Mango sexy, stable, easy to configure and defnitively very flexible .
I've been using it for a week , everithing relative to data reading over modbus is working perfectly, but things seems more tricky when i try to write to my coils.
before writing this I've been trying some tests and capture and here is the results of theses ...
When configuring a data point as Register (16 Coils ) it works very well , for example I can read a value of 4 when my COil #3 is UP , yes , 2^3 = 8 :-)
I can also force a value to this data point and it works well to : writing 3 really lights ON Q1 and Q2 only !
But of course managing COILS in group of registers is not very easy, as far as I imagine I would be obliged to make AND operations on actual values to modify thems ...
SO I tried to set up data point as Binaries, again the reading of values are OK, this time my datapoint indicates "1" when the coil is "ON" and it seems pefect.
BUT when i try to force my COIL with a binary value, nothing happens and I have a warning from the data set.
I've capture some packets with IO logs enabled :
Mango request: O 04 16 0007 FFEF 0010 83d4
Slave response : I 04 96 51 9e5d
it shows that the request sent to write a binary value is in fact a function 16 of Modbus protocol, wich correspond to "Write Mask Register", but infortunatly my slave doesn't seems to accept this function: error code is set (16 + 80) and the exception code is "Frame Error, fucntion code error ..."
Despite the fonction 16 is the most indicated for this operation (It's clearly not a bug from Mango!), I'm quite sure there is not a lot of PLC that accept this function so I would like to share with other people that have to write binaries if they found a solution specific to this issue...
I've also try to configure the data point as a Coil, but then I get another error, this time on function 01, wich is very basic :
Mango request: O 04 01 0007 0001 4c5e
Slave response: I 04 81 54 51ae => "Data out of Range exception"
While writing this post, I'm trying to find a trick with more complicated sets of datas but I'm really not aware of HEX/BIN/ASCII manipulations and I guess I will become mad before the end .... it's a pity regarding the very good interest of Mango concerning home automation.
Any help or share would be very appreciated ... :shock:
PS: my PLC are from IMO , the master is an "i3" : http://imopc.com/content.php?p=spotlight_i3Microsite&lang=EN
and the lazy slaves are ISmart V2 : http://imopc.com/pages/spotlight_ismart
I also try to use the fmous checkbox : Use multiple write commands only observing it resolved some issues in that taste... but it's not better.
I'm surprised to see that this options does not realy change the behaviour of the sender, I can still see 16-type request going to the slaves ...
Is this option require something else to be checked ?
Well, this topic doesn't meet so much success ...no matter, I continue to share my investigations
I Had responses from the manufacturer's doc (IMO): the function 16 is definitivly not supported ...
I see 2 solutions now :
- deal with the function 01 (ReadCoilStatus) and 05 (WriteCOil), I wait some answers from IMO to tell me how I could use this fn without getting back a, (Out of Range Data) error
- bypass the built-in fonctions of Mango to write values directly to the slave using the function 06 (WriteRegister) wich I know is well supported, and a routine to calculte the good value to write (read register value, then add or substract 2^n) then write the result). All of this with the help of the Process Event Handler.
SO I've a new question for the masters : is there a trick to call a internal procedure of Mango (from Unix CLI) to write a register to a slave ? As Mango is Master, I cannot use another external program to do this ....
If it does'nt disturb too much , I will continue to write my relfexions in this topic, perhaps some day .... 8)