AP_Generator: remove heat model for generator

It was agreed that the existing hyteresis in the H2 controller was
sufficient
This commit is contained in:
Peter Barker 2020-06-29 12:03:01 +10:00 committed by Randy Mackay
parent c5ac42d985
commit 1639bd7d09
2 changed files with 0 additions and 76 deletions

View File

@ -148,53 +148,6 @@ bool AP_Generator_RichenPower::get_reading()
return true;
}
void AP_Generator_RichenPower::update_heat()
{
// assume heat increase is directly proportional to RPM.
const uint32_t now = AP_HAL::millis();
uint16_t rpm = last_reading.rpm;
if (now - last_reading_ms > 2000) {
// if we're not getting updates, assume we're getting colder
rpm = 0;
// ... and resend the version information when we get something again
protocol_information_anounced = false;
}
const uint32_t time_delta_ms = now - last_heat_update_ms;
last_heat_update_ms = now;
heat += rpm * time_delta_ms * (1/1000.0f);
// cap the heat of the motor:
heat = MIN(heat, 60 * RUN_RPM); // so cap heat at 60 seconds at run-speed
// now lose some heat to the environment
heat -= (heat * environment_loss_factor * (time_delta_ms * (1/1000.0f))); // lose some % of heat per second
}
constexpr float AP_Generator_RichenPower::heat_required_for_run()
{
// assume that heat is proportional to RPM. Return a number
// proportial to RPM. Reduce it to account for the cooling some%/s
// cooling
return (30 * IDLE_RPM) * environment_loss_30s;
}
bool AP_Generator_RichenPower::generator_ok_to_run() const
{
return heat > heat_required_for_run();
}
constexpr float AP_Generator_RichenPower::heat_required_for_supply()
{
// account for cooling that happens in that 60 seconds
return (30 * IDLE_RPM + 30 * RUN_RPM) * environment_loss_60s;
}
bool AP_Generator_RichenPower::generator_ok_to_supply() const
{
// duplicated into prearms
return heat > heat_required_for_supply();
}
/*
update the state of the sensor
*/
@ -210,8 +163,6 @@ void AP_Generator_RichenPower::update(void)
(void)get_reading();
update_heat();
Log_Write();
}
@ -241,11 +192,6 @@ void AP_Generator_RichenPower::update_runstate()
_servo_channel->set_output_pwm(SERVO_PWM_IDLE);
break;
case RunState::RUN:
// we must have
if (!generator_ok_to_run()) {
_servo_channel->set_output_pwm(SERVO_PWM_IDLE);
break;
}
_servo_channel->set_output_pwm(SERVO_PWM_RUN);
break;
}
@ -341,10 +287,6 @@ bool AP_Generator_RichenPower::pre_arm_check(char *failmsg, uint8_t failmsg_len)
snprintf(failmsg, failmsg_len, "requested state is not RUN");
return false;
}
if (!generator_ok_to_supply()) {
snprintf(failmsg, failmsg_len, "warming up (%.0f%%)", (heat *100 / heat_required_for_supply()));
return false;
}
return true;
}

View File

@ -170,27 +170,9 @@ private:
// RC input generator for pilot to specify desired generator state
RC_Channel *_rc_channel;
// a simple heat model to avoid the motor moving to run too fast
// or being stopped before cooldown.
uint32_t last_heat_print;
uint32_t last_heat_update_ms;
float heat;
void update_heat();
bool generator_ok_to_run() const;
bool generator_ok_to_supply() const;
static constexpr float heat_required_for_supply();
static constexpr float heat_required_for_run();
static const uint16_t RUN_RPM = 15000;
static const uint16_t IDLE_RPM = 4800;
static constexpr float environment_loss_factor = 0.005f;
// powf is not constexpr, so we create a const for it:
// powf(1.0f-environment_loss_factor, 30)
static constexpr float environment_loss_30s = 0.860384;
static constexpr float environment_loss_60s = 0.740261;
// logging state
uint32_t last_logged_reading_ms;
};