Skip to content

Commit

Permalink
AP_InertialSensor: control IMU temperature using heater
Browse files Browse the repository at this point in the history
  • Loading branch information
bugobliterator committed Dec 1, 2015
1 parent 6a5e2bd commit 4cd41a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 17 additions & 2 deletions libraries/AP_InertialSensor/AP_InertialSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <AP_Notify/AP_Notify.h>
#include <AP_Vehicle/AP_Vehicle.h>
#include <AP_Math/AP_Math.h>

#include <stdio.h>
/*
enable TIMING_DEBUG to track down scheduling issues with the main
loop. Output is on the debug console
Expand Down Expand Up @@ -314,6 +314,8 @@ const AP_Param::GroupInfo AP_InertialSensor::var_info[] = {
parameters check for conflicts carefully
*/

AP_GROUPINFO("OP_TEMP", 27, AP_InertialSensor, _op_temp,65),
AP_GROUPINFO("TEMP_DZONE", 28, AP_InertialSensor, _temp_deadzone, 5),
AP_GROUPEND
};

Expand Down Expand Up @@ -911,6 +913,19 @@ void AP_InertialSensor::update(void)
_backends[i]->update();
}

if(_temperature[0] < _op_temp && !_heater_was_on) {
hal.gpio->set_heater(true);
_heater_was_on = true;
} else if(_temperature[0] < _op_temp - _temp_deadzone && _heater_was_on) {
hal.gpio->set_heater(true);
_heater_was_on = false;
}

if(_temperature[0] >= _op_temp) {
hal.gpio->set_heater(false);
}

//hal.console->printf("Temp: %f\n", _temperature[0]);
// clear accumulators
for (uint8_t i = 0; i < INS_MAX_INSTANCES; i++) {
_delta_velocity_acc[i].zero();
Expand Down Expand Up @@ -1259,7 +1274,7 @@ void AP_InertialSensor::acal_update()
return;
}
_acal->update();
if (_acal->get_status() != ACCEL_CAL_NOT_STARTED) {
if (hal.util->get_soft_armed() && _acal->get_status() != ACCEL_CAL_NOT_STARTED) {
_acal->clear();
}
}
Expand Down
4 changes: 4 additions & 0 deletions libraries/AP_InertialSensor/AP_InertialSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ class AP_InertialSensor : AP_AccelCal_Client
bool _gyro_healthy[INS_MAX_INSTANCES];
bool _accel_healthy[INS_MAX_INSTANCES];

bool _heater_was_on;
AP_Float _op_temp;
AP_Float _temp_deadzone;

uint32_t _accel_error_count[INS_MAX_INSTANCES];
uint32_t _gyro_error_count[INS_MAX_INSTANCES];

Expand Down

0 comments on commit 4cd41a3

Please sign in to comment.