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 ?
#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


Messages In This Thread
Connect my device via RS485 ? - by phongvucba - 02.12.2016, 08:07
RE: Connect my device via RS485 ? - by admin - 02.12.2016, 09:12

Forum Jump: