mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
heater: fix on blips when the heater is off (#25398)
Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
This commit is contained in:
parent
947c71e1cb
commit
e05d8f2168
@ -201,7 +201,7 @@ void Heater::Run()
|
||||
// Turn the heater off.
|
||||
_heater_on = false;
|
||||
heater_off();
|
||||
ScheduleDelayed(_controller_period_usec - _controller_time_on_usec);
|
||||
ScheduleDelayed(CONTROLLER_PERIOD_DEFAULT - _controller_time_on_usec);
|
||||
|
||||
} else if (_sensor_accel_sub.update(&sensor_accel)) {
|
||||
|
||||
@ -217,9 +217,9 @@ void Heater::Run()
|
||||
_integrator_value = math::constrain(_integrator_value, -0.25f, 0.25f);
|
||||
|
||||
_controller_time_on_usec = static_cast<int>((_param_sens_imu_temp_ff.get() + _proportional_value +
|
||||
_integrator_value) * static_cast<float>(_controller_period_usec));
|
||||
_integrator_value) * static_cast<float>(CONTROLLER_PERIOD_DEFAULT));
|
||||
|
||||
_controller_time_on_usec = math::constrain(_controller_time_on_usec, 0, _controller_period_usec);
|
||||
_controller_time_on_usec = math::constrain(_controller_time_on_usec, 0, CONTROLLER_PERIOD_DEFAULT);
|
||||
|
||||
if (fabsf(temperature_delta) < TEMPERATURE_TARGET_THRESHOLD) {
|
||||
_temperature_target_met = true;
|
||||
@ -229,9 +229,16 @@ void Heater::Run()
|
||||
_temperature_target_met = false;
|
||||
}
|
||||
|
||||
_heater_on = true;
|
||||
heater_on();
|
||||
ScheduleDelayed(_controller_time_on_usec);
|
||||
if (_controller_time_on_usec > 0) {
|
||||
// Turn the heater on.
|
||||
_heater_on = true;
|
||||
heater_on();
|
||||
ScheduleDelayed(_controller_time_on_usec);
|
||||
|
||||
} else {
|
||||
// Turn the heater off.
|
||||
ScheduleDelayed(CONTROLLER_PERIOD_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
publish_status();
|
||||
@ -245,7 +252,7 @@ void Heater::publish_status()
|
||||
status.temperature_sensor = _temperature_last;
|
||||
status.temperature_target = _param_sens_imu_temp.get();
|
||||
status.temperature_target_met = _temperature_target_met;
|
||||
status.controller_period_usec = _controller_period_usec;
|
||||
status.controller_period_usec = CONTROLLER_PERIOD_DEFAULT;
|
||||
status.controller_time_on_usec = _controller_time_on_usec;
|
||||
status.proportional_value = _proportional_value;
|
||||
status.integrator_value = _integrator_value;
|
||||
|
||||
@ -142,7 +142,6 @@ private:
|
||||
bool _heater_on = false;
|
||||
bool _temperature_target_met = false;
|
||||
|
||||
int _controller_period_usec = CONTROLLER_PERIOD_DEFAULT;
|
||||
int _controller_time_on_usec = 0;
|
||||
|
||||
float _integrator_value = 0.0f;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user