Added ADC measurements
This commit is contained in:
@ -14,6 +14,7 @@ from .constants import (
|
||||
RREF,
|
||||
BETA_INTERNAL, BETA_EXTERNAL, T0_K, R0,
|
||||
ADC_BITS_16, ADC_BITS_12,
|
||||
STM32_ADC_PIN_VREF,
|
||||
U3V3_COEFF, U5V_COEFF, U7V_COEFF,
|
||||
)
|
||||
|
||||
@ -111,4 +112,15 @@ def voltage_5v_n_to_v(n: int) -> float:
|
||||
|
||||
def voltage_7v_n_to_v(n: int) -> float:
|
||||
"""Convert 7V rail ADC count to volts."""
|
||||
return n * U7V_COEFF
|
||||
return n * U7V_COEFF
|
||||
|
||||
|
||||
def stm32_adc_pin_n_to_v(n: int) -> float:
|
||||
"""
|
||||
Convert a raw 12-bit STM32 ADC code from a direct MCU input pin to volts.
|
||||
|
||||
The new auxiliary telemetry channels are measured directly on PF3/PF4
|
||||
without an external divider in the firmware path, so the conversion is a
|
||||
plain ratio against the MCU analog reference rail.
|
||||
"""
|
||||
return n * STM32_ADC_PIN_VREF / ADC_BITS_12
|
||||
|
||||
Reference in New Issue
Block a user