BUG FIX - E-01 fired upon reboots with premature low volt detection

Improvement - /update and /reboot now have a post event status sequence during reboot.
This commit is contained in:
Ray Jones 2019-07-23 21:11:29 +10:00
parent db3343d362
commit cb79fd5dd0
6 changed files with 40 additions and 29 deletions

View file

@ -903,7 +903,7 @@ bool validateFrame(const CProtocol& frame, const char* name)
void requestOn()
{
if(SmartError.checkVolts(FilteredSamples.FastipVolts.getValue(), FilteredSamples.FastGlowAmps.getValue())) {
if(bHasHtrData && SmartError.checkVolts(FilteredSamples.FastipVolts.getValue(), FilteredSamples.FastGlowAmps.getValue())) {
heaterOn();
RTC_Store.setCyclicEngaged(true); // for cyclic mode
}

View file

@ -136,7 +136,7 @@ CScreenHeader::animate()
showTimers();
switch(_batteryCount) {
case 3:
if(SmartError.checkVolts(FilteredSamples.FastipVolts.getValue(), FilteredSamples.FastGlowAmps.getValue())) {
if(SmartError.checkVolts(FilteredSamples.FastipVolts.getValue(), FilteredSamples.FastGlowAmps.getValue(), false)) { // check but do not fault
showBatteryIcon(getBatteryVoltage(true));
}
else {

View file

@ -34,9 +34,9 @@ CSmartError::CSmartError()
void
CSmartError::reset()
{
m_prevRunState = 0;
m_Error = 0;
m_bInhibit = false;
_prevRunState = 0;
_Error = 0;
_bInhibit = false;
}
// we use inhibit when we manually command the heater off during preheat
@ -44,7 +44,7 @@ CSmartError::reset()
void
CSmartError::inhibit()
{
m_bInhibit = true;
_bInhibit = true;
// m_Error = 0;
}
@ -71,33 +71,33 @@ CSmartError::monitor(uint8_t newRunState)
{
// check if moving away from heater Idle state (S0)
// especially useful if an OEM controller exists
if((m_prevRunState == 0) && newRunState) {
if((_prevRunState == 0) && newRunState) {
// reset the smart error
m_Error = 0;
m_bInhibit = false;
_Error = 0;
_bInhibit = false;
}
if(!m_bInhibit) {
if(m_prevRunState == 2) { // preheat state (S2)
if(!_bInhibit) {
if(_prevRunState == 2) { // preheat state (S2)
if(newRunState == 4) {
// transitioned from preheat to ignited
// - all good!
m_Error = 0;
_Error = 0;
}
else if(newRunState > 5) {
// transitioned from preheat to post glow
// - second ignition attempt failed, heater is shutting down
m_Error = 11; // +1 over displayed error code
_Error = 11; // +1 over displayed error code
}
else if(newRunState == 3) {
// transitioned from preheat to retry
// - first ignition attempt failed, heater will retry
m_Error = 12; // +1 over displayed error code
_Error = 12; // +1 over displayed error code
}
}
}
if(m_prevRunState != newRunState) {
if(_prevRunState != newRunState) {
// check for transition to startup
// - force cancellation of an on request if we generated it
if(newRunState >= 2) {
@ -110,11 +110,11 @@ CSmartError::monitor(uint8_t newRunState)
}
}
m_prevRunState = newRunState;
_prevRunState = newRunState;
}
bool
CSmartError::checkVolts(float ipVolts, float glowI)
CSmartError::checkVolts(float ipVolts, float glowI, bool throwfault)
{
// check for low voltage
// values here are x10 integers
@ -122,20 +122,23 @@ CSmartError::checkVolts(float ipVolts, float glowI)
float cableComp = glowI * 0.1; // allow 1V drop for 10A current (bit naive but better than no compensation)
float Thresh = NVstore.getHeaterTuning().getLVC() - cableComp; // NVstore
if(ipVolts < Thresh) {
m_Error = 2; // +1 over displayed error code
requestOff();
if(throwfault) {
_Error = 2; // +1 over displayed error code
requestOff();
}
return false;
}
}
return true;
}
// return our smart error, if it exists, as the registered code
uint8_t
CSmartError::getError()
{
if(m_Error) {
return m_Error;
if(_Error) {
return _Error;
}
return 0;
}

View file

@ -22,16 +22,16 @@
#include "Protocol.h"
class CSmartError {
uint8_t m_prevRunState;
uint8_t m_Error;
bool m_bInhibit;
uint8_t _prevRunState;
uint8_t _Error;
bool _bInhibit;
public:
CSmartError();
void reset();
void inhibit();
void monitor(const CProtocol& heaterFrame);
void monitor(uint8_t runstate);
bool checkVolts(float volts, float plugI);
bool checkVolts(float volts, float plugI, bool throwfault=true);
uint8_t getError();
};

View file

@ -55,9 +55,9 @@ struct sHeaterTuning : public CESP32_NVStorage {
retval &= INBOUNDS(glowDrive, 1, 6);
retval &= INBOUNDS(pumpCal, 0.001, 1.0);
if(sysVoltage == 120)
retval &= INBOUNDS(lowVolts, 100, 125);
retval &= INBOUNDS(lowVolts, 100, 125) || (lowVolts == 0);
else
retval &= INBOUNDS(lowVolts, 200, 250);
retval &= INBOUNDS(lowVolts, 200, 250 || (lowVolts == 0));
retval &= INBOUNDS(tempOfs, -10, +10);
return retval;
};

View file

@ -351,7 +351,11 @@ function completeHandler(event) {
_('loaded_n_total').innerHTML = 'Uploaded ' + sendSize + ' bytes of ' + sendSize;
var file = _('file1').files[0];
if(file.name.endsWith('.bin')) {
setTimeout( function() { location.assign('/'); }, 5000);
_('status').innerHTML='Rebooting NOW';
setTimeout(function () { _('status').innerHTML='Rebooted'; }, 2000);
setTimeout(function () { _('status').innerHTML='Initialising...'; }, 4000);
setTimeout(function () { _('status').innerHTML='Loading /Index.html...'; }, 6000);
setTimeout(function () { location.assign('/'); }, 6500);
}
else {
setTimeout( function() { location.assign('/update'); }, 500);
@ -943,7 +947,11 @@ body {
<script>
function onReboot() {
if(confirm('Do you really want to reboot the Afterburner ?')) {
setTimeout(function () { location.assign('/'); }, 2000);
_('info').innerHTML='Rebooting NOW';
setTimeout(function () { _('info').innerHTML='Rebooted'; }, 2000);
setTimeout(function () { _('info').innerHTML='Initialising...'; }, 4000);
setTimeout(function () { _('info').innerHTML='Loading /Index.html...'; }, 6000);
setTimeout(function () { location.assign('/'); }, 6500);
var formdata = new FormData();
formdata.append('reboot', 'yes');
var ajax = new XMLHttpRequest();