LogicMachine as gateway to Denver e-Ribbon Fire
Example: LogicMachine as gateway to Denver e-Ribbon Fire
Task
This examples will show how to integrate/control Decoflame’s Denver e-Ribbon bio fire system into common KNX/ModBus/BACnet/EnOCean/DALI network through LogicMachine.
Denver e-Ribbon Fire™ is an automatic built-in burner with a continuous, linear flame tray which can be manufactured in any dimensions exclusively by Decoflame.
Connection to Denver e-Ribbon fire system is done over RS-232 port.
Send Function
Add this code to Scripting –> Common Functions
- function send(dev, req)
- local port, b1, b2, cs, data, res, err
-
- -- checksum calculation
- function getcs(b1, b2)
- return 0xFF - bit.band(b1 + b2, 0xFF)
- end
-
- require('serial')
- port = serial.open(dev, { baudrate = 19200 })
-
- -- get two bytes from request
- b1 = bit.rshift(req, 8)
- b1 = bit.band(b1, 0xFF)
- b2 = bit.band(req, 0xFF)
-
- -- calculate checksum
- cs = getcs(b1, b2)
-
- -- send data
- data = string.char(0x01, b1, b2, cs, 0x04)
- port:flush()
- port:write(data)
-
- -- wait for reply
- res, err = port:read(#data, 1)
- port:close()
-
- -- valid reply
- if type(res) == 'string' and #res == #data then
- b1, b2, cs = res:byte(2, 4)
-
- -- verify checksum
- if cs == getcs(b1, b2) then
- return b1, b2
- -- invalid checksum
- else
- return nil, 'invalid checksum'
- end
- -- no reply or invalid reply
- else
- return nil, err
- end
- end
Send commands to fire
Add control objects in LogicMachine and specify separate Event-based scripts for each control grp address.
For example, below is script to send ‘flame5’ command.
- log(send('/dev/RS232', 0x0005))
Statuses from fire
The fire can return statuses based on specific commands e.g. fuel level.
Add following function in Common Functions.
- function getstatus(port, data)
- local b1, b2 = send(port, data)
- if b1 then
- b1 = bit.band(b1, 0x0F)
- b1 = bit.lshift(b1, 8)
- return bit.bor(b1, b2)
- end
- end
Add resident script with necessary time interval to update respective grp addresses with statuses
- -- fuel level status
- fuel = getstatus('/dev/RS232', 0x9000)
- if fuel then
- grp.update('1/1/1', fuel)
- end