37 #include "pprzlink/messages.h"
45 #define PWM_HEAT_CHAN PWM_HEAT_CHAN_BEBOP2
47 #define PWM_HEAT_CHAN PWM_HEAT_CHAN_DISCO
49 #error temp control only implemented in Parrot Bebop2 and Disco
54 float temp_current, error;
55 static float sum_error = 0;
68 sum_error = sum_error + error;
75 }
else if (output < 0) {
80 printf(
"[temp-ctrl] could not set duty cycle\n");
84 #ifdef IMU_TEMP_CTRL_DEBUG
94 int pwm_heat_run_fd, ret;
97 ret = asprintf(&path,
"/sys/class/pwm/pwm_%u/run",
PWM_HEAT_CHAN);
99 printf(
"[temp-ctrl] could not create pwm path\n");
103 pwm_heat_run_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
105 if (pwm_heat_run_fd < 0) {
106 printf(
"[temp-ctrl] could not open pwm run device\n");
110 ret = asprintf(&path,
"/sys/class/pwm/pwm_%u/duty_ns",
PWM_HEAT_CHAN);
112 printf(
"[temp-ctrl] could not create pwm duty path\n");
113 close(pwm_heat_run_fd);
120 printf(
"[temp-ctrl] could not open pwm duty path\n");
121 close(pwm_heat_run_fd);
127 printf(
"[temp-ctrl] could not set duty cycle\n");
131 ret = write(pwm_heat_run_fd,
"0", 1);
133 printf(
"[temp-ctrl] could not disable pwm\n");
137 ret = write(pwm_heat_run_fd,
"1", 1);
139 printf(
"[temp-ctrl] could not enable pwm\n");
147 close(pwm_heat_run_fd);
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
struct Mpu60x0_I2c mpu
The MPU gyro/accel device.
struct ImuBebop imu_bebop
Basic Navstik IMU data.
void imu_temp_ctrl_init(void)
float temp
temperature in degrees Celcius
Common code for AP and FBW telemetry.
void imu_temp_ctrl_periodic(void)
#define IMU_TEMP_CTRL_DUTY_MAX