Update voltage divider calculation
This commit is contained in:
parent
a157c1eedd
commit
604c34a147
|
@ -72,8 +72,8 @@ const SWITCH_PWM_LIMIT: i32 = 93 * SWITCH_PWM_MAX / 100;
|
||||||
fn convert_adc_measurements(raw: &[u16; 4]) -> (i32, i32, i32)
|
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 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 vout = raw[2] as i32 * 3300 * (220 + 10) / 10 / 4096;
|
||||||
let vin = raw[3] as i32 * 3300 * (10 + 10) / 10 / 4096;
|
let vin = raw[3] as i32 * 3300 * (100 + 10) / 10 / 4096;
|
||||||
|
|
||||||
(vin, vout, iout) /* units: mV, mV, mA */
|
(vin, vout, iout) /* units: mV, mV, mA */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue