From 604c34a14772ab2976b47fd09fa296f8df8af5b1 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Thu, 15 Feb 2024 22:45:40 +0100 Subject: [PATCH] Update voltage divider calculation --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8e4da96..d4a1360 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,8 +72,8 @@ const SWITCH_PWM_LIMIT: i32 = 93 * SWITCH_PWM_MAX / 100; fn convert_adc_measurements(raw: &[u16; 4]) -> (i32, i32, i32) { let iout = (raw[0] as i32 - raw[1] as i32) * 3300 * 20 / 4096 / 28; // *20 = division by 50 mΩ shunt - let vout = raw[2] as i32 * 3300 * (47 + 10) / 10 / 4096; - let vin = raw[3] as i32 * 3300 * (10 + 10) / 10 / 4096; + let vout = raw[2] as i32 * 3300 * (220 + 10) / 10 / 4096; + let vin = raw[3] as i32 * 3300 * (100 + 10) / 10 / 4096; (vin, vout, iout) /* units: mV, mV, mA */ }