38 #ifndef IMU_HEATER_TARGET_TEMP
39 #define IMU_HEATER_TARGET_TEMP 45
43 #ifndef IMU_HEATER_P_GAIN
44 #define IMU_HEATER_P_GAIN 200.0
48 #ifndef IMU_HEATER_I_GAIN
49 #define IMU_HEATER_I_GAIN 0.3
53 #if !defined(IMU_HEATER_GYRO_ID) && !defined(IMU_HEATER_ACCEL_ID)
54 #define IMU_HEATER_GYRO_ID ABI_BROADCAST
62 #if PERIODIC_TELEMETRY
77 #ifdef PREFLIGHT_CHECKS
83 #ifndef IMU_HEATER_MAX_ERROR
84 #define IMU_HEATER_MAX_ERROR 0.20f
88 #if defined(IMU_HEATER_GYRO_ID)
89 #define IMU_HEATER_ABI_ID IMU_HEATER_GYRO_ID
90 #elif defined(IMU_HEATER_ACCEL_ID)
91 #define IMU_HEATER_ABI_ID IMU_HEATER_ACCEL_ID
103 #if defined(IMU_HEATER_GYRO_ID)
113 #if defined(IMU_HEATER_ACCEL_ID)
114 static void imu_heater_accel_raw_cb(
uint8_t sender_id __attribute__((unused)),
uint32_t stamp __attribute__((unused)),
struct Int32Vect3 *data __attribute__((unused)),
uint8_t samples __attribute__((unused)),
float rate __attribute__((unused)),
float temp) {
141 #if defined(IMU_HEATER_GYRO_ID)
143 #elif defined(IMU_HEATER_ACCEL_ID)
144 AbiBindMsgIMU_ACCEL_RAW(IMU_HEATER_ACCEL_ID, &
imu_heater_abi_ev, imu_heater_accel_raw_cb);
147 #if PERIODIC_TELEMETRY
166 #if defined(IMU_HEATER_GPIO) && defined(IMU_HEATER_GPIO_PIN)
168 gpio_set(IMU_HEATER_GPIO, IMU_HEATER_GPIO_PIN);
170 gpio_clear(IMU_HEATER_GPIO, IMU_HEATER_GPIO_PIN);
212 float dt = (current_ts - heater->
last_ts) * 1e-6;
218 if (heater->
last_ts != 0 && dt > 0) {
Main include for ABI (AirBorneInterface).
Event structure to store callbacks in a linked list.
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Inertial Measurement Unit interface.
#define IMU_HEATER_P_GAIN
Default heater kP gain.
#define IMU_HEATER_GYRO_ID
Default heater gyro abi ID.
static void imu_heater_gyro_raw_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *data, uint8_t samples, float rate, float temp)
#define IMU_HEATER_TARGET_TEMP
Default target temperature.
static float imu_heater_run(struct imu_heater_t *heater, float temp)
Calculate the IMU command percentage.
static void send_imu_heater(struct transport_tx *trans, struct link_device *dev)
Send the IMU heater message.
struct imu_heater_t imu_heater
Local variables and functions.
static abi_event imu_heater_abi_ev
void imu_heater_periodic_10hz(void)
10Hz IMU heater periodic This will run the control loop for the IMU heater and in case of an IOMCU wi...
void imu_heater_periodic(void)
High speed heater periodic This calculates the temperature average and in case of GPIO heater it will...
#define IMU_HEATER_I_GAIN
Default heater kI gain.
void imu_heater_init(void)
Initialize the heater Sets the default gains and resets the initial values.
IMU heater module which can actuate a resistor heater through GPIO or IOMCU.
uint32_t meas_temp_cnt
Amount of summed temperatures.
float meas_temp
Measered average temperature in degrees Celcius.
uint8_t heat_cmd
Heater command 0-100%.
float target_temp
Target temeperature in degrees Celcius.
uint32_t last_ts
Last integration timestamp.
float gain_p
Heater kP gain.
float meas_temp_sum
Summed temperature in degrees Celcius.
float integrated
Integrated temperature error multiplied by kI (max 70%)
float gain_i
Heater kI gain.
Main IMU heater structure.
void iomcu_set_heater_duty_cycle(uint8_t duty_cycle)
Set the IO MCU heater duty cycle.
Driver to communicate with the ardupilot IO MCU.
double rand_uniform(void)
void preflight_error(struct preflight_result_t *result, const char *fmt,...)
Register a preflight error used inside the preflight checking functions.
void preflight_success(struct preflight_result_t *result, const char *fmt,...)
Register a preflight success used inside the preflight checking functions.
void preflight_check_register(struct preflight_check_t *check, preflight_check_f func)
Register a preflight check and add it to the linked list.
static const struct usb_device_descriptor dev
Architecture independent timing functions.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.