Browse Source

Plane: use voltage_average() to not depend on INPUT_VOLTS

master
Andrew Tridgell 12 years ago
parent
commit
2331c84423
  1. 4
      ArduPlane/defines.h
  2. 4
      ArduPlane/sensors.pde

4
ArduPlane/defines.h

@ -191,8 +191,8 @@ enum log_messages { @@ -191,8 +191,8 @@ enum log_messages {
// regress a climb rate from
#define BATTERY_VOLTAGE(x) (x*(g.input_voltage/1024.0))*g.volt_div_ratio
#define CURRENT_AMPS(x) ((x*(g.input_voltage/1024.0))-g.curr_amp_offset)*g.curr_amp_per_volt
#define BATTERY_VOLTAGE(x) (x->voltage_average()*g.volt_div_ratio)
#define CURRENT_AMPS(x) (x->voltage_average()-g.curr_amp_offset)*g.curr_amp_per_volt
#define AN4 4
#define AN5 5

4
ArduPlane/sensors.pde

@ -47,12 +47,12 @@ static void read_battery(void) @@ -47,12 +47,12 @@ static void read_battery(void)
if(g.battery_monitoring == 3 || g.battery_monitoring == 4) {
// this copes with changing the pin at runtime
batt_volt_pin->set_pin(g.battery_volt_pin);
battery_voltage1 = BATTERY_VOLTAGE(batt_volt_pin->read_average());
battery_voltage1 = BATTERY_VOLTAGE(batt_volt_pin);
}
if(g.battery_monitoring == 4) {
// this copes with changing the pin at runtime
batt_curr_pin->set_pin(g.battery_curr_pin);
current_amps1 = CURRENT_AMPS(batt_curr_pin->read_average());
current_amps1 = CURRENT_AMPS(batt_curr_pin);
current_total1 += current_amps1 * (float)delta_ms_medium_loop * 0.0002778; // .0002778 is 1/3600 (conversion to hours)
}

Loading…
Cancel
Save