loop control commands and fixes for error disabling
This commit is contained in:
parent
e7a6a84bbc
commit
f44646bced
@ -166,10 +166,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.DTS/value=0
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.DTS/value=0
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.LOCAL/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.LOCAL/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.LOCAL/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.LOCAL/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.LOCAL/value=1483552040
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.LOCAL/value=1483571868
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.UTC/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.UTC/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.UTC/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.UTC/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.UTC/value=1483548440
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.UTC/value=1483568268
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.ZONE/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.ZONE/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.ZONE/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.ZONE/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.ZONE/value=3600
|
environment/project/it.baeyens.arduino.core.toolChain.release.1227494943/A.EXTRA.TIME.ZONE/value=3600
|
||||||
|
@ -176,7 +176,7 @@ void MeterBusMaster::sendBufferReady(uint16_t sendBufLen, uint8_t token, char *n
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MeterBusMaster::prepareResponse(bool err, uint8_t in) {
|
void MeterBusMaster::prepareResponse(bool err, uint8_t in) {
|
||||||
//Serial << "resp in, err: " << err << endl;
|
Serial << "resp in, err: " << err << endl;
|
||||||
static int16_t expectedChars = -1;
|
static int16_t expectedChars = -1;
|
||||||
static uint8_t state = 0;
|
static uint8_t state = 0;
|
||||||
|
|
||||||
@ -187,6 +187,7 @@ void MeterBusMaster::prepareResponse(bool err, uint8_t in) {
|
|||||||
uint8_t errorCode = 0;
|
uint8_t errorCode = 0;
|
||||||
if (m_disabled) {
|
if (m_disabled) {
|
||||||
errorCode = 2;
|
errorCode = 2;
|
||||||
|
m_disableDelay = 0;
|
||||||
} else {
|
} else {
|
||||||
errorCode = 1;
|
errorCode = 1;
|
||||||
m_disableDelay++;
|
m_disableDelay++;
|
||||||
@ -277,14 +278,14 @@ void MeterBusMaster::disableLoop() {
|
|||||||
if (! m_loopIsDisabled) {
|
if (! m_loopIsDisabled) {
|
||||||
m_loopIsDisabled = true;
|
m_loopIsDisabled = true;
|
||||||
m_disableTime = millis();
|
m_disableTime = millis();
|
||||||
|
digitalWrite(CURRENT_SHUTDOWN, CURRENT_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeterBusMaster::enableLoop() {
|
void MeterBusMaster::enableLoop() {
|
||||||
if (m_loopIsDisabled) {
|
if (m_loopIsDisabled) {
|
||||||
m_loopIsDisabled = false;
|
m_loopIsDisabled = false;
|
||||||
|
digitalWrite(CURRENT_SHUTDOWN, CURRENT_ON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,6 +324,7 @@ void MeterBusMaster::exec() {
|
|||||||
disableLoop();
|
disableLoop();
|
||||||
|
|
||||||
if (m_loopIsDisabled && ((millis() - m_disableTime) > DISABLE_TIMEOUT)) {
|
if (m_loopIsDisabled && ((millis() - m_disableTime) > DISABLE_TIMEOUT)) {
|
||||||
|
m_disabled = false;
|
||||||
enableLoop();
|
enableLoop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,11 @@ const uint8_t RX_EN_PIN = 2;
|
|||||||
const uint8_t RX_ENABLE = LOW;
|
const uint8_t RX_ENABLE = LOW;
|
||||||
const uint8_t RX_DISABLE = HIGH;
|
const uint8_t RX_DISABLE = HIGH;
|
||||||
|
|
||||||
|
const uint8_t CURRENT_SHUTDOWN = 5;
|
||||||
|
const uint8_t CURRENT_ON = LOW;
|
||||||
|
const uint8_t CURRENT_OFF = HIGH;
|
||||||
|
|
||||||
|
|
||||||
const uint8_t CURRENT_IN = A1;
|
const uint8_t CURRENT_IN = A1;
|
||||||
const double U_UNIT = 4.9; // mV
|
const double U_UNIT = 4.9; // mV
|
||||||
const double R_SHUNT = 10.0;
|
const double R_SHUNT = 10.0;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "overCurrentProt.h"
|
#include "overCurrentProt.h"
|
||||||
|
#include <Streaming.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -22,20 +23,39 @@ OverCurrentProtCmd::OverCurrentProtCmd(OverCurrentProt *overCurrentProt) : m_ove
|
|||||||
}
|
}
|
||||||
|
|
||||||
String OverCurrentProtCmd::exec(String params) {
|
String OverCurrentProtCmd::exec(String params) {
|
||||||
return String("") + m_overCurrentProt->getEventCnt();
|
String res = "done";
|
||||||
}
|
|
||||||
|
|
||||||
OverCurrentResetCmd::OverCurrentResetCmd(OverCurrentProt *overCurrentProt) : m_overCurrentProt(overCurrentProt) {
|
Print *out = m_server;
|
||||||
}
|
if (params.equalsIgnoreCase("help")) {
|
||||||
|
*out << "help ..... this help page" << endl;
|
||||||
String OverCurrentResetCmd::exec(String params) {
|
*out << "show ..... show statistics" << endl;
|
||||||
|
*out << "reset .... reset statistics" << endl;
|
||||||
|
*out << "disable .. disable loop" << endl;
|
||||||
|
*out << "enable ... enable loop" << endl;
|
||||||
|
*out << endl;
|
||||||
|
} else if (params.equalsIgnoreCase("enable")) {
|
||||||
|
digitalWrite(CURRENT_SHUTDOWN, CURRENT_ON);
|
||||||
|
*out << "Loop enabled" << endl;
|
||||||
|
} else if (params.equalsIgnoreCase("disable")) {
|
||||||
|
digitalWrite(CURRENT_SHUTDOWN, CURRENT_OFF);
|
||||||
|
*out << "Loop disabled" << endl;
|
||||||
|
} else if (params.equalsIgnoreCase("show")) {
|
||||||
|
*out << "Over current counter: " << m_overCurrentProt->getEventCnt() << endl;
|
||||||
|
} else if (params.equalsIgnoreCase("reset")) {
|
||||||
m_overCurrentProt->resetEventCnt();
|
m_overCurrentProt->resetEventCnt();
|
||||||
return "done";
|
*out << "Over current counter reseted" << endl;
|
||||||
|
} else {
|
||||||
|
*out << "unknown subcommand" << endl;
|
||||||
|
res = "failed";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
OverCurrentProt::OverCurrentProt() : m_overCurrentProtCmd(this), m_overCurrentResetCmd(this),
|
|
||||||
|
|
||||||
|
OverCurrentProt::OverCurrentProt() : m_overCurrentProtCmd(this),
|
||||||
m_eventCnt(0), m_timestamp(0) {
|
m_eventCnt(0), m_timestamp(0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -43,7 +63,6 @@ OverCurrentProt::OverCurrentProt() : m_overCurrentProtCmd(this), m_overCurrentRe
|
|||||||
|
|
||||||
void OverCurrentProt::begin(CmdServer *cmdServer) {
|
void OverCurrentProt::begin(CmdServer *cmdServer) {
|
||||||
m_overCurrentProtCmd.registerYourself(cmdServer);
|
m_overCurrentProtCmd.registerYourself(cmdServer);
|
||||||
m_overCurrentResetCmd.registerYourself(cmdServer);
|
|
||||||
pinMode(CURRENT_SHUTDOWN, OUTPUT);
|
pinMode(CURRENT_SHUTDOWN, OUTPUT);
|
||||||
digitalWrite(CURRENT_SHUTDOWN, CURRENT_ON);
|
digitalWrite(CURRENT_SHUTDOWN, CURRENT_ON);
|
||||||
overCurrentMarker = false;
|
overCurrentMarker = false;
|
||||||
|
@ -18,22 +18,13 @@ class OverCurrentProt;
|
|||||||
class OverCurrentProtCmd : public Cmd {
|
class OverCurrentProtCmd : public Cmd {
|
||||||
public:
|
public:
|
||||||
OverCurrentProtCmd(OverCurrentProt *overCurrentProt);
|
OverCurrentProtCmd(OverCurrentProt *overCurrentProt);
|
||||||
virtual String getCmdName() { return "OCPC"; }
|
virtual String getCmdName() { return "LC"; }
|
||||||
virtual String getHelp() { return "OCP count"; }
|
virtual String getHelp() { return "Loop control"; }
|
||||||
virtual String exec(String params);
|
virtual String exec(String params);
|
||||||
private:
|
private:
|
||||||
OverCurrentProt *m_overCurrentProt;
|
OverCurrentProt *m_overCurrentProt;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OverCurrentResetCmd : public Cmd {
|
|
||||||
public:
|
|
||||||
OverCurrentResetCmd(OverCurrentProt *overCurrentProt);
|
|
||||||
virtual String getCmdName() { return "OCRST"; }
|
|
||||||
virtual String getHelp() { return "OCP reset"; }
|
|
||||||
virtual String exec(String params);
|
|
||||||
private:
|
|
||||||
OverCurrentProt *m_overCurrentProt;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +37,6 @@ public:
|
|||||||
void resetEventCnt() { m_eventCnt = 0; };
|
void resetEventCnt() { m_eventCnt = 0; };
|
||||||
private:
|
private:
|
||||||
OverCurrentProtCmd m_overCurrentProtCmd;
|
OverCurrentProtCmd m_overCurrentProtCmd;
|
||||||
OverCurrentResetCmd m_overCurrentResetCmd;
|
|
||||||
uint32_t m_eventCnt;
|
uint32_t m_eventCnt;
|
||||||
unsigned long m_timestamp;
|
unsigned long m_timestamp;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user