carel
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
carel [2020/12/23 16:50] – emozolyak | carel [2022/01/15 17:31] (current) – ↷ Links adapted because of a move operation 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Carel cooling controllers ====== | ====== Carel cooling controllers ====== | ||
- | {{ :: | + | {{ network: |
+ | |||
+ | New models Carel cooling controllers have Modbus RTU, while older models have a proprietary Carel communication protocol. The protocol is quite efficient one, becuase it only sends changes of its parameter, or "no changes" | ||
+ | |||
+ | Older controllers have the following communication features: | ||
+ | |||
+ | The modules often do not have an integrated RS-485 driver, and the connection must be made to the TTL serial bus port via TTL-RS485 converter. The default transmission format - 19200, 8 data bits, no parity, 2 stop bits. | ||
+ | |||
+ | These modules can be read with the [[custom_protocols? | ||
+ | |||
+ | <code lua -example.lua> | ||
+ | function readRegister (reg, device, unitId) | ||
+ | |||
+ | if not carel.synced then | ||
+ | DEBUG(" | ||
+ | local newId = unitId + ADDR_OFFSET | ||
+ | | ||
+ | |||
+ | | ||
+ | local reply = readUntil(ETX, | ||
+ | |||
+ | if reply then | ||
+ | | ||
+ | if (#reply > 30) then | ||
+ | | ||
+ | -- now 2nd sync | ||
+ | | ||
+ | reply = readUntil(ACK, | ||
+ | if reply then | ||
+ | | ||
+ | | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | |||
+ | if carel.synced then -- synced | ||
+ | local poll_counter, | ||
+ | |||
+ | repeat | ||
+ | poll_counter = poll_counter + 1 | ||
+ | sendBytes(carel.pollTemplate) ; local reply = readUntil(ETX, | ||
+ | |||
+ | if not reply then | ||
+ | ERROR(" | ||
+ | carel.synced = false | ||
+ | return false | ||
+ | end | ||
+ | |||
+ | if (reply[1] == NULL) then | ||
+ | DEBUG(" | ||
+ | sendBytes{ACK} | ||
+ | break | ||
+ | else | ||
+ | DEBUG(" | ||
+ | sendBytes{ACK} | ||
+ | |||
+ | local idx = {type = 3, addr_hi = 4, addr_lo = 5, data_start = 6} | ||
+ | local type_ = string.char(reply[idx.type]) ; DEBUG(" | ||
+ | if not (type_ == ' | ||
+ | ERROR(" | ||
+ | return -1 | ||
+ | else | ||
+ | local dev_addr = getHexFromASCII(reply[idx.addr_hi], | ||
+ | dev_addr = string.sub(dev_addr, | ||
+ | dev_addr = tonumber(dev_addr, | ||
+ | |||
+ | local dev_data_len = ((type_ == ' | ||
+ | |||
+ | local tmp_t = {} | ||
+ | for j = idx.data_start, | ||
+ | table.insert(tmp_t, | ||
+ | end | ||
+ | local dev_data = tonumber(table.concat(tmp_t), | ||
+ | DEBUG(' | ||
+ | |||
+ | carel.data[type_][dev_addr] = dev_data | ||
+ | end | ||
+ | end | ||
+ | |||
+ | if (poll_counter >= POLL_LIMIT) then | ||
+ | | ||
+ | end | ||
+ | until (poll_counter >= POLL_LIMIT) | ||
+ | |||
+ | local value = carel.data[device.name][reg.internalAddr] | ||
+ | return value | ||
+ | |||
+ | end -- synced | ||
+ | end -- readRegister | ||
+ | </ |
carel.1608742206.txt.gz · Last modified: 2020/12/23 16:50 by emozolyak