Posts: 54
Threads: 15
Joined: Feb 2021
Reputation:
0
Hi Admin
I'm trying to integrate LM with generator to read 3 phase values , fuel level etc.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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 )
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: 8097
Threads: 43
Joined: Jun 2015
Reputation:
471
Use 'F' duplex instead of 'H' for RS232.
Posts: 54
Threads: 15
Joined: Feb 2021
Reputation:
0
Still no change,anything else
Posts: 8097
Threads: 43
Joined: Jun 2015
Reputation:
471
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: 54
Threads: 15
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: 54
Threads: 15
Joined: Feb 2021
Reputation:
0
After a few tries i got invalid CRC error.How can i solve it?
Posts: 8097
Threads: 43
Joined: Jun 2015
Reputation:
471
Are you using RS232 or RS485? Is GND connected between devices?
Posts: 54
Threads: 15
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
{
"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: 8097
Threads: 43
Joined: Jun 2015
Reputation:
471
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.
Posts: 92
Threads: 18
Joined: Apr 2022
Reputation:
0
26.07.2023, 10:07
(This post was last modified: 26.07.2023, 10:10 by rw_echo .)
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?
Posts: 4961
Threads: 28
Joined: Aug 2017
Reputation:
228
------------------------------
Ctrl+F5
Posts: 92
Threads: 18
Joined: Apr 2022
Reputation:
0
@Daniel ,thank you for your timely answer.