aboutsummaryrefslogtreecommitdiff
path: root/hw/hank/emisar-d3aa
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-03-04 06:18:26 -0700
committerSelene ToyKeeper2024-03-04 06:18:26 -0700
commitd623fe5a1bbe02d680094eae5c16cdc83732a984 (patch)
tree5bd830670b5d29ff3324447971eec79ee22009b2 /hw/hank/emisar-d3aa
parentMerge branch 'trunk' into emisar-d3aa (diff)
downloadanduril-d623fe5a1bbe02d680094eae5c16cdc83732a984.tar.gz
anduril-d623fe5a1bbe02d680094eae5c16cdc83732a984.tar.bz2
anduril-d623fe5a1bbe02d680094eae5c16cdc83732a984.zip
d3aa: fixed voltage measurement
Diffstat (limited to '')
-rw-r--r--hw/hank/emisar-d3aa/anduril.h4
-rw-r--r--hw/hank/emisar-d3aa/hwdef.c2
-rw-r--r--hw/hank/emisar-d3aa/hwdef.h3
3 files changed, 5 insertions, 4 deletions
diff --git a/hw/hank/emisar-d3aa/anduril.h b/hw/hank/emisar-d3aa/anduril.h
index 3d65dc5..ca2ed65 100644
--- a/hw/hank/emisar-d3aa/anduril.h
+++ b/hw/hank/emisar-d3aa/anduril.h
@@ -6,8 +6,8 @@
#define HWDEF_H hank/emisar-d3aa/hwdef.h
// HPRsense : 4.2+0.3+20 = 24.5mR
-// Vsense=42.46mV, R1= 191k
-// LPRsense : 2R
+// Vsense=42.46mV, R1= 165k
+// LPRsense : 3R3
// HDR ratio: 131.5
// transition DAC level 20, ramp level 48
// fifth power ramp 0.02mA to 2001mA
diff --git a/hw/hank/emisar-d3aa/hwdef.c b/hw/hank/emisar-d3aa/hwdef.c
index 5f41d9d..a963bc2 100644
--- a/hw/hank/emisar-d3aa/hwdef.c
+++ b/hw/hank/emisar-d3aa/hwdef.c
@@ -113,7 +113,7 @@ uint8_t voltage_raw2cooked(uint16_t measurement) {
// (plus a bit of fudging to fix the slope and offset,
// based on measuring actual hardware)
uint8_t result = (uint32_t)(measurement + (65535 * 4 / 1024))
- * 43 / 16128;
+ * 43 / 16000;
return result;
}
#endif
diff --git a/hw/hank/emisar-d3aa/hwdef.h b/hw/hank/emisar-d3aa/hwdef.h
index 1001e5d..a104fc2 100644
--- a/hw/hank/emisar-d3aa/hwdef.h
+++ b/hw/hank/emisar-d3aa/hwdef.h
@@ -100,7 +100,7 @@ enum CHANNEL_MODES {
#define DUAL_VOLTAGE_FLOOR (4*21) // for AA/14500 boost drivers, don't indicate low voltage if below this level
#define DUAL_VOLTAGE_LOW_LOW (4*7) // the lower voltage range's danger zone 0.7 volts (NiMH)
// comment out to use VDDIO2 instead of external voltage divider
-//#define USE_VOLTAGE_DIVIDER
+#define USE_VOLTAGE_DIVIDER
#ifdef USE_VOLTAGE_DIVIDER
// AVR datasheet table 3.1 I/O Multiplexing, PA5 ADC0 = AIN25
#define ADMUX_VOLTAGE_DIVIDER ADC_MUXPOS_AIN25_gc
@@ -109,6 +109,7 @@ enum CHANNEL_MODES {
#undef voltage_raw2cooked
uint8_t voltage_raw2cooked(uint16_t measurement);
#else
+ // doesn't work on this hardware in AA mode
#define USE_VOLTAGE_VDDIO2
#endif