Posts: 52
Threads: 13
Joined: Feb 2021
Reputation:
0
Hi Admin
I'm trying to integrate LM with generator to read 3 phase values , fuel level etc.
Code:
require('luamodbus')
mb = luamodbus.rtu()
res = mb:open('/dev/RS232', 9600, 'N', 8, 1, 'H')
log(res)
if res then
mb:connect()
mb:setslave(3)
mb:setresponsetimeout(30)
-- read 3-phase system voltage
r1, r2 = mb:readregisters(10240, 2)
if r1 and r2 then
result = bit.lshift(r1, 16) + r2
grp.checkwrite('32/5/1', result)
log(result)
end
end
mb:close()
I used this code to read registers LM opens port succesfully but no value writed at all.
I tried changing Rx - Tx pins already but helped not at all.
Any help would appreciated
Thanks
Attached Files
Posts: 6477
Threads: 35
Joined: Jun 2015
Reputation:
360
Use 'F' duplex instead of 'H' for RS232.
Posts: 52
Threads: 13
Joined: Feb 2021
Reputation:
0
Still no change,anything else
Posts: 6477
Threads: 35
Joined: Jun 2015
Reputation:
360
I'm not even sure if this device supports Modbus over RS232 - the documentation states two different things. Have you tried using RS485 instead?
Posts: 52
Threads: 13
Joined: Feb 2021
Reputation:
0
25.05.2023, 14:48
(This post was last modified: 25.05.2023, 14:57 by mkaymak .)
Yeah i've tried but still no clue.
Should i change addresses to Hex ?
Posts: 52
Threads: 13
Joined: Feb 2021
Reputation:
0
After a few tries i got invalid CRC error.How can i solve it?
Posts: 6477
Threads: 35
Joined: Jun 2015
Reputation:
360
Are you using RS232 or RS485? Is GND connected between devices?
Posts: 52
Threads: 13
Joined: Feb 2021
Reputation:
0
29.05.2023, 05:26
(This post was last modified: 29.05.2023, 07:54 by mkaymak .)
I'm using RS232 and ground is connected
Code:
{
"manufacturer": "DATAKOM",
"description": "D300 JENERATOR",
"mapping": [
{ "address": 10240, "name": "Sebeke Faz L1 gerilimi", "datatype": "uint32", "bus_datatype": "uint32", "type": "inputregister"},
{ "address": 10242, "name": "Sebeke Faz L2 gerilimi", "datatype": "uint32", "bus_datatype": "uint32", "type": "inputregister"},
{ "address": 10244, "name": "Sebeke Faz L3 gerilimi", "datatype": "uint32", "bus_datatype": "uint32", "type": "inputregister"},
{ "address": 10264, "name": "Sebeke Faz L1 akimi", "datatype": "uint32", "bus_datatype": "uint32", "type": "inputregister"},
{ "address": 10266, "name": "Sebeke Faz L2 akimi", "datatype": "uint32", "bus_datatype": "uint32", "type": "inputregister"},
{ "address": 10266, "name": "Sebeke Faz L3 akimi", "datatype": "uint32", "bus_datatype": "uint32", "type": "inputregister"},
{ "address": 10292, "name": "Sebeke toplam aktif guc", "datatype": "uint32", "bus_datatype": "uint32", "type": "inputregister"},
{ "address": 10308, "name": "Sebeke toplam reaktif guc", "datatype": "uint32", "bus_datatype": "uint32", "type": "inputregister"},
{ "address": 10324, "name": "Sebeke toplam guc", "datatype": "uint32", "bus_datatype": "uint32", "type": "inputregister"},
{ "address": 10338, "name": "Sebeke Faz", "datatype": "uint16", "bus_datatype": "uint16", "type": "inputregister"},
{ "address": 10363, "name": "Yakit Seviyesi", "datatype": "uint16", "bus_datatype": "uint16", "type": "inputregister"}
]
}
Added profile
Posts: 6477
Threads: 35
Joined: Jun 2015
Reputation:
360
Disable Modbus mapper, run this debug script and post what you get in Logs:
https://forum.logicmachine.net/showthrea...2#pid16012
Modify the script with correct serial port and Modbus device settings.