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.

Connect my device via RS485 ?
#1
I want to connect a device "Modbus RTU" with LM3.
How to use it! and through LM3 to control it! I have to write what initialization script?
My device is DDL24 of Razumdom and RS485 connection to LM3.
I was a new person ! I am very grateful to everyone for my information!
Heart Heart
Reply
#2
First, you need to set device address via broadacst message, so make sure only one device is connected to RS-485 line:
Code:
require('luamodbus')
mb = luamodbus.rtu()

mb:open('/dev/RS485-1', 9600, 'N', 8, 2, 'H')
mb:connect()

-- set new address to 10 via broadcast
mb:setslave(0)
mb:writeregisters(0, 10)

Then you can control it like this:
Code:
require('luamodbus')
mb = luamodbus.rtu()

mb:open('/dev/RS485-1', 9600, 'N', 8, 2, 'H')
mb:connect()

mb:setslave(10)

mb:writeregisters(4, 255) -- set red to 255
mb:writeregisters(5, 127) -- set green to 127
mb:writeregisters(6, 50) -- set blue to 50
mb:writeregisters(7, 80) -- set white to 80

If this works fine, then a profile can be created to make mapping from ModBus tab without scripts.
Reply
#3
I have some do not understand?
above marked "mb: setslave (0)" but the bottom stating "mb: setslave (10)"?
Meaning it differently?
mb: writeregisters (4, 255) - set to 255 red
mb: writeregisters (5, 127) - set to 127 green
mb: writeregisters (6, 50) - set to 50 blue
mb: writeregisters (7, 80) -
And 4,5,6,7 value here is what? This value must be taken from the production?
Maybe someone did this!, You can help me? I am very grateful!
Reply
#4
Hi,

The first part set a default slave to address 10 by a broadcast command so be sure to have only 1 device connected when you write the address to device, when all devices have a new final address you can connect them all together and use 2nd script to control them by using there new adresses.

4, 5, 6, 7 are the modbus registers in the connected modbus device.

I would advice you to read the manual of the device as all modbus registers are explained there.

BR,

Erwin
Reply


Forum Jump: