Skip to content

feat: PCB_VERSION, the internal 1.1 V ADC reference of the new motherboard - #184

Merged
FredM67 merged 1 commit into
devfrom
feat/pcb-version
Oct 2, 2026
Merged

FredM67 merged 1 commit into
devfrom
feat/pcb-version

Conversation

@FredM67

@FredM67 FredM67 commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Why

The universal 3phaseDiverter board (rev. 6.0 and later) is designed for the internal 1.1 V reference of the ATmega328P. An LMV321A buffers it from AREF, and the doc says the firmware must switch it on. The firmware always selected AVCC, the reference of the old 3-phase board, so a new board measured wrongly.

The change existed on the unmerged new-pcb branch (cfe0682a, 2025-12-30). It was written for the old switch ISR, which #127 later replaced with the circular channel list, so it could not be merged as is.

What

  • config.h: a setting a user can understand:
    // Motherboard: OLD for the former 3-phase board, NEW for the universal 3phaseDiverter board
    // (rev. 6.0 and later). A wrong choice gives wrong measurements: recalibrate after a change.
    inline constexpr PcbVersion PCB_VERSION{ PcbVersion::OLD };
    OLD is the default, so existing installations behave as before.
  • processing.cpp: _ADMUX selects AVCC (OLD) or the internal 1.1 V (NEW). initializeProcessing() now writes the full ADMUX (reference, ADLAR, V1) for the first conversion too. Before, that conversion ran with REFS = 00 (external AREF) until the ISR took over.
  • The startup summary prints Motherboard: old (AVCC reference) or new (internal 1.1 V reference).
  • READMEs (EN/FR): a "Motherboard: old or new" section, with the reminder to recalibrate. CHANGELOG: an Added entry and an "Upgrading" note.

Checked

  • OLD: the ADMUX values in the channel list are unchanged (0x60 | channel). The grid simulator passes (clouds 11/11, no_surplus 7/7, surplus_step 12/12).
  • NEW: the channel list holds 0xE0 | channel and the setup writes 0xE0.
  • The simulator fails with NEW, as expected: simavr scales conversions against the 1.1 V reference while the scenarios feed signals sized for 5 V. That shows the reference really switches. Simulating the new board would need scenarios with its signal levels.
  • Native tests 172/172. Embedded tests 106/108; the 2 errors are empty local test folders, unrelated.
  • Still to do: a hardware test on a new board (VREF ≈ 1.1 V on AREF, then calibration).

Follow-ups

🤖 Generated with Claude Code

…board

The universal 3phaseDiverter board (rev. 6.0 and later) is designed for the internal 1.1 V
reference of the ATmega328P (buffered from AREF by an LMV321A), which the firmware must select.
Until now the firmware always used AVCC, the reference of the old 3-phase board, so a new board
measured wrongly. The change was on the unmerged new-pcb branch (cfe0682), written for the
ISR before the circular channel list of #127.

- config.h: PCB_VERSION, OLD (default, unchanged behaviour) or NEW;
- processing.cpp: _ADMUX selects AVCC or the internal 1.1 V, and the first conversion now uses
  it too (it ran on the AREF setting before the ISR took over);
- the startup summary shows the board;
- READMEs (EN/FR): how to choose, and to recalibrate after a change; CHANGELOG.

Checked: OLD gives the same ADMUX values as before (0x60 | channel) and passes the grid
simulator scenarios; NEW gives 0xE0 | channel.

Co-Authored-By: Claude <noreply@anthropic.com>
@FredM67
FredM67 merged commit 1bfa698 into dev Oct 2, 2026
11 checks passed
@FredM67
FredM67 deleted the feat/pcb-version branch October 2, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant