Central Heating controller using the real time clock, PHY module for internet, 1-wire interface for temperature sensors, a system log and a configuration file
Dependencies: net 1-wire lpc1768 crypto clock web fram log
/media/uploads/andrewboyson/heating.sch
/media/uploads/andrewboyson/heating.brd
/media/uploads/andrewboyson/eagle.epf
web-this/boiler/web-boiler-script.js@104:46ce1aaf8be7, 2021-02-10 (annotated)
- Committer:
- andrewboyson
- Date:
- Wed Feb 10 17:24:36 2021 +0000
- Revision:
- 104:46ce1aaf8be7
- Parent:
- 92:2d1ca4dcbca7
- Child:
- 105:1899f7ed17ec
Added PWM speed control to the boiler pump.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 47:229338b3adcb | 1 | //Boiler script |
andrewboyson | 47:229338b3adcb | 2 | 'use strict'; |
andrewboyson | 47:229338b3adcb | 3 | |
andrewboyson | 91:8b192efd0288 | 4 | let dateTime = ''; |
andrewboyson | 91:8b192efd0288 | 5 | let tankTemperature = ''; |
andrewboyson | 91:8b192efd0288 | 6 | let blrOutTemperature = ''; |
andrewboyson | 91:8b192efd0288 | 7 | let blrRtnTemperature = ''; |
andrewboyson | 91:8b192efd0288 | 8 | let boilerCall = false; |
andrewboyson | 91:8b192efd0288 | 9 | let boilerPump = false; |
andrewboyson | 91:8b192efd0288 | 10 | let tankSetPoint = ''; |
andrewboyson | 91:8b192efd0288 | 11 | let tankHysteresis = ''; |
andrewboyson | 91:8b192efd0288 | 12 | let blrRunOnDeg = ''; |
andrewboyson | 91:8b192efd0288 | 13 | let blrRunOnTime = ''; |
andrewboyson | 104:46ce1aaf8be7 | 14 | let blrPumpSpeed = ''; |
andrewboyson | 104:46ce1aaf8be7 | 15 | let blrPumpPwm = ''; |
andrewboyson | 104:46ce1aaf8be7 | 16 | let pumpSpeedCalling = ''; |
andrewboyson | 104:46ce1aaf8be7 | 17 | let pumpSpeedRunOn = ''; |
andrewboyson | 104:46ce1aaf8be7 | 18 | let blrOutputTarget = ''; |
andrewboyson | 104:46ce1aaf8be7 | 19 | let riseAt0 = ''; |
andrewboyson | 104:46ce1aaf8be7 | 20 | let riseAt50 = ''; |
andrewboyson | 104:46ce1aaf8be7 | 21 | let riseAt100 = ''; |
andrewboyson | 47:229338b3adcb | 22 | |
andrewboyson | 47:229338b3adcb | 23 | function parse() |
andrewboyson | 47:229338b3adcb | 24 | { |
andrewboyson | 47:229338b3adcb | 25 | let lines = Ajax.response.split('\n'); |
andrewboyson | 104:46ce1aaf8be7 | 26 | tankTemperature = Ajax.hexToSignedInt16(lines[ 0]); |
andrewboyson | 104:46ce1aaf8be7 | 27 | blrOutTemperature = Ajax.hexToSignedInt16(lines[ 1]); |
andrewboyson | 104:46ce1aaf8be7 | 28 | blrRtnTemperature = Ajax.hexToSignedInt16(lines[ 2]); |
andrewboyson | 104:46ce1aaf8be7 | 29 | boilerCall = Ajax.hexToBit (lines[ 3], 0); |
andrewboyson | 104:46ce1aaf8be7 | 30 | boilerPump = Ajax.hexToBit (lines[ 3], 1); |
andrewboyson | 104:46ce1aaf8be7 | 31 | tankSetPoint = Ajax.hexToSignedInt16(lines[ 4]); |
andrewboyson | 104:46ce1aaf8be7 | 32 | tankHysteresis = Ajax.hexToSignedInt16(lines[ 5]); |
andrewboyson | 104:46ce1aaf8be7 | 33 | blrRunOnDeg = Ajax.hexToSignedInt16(lines[ 6]); |
andrewboyson | 104:46ce1aaf8be7 | 34 | blrRunOnTime = Ajax.hexToSignedInt16(lines[ 7]); |
andrewboyson | 104:46ce1aaf8be7 | 35 | blrPumpSpeed = Ajax.hexToSignedInt16(lines[ 8]); |
andrewboyson | 104:46ce1aaf8be7 | 36 | blrPumpPwm = Ajax.hexToSignedInt16(lines[ 9]); |
andrewboyson | 104:46ce1aaf8be7 | 37 | pumpSpeedCalling = Ajax.hexToSignedInt16(lines[10]); |
andrewboyson | 104:46ce1aaf8be7 | 38 | pumpSpeedRunOn = Ajax.hexToSignedInt16(lines[11]); |
andrewboyson | 104:46ce1aaf8be7 | 39 | blrOutputTarget = Ajax.hexToSignedInt16(lines[12]); |
andrewboyson | 104:46ce1aaf8be7 | 40 | riseAt0 = Ajax.hexToSignedInt16(lines[13]); |
andrewboyson | 104:46ce1aaf8be7 | 41 | riseAt50 = Ajax.hexToSignedInt16(lines[14]); |
andrewboyson | 104:46ce1aaf8be7 | 42 | riseAt100 = Ajax.hexToSignedInt16(lines[15]); |
andrewboyson | 47:229338b3adcb | 43 | } |
andrewboyson | 47:229338b3adcb | 44 | function display() |
andrewboyson | 47:229338b3adcb | 45 | { |
andrewboyson | 47:229338b3adcb | 46 | let elem; |
andrewboyson | 92:2d1ca4dcbca7 | 47 | elem = Ajax.getElementOrNull('ajax-tank-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(tankTemperature); |
andrewboyson | 92:2d1ca4dcbca7 | 48 | elem = Ajax.getElementOrNull('ajax-blr-out-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrOutTemperature); |
andrewboyson | 92:2d1ca4dcbca7 | 49 | elem = Ajax.getElementOrNull('ajax-blr-rtn-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrRtnTemperature); |
andrewboyson | 92:2d1ca4dcbca7 | 50 | elem = Ajax.getElementOrNull('ajax-blr-rise-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrOutTemperature - blrRtnTemperature); |
andrewboyson | 91:8b192efd0288 | 51 | |
andrewboyson | 104:46ce1aaf8be7 | 52 | elem = Ajax.getElementOrNull('ajax-blr-pump-speed-html'); if (elem) elem.textContent = blrPumpSpeed; |
andrewboyson | 104:46ce1aaf8be7 | 53 | elem = Ajax.getElementOrNull('ajax-blr-pump-pwm-html' ); if (elem) elem.textContent = blrPumpPwm; |
andrewboyson | 104:46ce1aaf8be7 | 54 | |
andrewboyson | 104:46ce1aaf8be7 | 55 | elem = Ajax.getElementOrNull('ajax-blr-call-toggle' ); if (elem) elem.setAttribute('dir', boilerCall ? 'rtl' : 'ltr'); |
andrewboyson | 104:46ce1aaf8be7 | 56 | elem = Ajax.getElementOrNull('ajax-blr-pump-toggle' ); if (elem) elem.setAttribute('dir', boilerPump ? 'rtl' : 'ltr'); |
andrewboyson | 104:46ce1aaf8be7 | 57 | elem = Ajax.getElementOrNull('ajax-tank-set-point' ); if (elem) elem.value = tankSetPoint; |
andrewboyson | 104:46ce1aaf8be7 | 58 | elem = Ajax.getElementOrNull('ajax-tank-hysteresis' ); if (elem) elem.value = tankHysteresis; |
andrewboyson | 104:46ce1aaf8be7 | 59 | elem = Ajax.getElementOrNull('ajax-blr-run-on-deg' ); if (elem) elem.value = OneWire.DS18B20ToString(blrRunOnDeg); |
andrewboyson | 104:46ce1aaf8be7 | 60 | elem = Ajax.getElementOrNull('ajax-blr-run-on-time' ); if (elem) elem.value = blrRunOnTime; |
andrewboyson | 104:46ce1aaf8be7 | 61 | |
andrewboyson | 104:46ce1aaf8be7 | 62 | elem = Ajax.getElementOrNull('ajax-pump-speed-calling'); if (elem) elem.value = pumpSpeedCalling; |
andrewboyson | 104:46ce1aaf8be7 | 63 | elem = Ajax.getElementOrNull('ajax-pump-speed-run-on' ); if (elem) elem.value = pumpSpeedRunOn; |
andrewboyson | 104:46ce1aaf8be7 | 64 | elem = Ajax.getElementOrNull('ajax-blr-output-target' ); if (elem) elem.value = blrOutputTarget; |
andrewboyson | 104:46ce1aaf8be7 | 65 | |
andrewboyson | 104:46ce1aaf8be7 | 66 | elem = Ajax.getElementOrNull('ajax-pump-rise-at-0' ); if (elem) elem.value = OneWire.DS18B20ToString(riseAt0); |
andrewboyson | 104:46ce1aaf8be7 | 67 | elem = Ajax.getElementOrNull('ajax-pump-rise-at-50' ); if (elem) elem.value = OneWire.DS18B20ToString(riseAt50); |
andrewboyson | 104:46ce1aaf8be7 | 68 | elem = Ajax.getElementOrNull('ajax-pump-rise-at-100' ); if (elem) elem.value = OneWire.DS18B20ToString(riseAt100); |
andrewboyson | 47:229338b3adcb | 69 | } |
andrewboyson | 47:229338b3adcb | 70 | |
andrewboyson | 47:229338b3adcb | 71 | Ajax.server = '/boiler-ajax'; |
andrewboyson | 47:229338b3adcb | 72 | Ajax.onResponse = function() { parse(); display(); }; |
andrewboyson | 47:229338b3adcb | 73 | Ajax.init(); |