From: Joseph Coffland Date: Wed, 6 Dec 2017 07:01:03 +0000 (-0800) Subject: docs X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=bcfde1ac78069f8a5f4f0073fc25aadc40a82cc3;p=bbctrl-firmware docs --- diff --git a/src/pwr/config.h b/src/pwr/config.h index ef61776..71b5516 100644 --- a/src/pwr/config.h +++ b/src/pwr/config.h @@ -84,7 +84,7 @@ enum { #define VOLTAGE_EXP 0.01 #define FAULT_TIMEOUT 5000 // ms -#define SHUNT_WATTS_PER_SEC 5 +#define SHUNT_WATTS 5 #define SHUNT_OHMS 10 #define SHUNT_MIN_V 1 #define SHUNT_MAX_V 3 diff --git a/src/pwr/main.c b/src/pwr/main.c index 38ffa30..fe60b28 100644 --- a/src/pwr/main.c +++ b/src/pwr/main.c @@ -120,11 +120,11 @@ static float get_reg(int reg) { static void update_shunt() { - static float watts = SHUNT_WATTS_PER_SEC; + static float watts = SHUNT_WATTS; // Add power dissipation credit - watts += SHUNT_WATTS_PER_SEC / 1000.0; - if (SHUNT_WATTS_PER_SEC < watts) watts = SHUNT_WATTS_PER_SEC; + watts += SHUNT_WATTS / 1000.0; + if (SHUNT_WATTS < watts) watts = SHUNT_WATTS; // Remove power dissipation credit watts -= shunt_ms_power; @@ -177,8 +177,8 @@ ISR(TIMER0_OVF_vect) { time++; tick = 0; - update_shunt(); - if (!(time & 7)) measure_nominal_voltage(); + update_shunt(); // Every 1ms + if (!(time & 7)) measure_nominal_voltage(); // Every 8ms } }