EasyManua.ls Logo

Embedded Systems LogiMachine5 Power - Page 188

Embedded Systems LogiMachine5 Power
254 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
188
coil2 = false
coil3 = false
mb:writebits(10, coil1, coil2, coil3)
-- multiple write from table
coils = { true, false, false }
mb:writebits(10, unpack(coils))
Core functions:
luamodbus.rtu()
Creates new Modbus RTU object
luamodbus.tcp()
Creates new Modbus TCP object
Modbus object functions:
Core functions:
mb:open(port, [baudrate = 9600, [parity = 'N', [databits = 8, [stopbits = 2]]]])
RTU mode - opens the serial port. (parity: 'N' - none, 'E' - even, 'O' - odd; databits: 7 or
8; stopbits: 1 or 2)
mb:open(ip, [port = 502])
TCP mode - prepares connection to the specified IP and port (optional)
mb:connect()
opens serial or network connection
mb:close()
closes an open connection
mb:flush()
flushes any unsent data
Slave functions:
mb:receive()
receives data from master with 1 minute timeout
returns data as a binary string on success and nil, error description on error
mb:setmapping(coils, inputs, holding_regs, input_regs)
creates memory mapping for the registers with size specified for each type
mb:handleslave()
waits for an incoming indication from master and sends a reply when necessary
mb:getcoils(start, count)
mb:getdiscreteinputs(start, count)
mb:getinputregisters(start, count)
mb:getregisters(start, count)
gets one or many register/coil values from mapping from the start address
returns all values on success and nil, error description on error, exception code if
applicable
mb:setcoils(start, v1, [v2, [v3, ...]])
mb:setdiscreteinputs(start, v1, [v2, [v3, ...]])
mb:setinputregisters(start, v1, [v2, [v3, ...]])

Table of Contents