fine tuning Firmware in version V0.6, testing and declaring Version 1.0 of firmware
This commit is contained in:
1 parent
80e42f1952
commit
128f5ce40a
2 files changed
+182
-54
No files matched your search
@@ -8,13 +8,26 @@
|
||||
=============================================================================
|
||||
Project definitions, sources
|
||||
-----------------------------------------------------------------------------
|
||||
Version : 0.5 - ATTiny85, 1 MHz, BOD fuse disabled
|
||||
used Flash: 1284 bytes
|
||||
Version : 1.0 - ATTiny85, 1 MHz, BOD fuse disabled
|
||||
used Flash: 1226 bytes
|
||||
|
||||
gitea : https://gitea.togo-lab.io/tgohle/0001-FireFly
|
||||
Date : 2026-11-10
|
||||
|
||||
Date : 2026-11-14
|
||||
|
||||
|
||||
Version 1.0 = the Version 0.6 code, declared stable after bench tests (boot
|
||||
marker, deliberate hang test with watchdog recovery) and a run-down test on one
|
||||
charge down to a supercap voltage below 0.6 V ahead of the DC/DC converter.
|
||||
Not yet confirmed: behaviour on warm/hot (25-40 C) summer nights, see darkSteps.
|
||||
|
||||
Key changes Version 0.6 (goal: stable, unattended running for years):
|
||||
|
||||
- Watchdog now runs in interrupt AND reset mode (WDE = 1). If the main code
|
||||
does not reach the next sleepWdt() within one watchdog timeout, the chip
|
||||
resets instead of hanging forever. Every awake stretch is only microseconds
|
||||
long and every sleepWdt() call re-arms the watchdog, so this never triggers
|
||||
in normal operation. After such a reset the normal recovery wait applies.
|
||||
|
||||
Key changes Version 0.5 (goal: lowest possible average current):
|
||||
|
||||
- No delay(), no millis(): Timer0 and Timer1 are not needed any more and
|
||||
@@ -32,15 +45,16 @@ Key changes Version 0.5 (goal: lowest possible average current):
|
||||
- Startup code saves MCUSR and disables the watchdog early (.init3), avoiding
|
||||
a watchdog-reset loop before setup() can execute.
|
||||
- Optional: BOD disable during sleep (only useful if BOD fuse is enabled).
|
||||
But found out that also BOD Fuse for 1.8V shorten unnecessary blinking time,
|
||||
will still work ~1V, meaning ~20 min longer blinking time.
|
||||
But found out that the BOD fuse for 1.8V shortens the useful blinking time:
|
||||
without BOD the chip still works down to ~1V, meaning ~20 min longer
|
||||
blinking time. So the BOD fuse stays disabled.
|
||||
- Field Test: After a sunny day in Winter, outdoor -1 ... 8°C, with a payload
|
||||
of 10 signs) it blinks for >> 12h.
|
||||
|
||||
Timing note: the watchdog oscillator is not precise (changes with Vcc and
|
||||
temperature). All Morse timing comes from the same clock, so dit/dah/gap
|
||||
ratios stay correct; only the absolute speed drifts a little.
|
||||
The HW actual allowes 5V and 3.3V, standard is 3.3V. So don't expec exact timing.
|
||||
The HW actually allows 5V and 3.3V, standard is 3.3V. So don't expect exact timing.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
@@ -67,7 +81,7 @@ Inspired by Karl Lunt's FireFly project:
|
||||
'!', "-.-.--" ':', "---..." ';', "-.-.-."
|
||||
'(', "-.--." ')', "-.--.-" '"', ".-..-."
|
||||
'@', ".--.-." '&', ".-..." '-', "-....-"
|
||||
'/', "-..-." ''', ".----." '+', ".-.-."
|
||||
'/', "-..-." ''', ".----." '+', ".-.-."
|
||||
'=', "-...-" '_', "..--.-"
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
@@ -130,6 +144,9 @@ const uint8_t sleepCycles = 5;
|
||||
// The window costs almost no energy (CPU sleeps), so it is only a threshold.
|
||||
// Calibrate at real dusk. Old threshold 17000 loops: measure the old
|
||||
// sensDarkness() time with micros() at your dusk level and divide it by 16 ms.
|
||||
// LED leakage rises with temperature: the discharge time in real darkness
|
||||
// gets shorter when warm. If it blinks in winter but not on warm summer
|
||||
// nights, lower this value.
|
||||
const uint8_t darkSteps = 40; // ~640 ms
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -290,6 +307,11 @@ ISR(WDT_vect)
|
||||
// Sleep in POWER-DOWN until the watchdog interrupt fires after timeout code ii
|
||||
// (0=16 ms ... 9=8 s). Reconfigures the watchdog on every call, so the full
|
||||
// interval always starts fresh.
|
||||
//
|
||||
// The watchdog runs in interrupt AND reset mode (WDE = 1, WDIE = 1):
|
||||
// the first timeout raises the interrupt (and hardware clears WDIE), a second
|
||||
// timeout without a new sleepWdt() call resets the chip. So a hang anywhere
|
||||
// in the main code ends in a reset instead of a dead firefly.
|
||||
static void sleepWdt(uint8_t ii)
|
||||
{
|
||||
if (ii > 9) ii = 9;
|
||||
@@ -297,8 +319,8 @@ static void sleepWdt(uint8_t ii)
|
||||
uint8_t bb = ii & 7;
|
||||
if (ii > 7) bb |= (1 << WDP3);
|
||||
|
||||
// Interrupt-only mode (WDE = 0). WDIF written as 1 clears a stale flag.
|
||||
const uint8_t cfg = bb | (1 << WDIE) | (1 << WDIF);
|
||||
// Interrupt + system reset mode. WDIF written as 1 clears a stale flag.
|
||||
const uint8_t cfg = bb | (1 << WDIE) | (1 << WDE) | (1 << WDIF);
|
||||
|
||||
f_wdt = false;
|
||||
cli();
|
||||
@@ -483,7 +505,7 @@ void morse(int LED_N, int LED_P)
|
||||
case '&': dit(LED_P); dah(LED_P); dit(LED_P); dit(LED_P); dit(LED_P); symbolSent = true; break; // .-...
|
||||
case '-': dah(LED_P); dit(LED_P); dit(LED_P); dit(LED_P); dit(LED_P); dah(LED_P); symbolSent = true; break; // -....-
|
||||
case '/': dah(LED_P); dit(LED_P); dit(LED_P); dah(LED_P); dit(LED_P); symbolSent = true; break; // -..-.
|
||||
case '\'': dit(LED_P); dah(LED_P); dah(LED_P);dah(LED_P); dah(LED_P); dit(LED_P); symbolSent = true; break; // .----.
|
||||
case '\'': dit(LED_P); dah(LED_P); dah(LED_P); dah(LED_P); dah(LED_P); dit(LED_P); symbolSent = true; break; // .----.
|
||||
case '+': dit(LED_P); dah(LED_P); dit(LED_P); dah(LED_P); dit(LED_P); symbolSent = true; break; // .-.-.
|
||||
case '=': dah(LED_P); dit(LED_P); dit(LED_P); dit(LED_P); dah(LED_P); symbolSent = true; break; // -...-
|
||||
case '_': dit(LED_P); dit(LED_P); dah(LED_P); dah(LED_P); dit(LED_P); dah(LED_P); symbolSent = true; break; // ..--.-
|
||||
|
||||
Reference in new issue
Block a user