Browse Source

more debugging for 2nd Inverter, longer fast sync polling if signal lost, see config.h

pull/478/head
golfi200 2 years ago
parent
commit
672963f7bf
  1. 12
      tools/nano/AhoyUL/src/config.h
  2. 17
      tools/nano/AhoyUL/src/main.cpp

12
tools/nano/AhoyUL/src/config.h

@ -15,6 +15,12 @@
#define DEF_RF24_CS_PIN 15 #define DEF_RF24_CS_PIN 15
#define DEF_RF24_CE_PIN 2 #define DEF_RF24_CE_PIN 2
#define DEF_RF24_IRQ_PIN 0 #define DEF_RF24_IRQ_PIN 0
#elif defined(ESP32WROOM)
// todo: not yet tested on real HW, check pins in detail
#define DEF_DEVICE_NAME "\n\n +++ AHOY-UL ESP32wroom +++"
#define DEF_RF24_CS_PIN (5)
#define DEF_RF24_CE_PIN (4)
#define DEF_RF24_IRQ_PIN (16)
#else #else
// default pinout (GPIO Number) for Arduino Nano 328p // default pinout (GPIO Number) for Arduino Nano 328p
#define DEF_DEVICE_NAME "\n\n +++ AHOY-UL A-NANO +++" #define DEF_DEVICE_NAME "\n\n +++ AHOY-UL A-NANO +++"
@ -45,8 +51,8 @@
// default send interval // default send interval
#define SEND_INTERVAL (60) //send interval if Rx OK #define SEND_INTERVAL (60) //send interval if Rx OK
#define SEND_NOSIGNAL_SHORT (10) //short send interval if no RX (used initial sync or signal loss) #define SEND_NOSIGNAL_SHORT (10) //short send interval if no RX (used initial sync or signal loss)
#define SEND_REPEAT (6) //number of tries of short send interval to sync faster to inverter after night #define SEND_REPEAT (7) //number of tries of short send interval to sync faster to inverter after night
#define SEND_NOSIGNAL_LONG (20*60) //long TX interval when no SIGNAL for long time, e.g. over night #define SEND_NOSIGNAL_LONG (21*60) //long TX interval when no SIGNAL for long time, e.g. over night
#define INVERTER_TIMEOUT_sec (SEND_INTERVAL * 2) //max duration of send to one inverter #define INVERTER_TIMEOUT_sec (SEND_INTERVAL * 2) //max duration of send to one inverter
@ -63,7 +69,7 @@
#define DEF_MAX_RETRANS_PER_PYLD 10 #define DEF_MAX_RETRANS_PER_PYLD 10
// number of seconds since last successful response, before inverter is marked inactive // number of seconds since last successful response, before inverter is marked inactive
#define INACT_THRES_SEC 300 #define INACT_THRES_SEC 370
// threshold of minimum power on which the inverter is marked as inactive // threshold of minimum power on which the inverter is marked as inactive
#define INACT_PWR_THRESH 3 #define INACT_PWR_THRESH 3

17
tools/nano/AhoyUL/src/main.cpp

@ -136,7 +136,8 @@ static uint32_t tmp32 = 0;
static uint8_t mCountdown_noSignal[MAX_NUM_INVERTERS]; // counter down of number of Inverter Requests if no response received, in dark or no signal static uint8_t mCountdown_noSignal[MAX_NUM_INVERTERS]; // counter down of number of Inverter Requests if no response received, in dark or no signal
static volatile uint32_t mSendInterval_ms[MAX_NUM_INVERTERS]; static volatile uint32_t mSendInterval_ms[MAX_NUM_INVERTERS];
static volatile uint32_t polling_req_msec[MAX_NUM_INVERTERS]; // will be set via serial interface static volatile uint32_t polling_req_msec[MAX_NUM_INVERTERS]; // will be set via serial interface
static volatile boolean m_next_invIX = false; //after successful receiving of one inverter switch to the next static volatile uint32_t mTimer_InvChange_msec[MAX_NUM_INVERTERS]; // timestamp when this inverter is left to poll the next inverter
static volatile boolean m_next_invIX = false; // after successful receiving of one inverter switch to the next
static bool iv_devControlReq = false; // this is one kind of requests, see devControlCmds static bool iv_devControlReq = false; // this is one kind of requests, see devControlCmds
static uint8_t iv_devControlCmd = ActivePowerContr; // for now the only devControlCmd static uint8_t iv_devControlCmd = ActivePowerContr; // for now the only devControlCmd
@ -181,12 +182,14 @@ void setup() {
mPayload[0].invId[0] = (uint8_t)0x01; mPayload[0].invId[0] = (uint8_t)0x01;
swap_bytes(&mPayload[0].invId[1], (uint32_t)IV1_RADIO_ID); // high byte is at lowest index swap_bytes(&mPayload[0].invId[1], (uint32_t)IV1_RADIO_ID); // high byte is at lowest index
mPayload[0].invType = (uint16_t)(IV1_RADIO_ID >> 32); // keep just upper 6 and 5th byte (e.g.0x1141) of interter plate id for type mPayload[0].invType = (uint16_t)(IV1_RADIO_ID >> 32); // keep just upper 6 and 5th byte (e.g.0x1141) of interter plate id for type
hmRadio.dumpBuf(DBG_INFO, "\nIV1 ", &mPayload[0].invId[1], 4);
//2nd inverter //2nd inverter
#if defined(IV2_RADIO_ID) #if defined(IV2_RADIO_ID)
mPayload[1].invId[0] = (uint8_t)0x01; mPayload[1].invId[0] = (uint8_t)0x01;
swap_bytes(&mPayload[1].invId[1], (uint32_t)IV2_RADIO_ID); // high byte is at lowest index swap_bytes(&mPayload[1].invId[1], (uint32_t)IV2_RADIO_ID); // high byte is at lowest index
mPayload[1].invType = (uint16_t)(IV2_RADIO_ID >> 32); // keep just upper 6 and 5th byte (e.g.0x1141) of interter plate id for type mPayload[1].invType = (uint16_t)(IV2_RADIO_ID >> 32); // keep just upper 6 and 5th byte (e.g.0x1141) of interter plate id for type
hmRadio.dumpBuf(DBG_INFO, "IV2 ", &mPayload[1].invId[1], 4);
#endif #endif
// hmRadio.dumpBuf("\nsetup InvID ", &mPayload[0].invId[0], 5, DBG_DEBUG); // hmRadio.dumpBuf("\nsetup InvID ", &mPayload[0].invId[0], 5, DBG_DEBUG);
@ -248,16 +251,18 @@ void loop() {
// automode RF-Tx-trigger // automode RF-Tx-trigger
if (automode) { if (automode) {
// increment the the inverter-index // increment the inverter-index
if ( m_next_invIX || (millis() > INVERTER_TIMEOUT_sec * 1000 && (millis() - lastInvChange_millis) > INVERTER_TIMEOUT_sec * 1000)) { if ( m_next_invIX || ((millis() > INVERTER_TIMEOUT_sec * 1000L) && ((millis() - lastInvChange_millis) > (INVERTER_TIMEOUT_sec * 1000L))) ) {
lastInvChange_millis = millis(); lastInvChange_millis = millis();
mTimer_InvChange_msec[m_inv_ix] = millis(); //store timestamp when this Inverter is left, use next for correct timing for each inverter
m_next_invIX = false; m_next_invIX = false;
DPRINT(DBG_INFO, F("Change inverter index to ")); DPRINT(DBG_INFO, F("Change inverter index "));
tmp8 = m_inv_ix; //save last valid ix value tmp8 = m_inv_ix; //save last valid ix value
m_inv_ix++; m_inv_ix++;
if (m_inv_ix >= MAX_NUM_INVERTERS) { if (m_inv_ix >= MAX_NUM_INVERTERS) {
m_inv_ix = 0; m_inv_ix = 0;
} }
tmp32 = millis() - mTimer_InvChange_msec[m_inv_ix]; //todo: time that current inverter was not polled, must be removed from current millis() for all timings aquired in the last iteration of this inverter
if (mPayload[m_inv_ix].invType == 0x0000) { if (mPayload[m_inv_ix].invType == 0x0000) {
//inverter index is invalid //inverter index is invalid
@ -275,7 +280,7 @@ void loop() {
// initial fast send as long as no rx // initial fast send as long as no rx
mSendInterval_ms[m_inv_ix] = (SEND_NOSIGNAL_SHORT * ONE_SECOND); mSendInterval_ms[m_inv_ix] = (SEND_NOSIGNAL_SHORT * ONE_SECOND);
} else if (millis() - lastRx_millis[m_inv_ix] > (8 * polling_req_msec[m_inv_ix])) { } else if (millis() - lastRx_millis[m_inv_ix] > (12 * polling_req_msec[m_inv_ix])) {
// no Rx in time reduce Tx polling // no Rx in time reduce Tx polling
if (mCountdown_noSignal[m_inv_ix] ) { if (mCountdown_noSignal[m_inv_ix] ) {
// keep fast Tx on initial no-signal for countdown > 0 // keep fast Tx on initial no-signal for countdown > 0

Loading…
Cancel
Save