Logic Machine Forum
MODBUS - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: MODBUS (/showthread.php?tid=5204)



MODBUS - KARRAS - 16.01.2024

I have a problem writing to a GREE brand air conditioning machine.
From a PAS600 TCP/IP modbus gateway and software I can do the writing in Word 2 for the ON/OFF and setpoint change, but from the Logic Machine I have not been able to.

This is the json file.

{
  "manufacturer": "LM",
  "description": "Special Profile",
  "mapping": [
{ "name": "ON_OFF", "bus_datatype": "int16", "type": "register", "address": 2, "writable": true },
{ "name": "Ambient temperature", "bus_datatype": "int16", "type": "register", "address":4, "writable":false, "value_multiplier": 0.1, "units": "° C"},
{ "name": "mode", "bus_datatype": "uint16","type":"register", "address":17, "writable":true },
{ "name": "set fan speed", "bus_datatype": "uint16", "type": "register", "address":19, "writable":true },
{ "name": "set point", "bus_datatype": "uint16", "type": "register", "address": 20, "writable": true },
{ "name": "set point1", "bus_datatype": "int16", "type": "register", "address": 20, "writable": true },
{ "name": "Operation", "bus_datatype": "uint16", "type": "register", "address": 20, "writable": true},
{ "name": "Operation Mode ", "bus_datatype": "uint16", "datatype": "uint16", "type": "register", "address": 20, "writable": true}
  ]

  }
I have tried all possible options, but nothing.
How can I know the command that is being output via modbus TCP/IP to the PAS600 gateway?


RE: MODBUS - Daniel - 16.01.2024

Add "write_multiple" : true


RE: MODBUS - KARRAS - 16.01.2024

(16.01.2024, 08:54)Daniel Wrote: Add "write_multiple" : true
Sorry, I also tried this yesterday but the same thing keeps happening to me.


{
  "manufacturer": "LM",
  "description": "Special Profile",
  "mapping": [
{ "name": "ON_OFF", "bus_datatype": "int16", "type": "register", "address": 2, "writable": true ,  "write_multiple": true},
{ "name": "Temperatura ambiente", "bus_datatype": "int16", "type": "register",  "address":4, "writable":false, "value_multiplier": 0.1, "units": "°C"},
{ "name": "mode", "bus_datatype": "uint16","type":"register", "address":17, "writable":true,  "write_multiple": true },
{ "name": "set fan speed",  "bus_datatype": "uint16", "type": "register",  "address":19, "writable":true,  "write_multiple": true },
{ "name": "set point", "bus_datatype": "uint16", "type": "register", "address": 20, "writable": true,  "write_multiple": true },
  ]

}


RE: MODBUS - admin - 16.01.2024

Which value did you try sending? According to docs you need to send 170 (0xAA) to turn it ON and 85 (0x55) to turn it OFF.
See if you can read register values using read test.


RE: MODBUS - KARRAS - 16.01.2024

Hello, that's right, I read the values perfectly. The problem is when writing. With the readtest I see the values, both 170 (0xAA) and 85 (0x55).
In fact, I have done the writing through a program that I have and I can turn the machine on and off, but not from the LM.


RE: MODBUS - Daniel - 16.01.2024

Add "datatype": "uint16"


RE: MODBUS - KARRAS - 16.01.2024

Hello, 
I also tried with uint16 but it doesn't work, I have tried everything.


Now, I just tried it this way and it works with this script.


-- object mapped to this event must have its data type set
value = event.getvalue()

require('luamodbus')
mb3 = luamodbus.tcp()
IP='192.168.1.141'  --IP

mb3:open(IP, 502)
mb3:connect()

address=1 ----DIRECCIÓN DEL DISPOSITIVO ESCLAVO
mb3Confusedetslave(address)

registro=2 --registro modbus

--valueInt1, valueInt2 = mb3:readregisters(registro,1)

--log(valueInt1, valueInt2 )

r1, r2 = mb3:writemultipleregisters(registro, value)

Do you know any way to be able to see the modbus command that comes out through the port, that is, the composition of the writing, to see what it sends through the port?