3-phase PV router
Loading...
Searching...
No Matches
adc_chain.h File Reference

The six ADC conversions of the 3-phase board, and the ADMUX pipeline of the free-running ADC. More...

#include <stdint.h>
#include "config_types.h"
Include dependency graph for adc_chain.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  AdcChain
 

Enumerations

enum class  AdcChain::Channel : uint8_t {
  AdcChain::V1 , AdcChain::I1 , AdcChain::V2 , AdcChain::I2 ,
  AdcChain::V3 , AdcChain::I3
}
 

Functions

constexpr uint8_t AdcChain::admuxOf (const PcbVersion board, const Channel ch)
 The ADMUX value that converts a channel: reference, left-adjusted result, analog input.
 
constexpr uint8_t AdcChain::admuxWrittenAfter (const PcbVersion board, const Channel converted)
 The ADMUX value the interrupt writes after the conversion of a channel.
 
constexpr Channel AdcChain::channelAfterNext (const Channel ch)
 The channel two steps after another one in the chain V1, I1, V2, I2, V3, I3.
 
constexpr Channel AdcChain::channelConverted (const uint8_t round)
 The channel round round converts, once the pipeline is full.
 
constexpr uint8_t AdcChain::pinOf (const Channel ch)
 The analog input of a channel (A0 = 0).
 
constexpr uint8_t AdcChain::refBits (const PcbVersion board)
 The reference bits of ADMUX on a board.
 

Variables

constexpr uint8_t AdcChain::BIT_ADLAR { 5 }
 
constexpr uint8_t AdcChain::BIT_REFS0 { 6 }
 
constexpr uint8_t AdcChain::BIT_REFS1 { 7 }
 
constexpr uint8_t AdcChain::NO_OF_CONVERSIONS { 6 }
 

Detailed Description

The six ADC conversions of the 3-phase board, and the ADMUX pipeline of the free-running ADC.

Author
Frédéric Metrich (frede.nosp@m.ric..nosp@m.metri.nosp@m.ch@l.nosp@m.ive.f.nosp@m.r)
Version
1.0
Date
2026-11-22

The ADC converts six channels in a fixed chain, V1, I1, V2, I2, V3, I3, each about every 104 us (13 ADC clocks at F_CPU / 128). The analog input of a conversion is its place in the chain: A0 to A5.

The ADC runs free: when the interrupt of a finished conversion runs, the next conversion has already started with the previous ADMUX. The ADMUX written now applies to the conversion after next, so after the conversion of a channel the interrupt writes the channel two steps ahead in the chain.

Pure C++, no Arduino: the native tests include it. The ADMUX bit numbers are those of the ATmega328P (processing.cpp checks them against avr/io.h).

Definition in file adc_chain.h.