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

Committer:
andrewboyson
Date:
Fri Apr 23 08:36:42 2021 +0000
Revision:
106:41ed3ea0bbba
Parent:
105:1899f7ed17ec
Not working, crashes.

Who changed what in which revision?

UserRevisionLine numberNew 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 105:1899f7ed17ec 8 let blrAlnTemperature = '';
andrewboyson 105:1899f7ed17ec 9 let blrDeltaT = '';
andrewboyson 105:1899f7ed17ec 10 let boilerEnable = false;
andrewboyson 91:8b192efd0288 11 let boilerCall = false;
andrewboyson 91:8b192efd0288 12 let boilerPump = false;
andrewboyson 105:1899f7ed17ec 13 let fullSpeedSecs = '';
andrewboyson 91:8b192efd0288 14 let tankSetPoint = '';
andrewboyson 91:8b192efd0288 15 let tankHysteresis = '';
andrewboyson 91:8b192efd0288 16 let blrRunOnDeg = '';
andrewboyson 91:8b192efd0288 17 let blrRunOnTime = '';
andrewboyson 104:46ce1aaf8be7 18 let blrPumpSpeed = '';
andrewboyson 104:46ce1aaf8be7 19 let blrPumpPwm = '';
andrewboyson 104:46ce1aaf8be7 20 let pumpSpeedCalling = '';
andrewboyson 104:46ce1aaf8be7 21 let pumpSpeedRunOn = '';
andrewboyson 104:46ce1aaf8be7 22 let blrOutputTarget = '';
andrewboyson 106:41ed3ea0bbba 23 let minSpeed = '';
andrewboyson 104:46ce1aaf8be7 24 let riseAt50 = '';
andrewboyson 104:46ce1aaf8be7 25 let riseAt100 = '';
andrewboyson 47:229338b3adcb 26
andrewboyson 47:229338b3adcb 27 function parse()
andrewboyson 47:229338b3adcb 28 {
andrewboyson 47:229338b3adcb 29 let lines = Ajax.response.split('\n');
andrewboyson 104:46ce1aaf8be7 30 tankTemperature = Ajax.hexToSignedInt16(lines[ 0]);
andrewboyson 104:46ce1aaf8be7 31 blrOutTemperature = Ajax.hexToSignedInt16(lines[ 1]);
andrewboyson 104:46ce1aaf8be7 32 blrRtnTemperature = Ajax.hexToSignedInt16(lines[ 2]);
andrewboyson 105:1899f7ed17ec 33 blrAlnTemperature = Ajax.hexToSignedInt16(lines[ 3]);
andrewboyson 105:1899f7ed17ec 34 blrDeltaT = Ajax.hexToSignedInt16(lines[ 4]);
andrewboyson 105:1899f7ed17ec 35 boilerCall = Ajax.hexToBit (lines[ 5], 0);
andrewboyson 105:1899f7ed17ec 36 boilerPump = Ajax.hexToBit (lines[ 5], 1);
andrewboyson 105:1899f7ed17ec 37 boilerEnable = Ajax.hexToBit (lines[ 5], 2);
andrewboyson 105:1899f7ed17ec 38 fullSpeedSecs = Ajax.hexToSignedInt16(lines[ 6]);
andrewboyson 105:1899f7ed17ec 39 tankSetPoint = Ajax.hexToSignedInt16(lines[ 7]);
andrewboyson 105:1899f7ed17ec 40 tankHysteresis = Ajax.hexToSignedInt16(lines[ 8]);
andrewboyson 105:1899f7ed17ec 41 blrRunOnDeg = Ajax.hexToSignedInt16(lines[ 9]);
andrewboyson 105:1899f7ed17ec 42 blrRunOnTime = Ajax.hexToSignedInt16(lines[10]);
andrewboyson 105:1899f7ed17ec 43 blrPumpSpeed = Ajax.hexToSignedInt16(lines[11]);
andrewboyson 105:1899f7ed17ec 44 blrPumpPwm = Ajax.hexToSignedInt16(lines[12]);
andrewboyson 105:1899f7ed17ec 45 pumpSpeedCalling = Ajax.hexToSignedInt16(lines[13]);
andrewboyson 105:1899f7ed17ec 46 if (pumpSpeedCalling == -1) pumpSpeedCalling = 'A';
andrewboyson 105:1899f7ed17ec 47 if (pumpSpeedCalling == -2) pumpSpeedCalling = 'T';
andrewboyson 105:1899f7ed17ec 48 pumpSpeedRunOn = Ajax.hexToSignedInt16(lines[14]);
andrewboyson 105:1899f7ed17ec 49 blrOutputTarget = Ajax.hexToSignedInt16(lines[15]);
andrewboyson 106:41ed3ea0bbba 50 minSpeed = Ajax.hexToSignedInt16(lines[16]);
andrewboyson 105:1899f7ed17ec 51 riseAt50 = Ajax.hexToSignedInt16(lines[17]);
andrewboyson 105:1899f7ed17ec 52 riseAt100 = Ajax.hexToSignedInt16(lines[18]);
andrewboyson 47:229338b3adcb 53 }
andrewboyson 47:229338b3adcb 54 function display()
andrewboyson 47:229338b3adcb 55 {
andrewboyson 47:229338b3adcb 56 let elem;
andrewboyson 92:2d1ca4dcbca7 57 elem = Ajax.getElementOrNull('ajax-tank-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(tankTemperature);
andrewboyson 92:2d1ca4dcbca7 58 elem = Ajax.getElementOrNull('ajax-blr-out-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrOutTemperature);
andrewboyson 92:2d1ca4dcbca7 59 elem = Ajax.getElementOrNull('ajax-blr-rtn-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrRtnTemperature);
andrewboyson 105:1899f7ed17ec 60 elem = Ajax.getElementOrNull('ajax-blr-aln-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrAlnTemperature);
andrewboyson 105:1899f7ed17ec 61 elem = Ajax.getElementOrNull('ajax-blr-rise-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrDeltaT);
andrewboyson 91:8b192efd0288 62
andrewboyson 104:46ce1aaf8be7 63 elem = Ajax.getElementOrNull('ajax-blr-pump-speed-html'); if (elem) elem.textContent = blrPumpSpeed;
andrewboyson 104:46ce1aaf8be7 64 elem = Ajax.getElementOrNull('ajax-blr-pump-pwm-html' ); if (elem) elem.textContent = blrPumpPwm;
andrewboyson 104:46ce1aaf8be7 65
andrewboyson 105:1899f7ed17ec 66 elem = Ajax.getElementOrNull('ajax-blr-call-toggle' ); if (elem) elem.setAttribute('dir', boilerCall ? 'rtl' : 'ltr');
andrewboyson 105:1899f7ed17ec 67 elem = Ajax.getElementOrNull('ajax-blr-pump-toggle' ); if (elem) elem.setAttribute('dir', boilerPump ? 'rtl' : 'ltr');
andrewboyson 105:1899f7ed17ec 68 elem = Ajax.getElementOrNull('ajax-blr-enable-toggle' ); if (elem) elem.setAttribute('dir', boilerEnable ? 'rtl' : 'ltr');
andrewboyson 105:1899f7ed17ec 69 elem = Ajax.getElementOrNull('ajax-full-speed-secs' ); if (elem) elem.value = fullSpeedSecs;
andrewboyson 104:46ce1aaf8be7 70 elem = Ajax.getElementOrNull('ajax-tank-set-point' ); if (elem) elem.value = tankSetPoint;
andrewboyson 104:46ce1aaf8be7 71 elem = Ajax.getElementOrNull('ajax-tank-hysteresis' ); if (elem) elem.value = tankHysteresis;
andrewboyson 104:46ce1aaf8be7 72 elem = Ajax.getElementOrNull('ajax-blr-run-on-deg' ); if (elem) elem.value = OneWire.DS18B20ToString(blrRunOnDeg);
andrewboyson 104:46ce1aaf8be7 73 elem = Ajax.getElementOrNull('ajax-blr-run-on-time' ); if (elem) elem.value = blrRunOnTime;
andrewboyson 104:46ce1aaf8be7 74
andrewboyson 104:46ce1aaf8be7 75 elem = Ajax.getElementOrNull('ajax-pump-speed-calling'); if (elem) elem.value = pumpSpeedCalling;
andrewboyson 104:46ce1aaf8be7 76 elem = Ajax.getElementOrNull('ajax-pump-speed-run-on' ); if (elem) elem.value = pumpSpeedRunOn;
andrewboyson 104:46ce1aaf8be7 77 elem = Ajax.getElementOrNull('ajax-blr-output-target' ); if (elem) elem.value = blrOutputTarget;
andrewboyson 104:46ce1aaf8be7 78
andrewboyson 106:41ed3ea0bbba 79 elem = Ajax.getElementOrNull('ajax-min-speed-value' ); if (elem) elem.value = minSpeed;
andrewboyson 106:41ed3ea0bbba 80 elem = Ajax.getElementOrNull('ajax-min-speed-text' ); if (elem) elem.textContent = minSpeed;
andrewboyson 105:1899f7ed17ec 81 elem = Ajax.getElementOrNull('ajax-pump-rise-at-50' ); if (elem) elem.value = riseAt50;
andrewboyson 104:46ce1aaf8be7 82 elem = Ajax.getElementOrNull('ajax-pump-rise-at-100' ); if (elem) elem.value = OneWire.DS18B20ToString(riseAt100);
andrewboyson 47:229338b3adcb 83 }
andrewboyson 47:229338b3adcb 84
andrewboyson 47:229338b3adcb 85 Ajax.server = '/boiler-ajax';
andrewboyson 47:229338b3adcb 86 Ajax.onResponse = function() { parse(); display(); };
andrewboyson 47:229338b3adcb 87 Ajax.init();