This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

RS232 Communacation
#1
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
.pdf   500_MODBUS.pdf (Size: 838.77 KB / Downloads: 14)
Reply
#2
Use 'F' duplex instead of 'H' for RS232.
Reply
#3
Still no change,anything else
Reply
#4
I'm not even sure if this device supports Modbus over RS232 - the documentation states two different things. Have you tried using RS485 instead?
Reply
#5
Yeah i've tried but still no clue.

Should i change addresses to Hex ?
Reply
#6
After a few tries i got invalid CRC error.How can i solve it?
Reply
#7
Are you using RS232 or RS485? Is GND connected between devices?
Reply
#8
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
Reply
#9
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.
Reply
#10
Can anyone help me with the following questions? Thank you in advance.
Q1:How many modbus slave devices can each RS485 or RS232 interface of LM drive?
Q2:Is there a limit on the total length range of the bus?
Reply
#11
Q1 RS485 = 31, RS232 = 1
Q2. Not so simple https://electrical-engineering-portal.co...dbus-rs485
------------------------------
Ctrl+F5
Reply
#12
@Daniel ,thank you for your timely answer.
Reply


Forum Jump: