Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_analog module

Analog IMU connected to MCU ADC ports.

Only add the configure and define lines for the sensors you actually use. E.g. to replace the old gyro_pitch subsystem only add GYRO_P and GYRO_Q

Example for airframe file

Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!

1 <module name="imu_analog">
2  <configure name="GYRO_P" value="ADC_0" />
3  <configure name="GYRO_Q" value="ADC_1" />
4  <configure name="GYRO_R" value="ADC_2" />
5  <configure name="ACCEL_X" value="ADC_5" />
6  <configure name="ACCEL_Y" value="ADC_6" />
7  <configure name="ACCEL_Z" value="ADC_7" />
8  <configure name="ADC_GYRO_NB_SAMPLES" value="16" />
9  <configure name="ADC_ACCEL_NB_SAMPLES" value="16" />
10 </module>

Module configuration options

Configure Options

  • name: GYRO_P value: ADC_0
  • name: GYRO_Q value: ADC_1
  • name: GYRO_R value: ADC_2
  • name: ACCEL_X value: ADC_5
  • name: ACCEL_Y value: ADC_6
  • name: ACCEL_Z value: ADC_7
  • name: ADC_GYRO_NB_SAMPLES value: 16
  • name: ADC_ACCEL_NB_SAMPLES value: 16

Airframe file section

  • section name: IMU prefix: IMU_
    • name GYRO_P_NEUTRAL value: 512
    • name GYRO_Q_NEUTRAL value: 512
    • name GYRO_R_NEUTRAL value: 512
    • name GYRO_P_SENS value: 0.017
    • name GYRO_Q_SENS value: 0.017
    • name GYRO_R_SENS value: 0.017
    • name GYRO_P_SIGN value: 1
    • name GYRO_Q_SIGN value: 1
    • name GYRO_R_SIGN value: -1
    • name ACCEL_X_SENS value: 0.1
    • name ACCEL_Y_SENS value: 0.1
    • name ACCEL_Z_SENS value: 0.1
    • name ACCEL_X_NEUTRAL value: 512
    • name ACCEL_Y_NEUTRAL value: 512
    • name ACCEL_Z_NEUTRAL value: 512
    • name ACCEL_X_SIGN value: 1
    • name ACCEL_Y_SIGN value: -1
    • name ACCEL_Z_SIGN value: 1

Auto-loaded modules

The following modules are automatically loaded (just as if you had added them in the airframe file)

Module functions

Init Functions

These initialization functions are called once on startup.

Periodic Functions

These functions are called periodically at the specified frequency from the module periodic loop.

  • imu_analog_periodic()
    • Running at maximum module frequency.
    • Autorun: LOCK
      Periodic function automatically starts after init and can't be stopped.


Header Files

The following headers are automatically included in modules.h

Source Files

Raw imu_analog.xml file:

<!DOCTYPE module SYSTEM "module.dtd">
<module name="imu_analog" dir="imu">
Analog IMU connected to MCU ADC ports.
Only add the configure and define lines for the sensors you actually use.
E.g. to replace the old gyro_pitch subsystem only add GYRO_P and GYRO_Q
<configure name="GYRO_P" value="ADC_0"/>
<configure name="GYRO_Q" value="ADC_1"/>
<configure name="GYRO_R" value="ADC_2"/>
<configure name="ACCEL_X" value="ADC_5"/>
<configure name="ACCEL_Y" value="ADC_6"/>
<configure name="ACCEL_Z" value="ADC_7"/>
<configure name="ADC_GYRO_NB_SAMPLES" value="16"/>
<configure name="ADC_ACCEL_NB_SAMPLES" value="16"/>
<section name="IMU" prefix="IMU_">
<define name="GYRO_P_NEUTRAL" value="512"/>
<define name="GYRO_Q_NEUTRAL" value="512"/>
<define name="GYRO_R_NEUTRAL" value="512"/>
<define name="GYRO_P_SENS" value="0.017" integer="16"/>
<define name="GYRO_Q_SENS" value="0.017" integer="16"/>
<define name="GYRO_R_SENS" value="0.017" integer="16"/>
<define name="GYRO_P_SIGN" value="1" />
<define name="GYRO_Q_SIGN" value="1" />
<define name="GYRO_R_SIGN" value="-1" />
<define name="ACCEL_X_SENS" value="0.1" integer="16"/>
<define name="ACCEL_Y_SENS" value="0.1" integer="16"/>
<define name="ACCEL_Z_SENS" value="0.1" integer="16"/>
<define name="ACCEL_X_NEUTRAL" value="512"/>
<define name="ACCEL_Y_NEUTRAL" value="512"/>
<define name="ACCEL_Z_NEUTRAL" value="512"/>
<define name="ACCEL_X_SIGN" value="1"/>
<define name="ACCEL_Y_SIGN" value="-1"/>
<define name="ACCEL_Z_SIGN" value="1"/>
<autoload name="imu_common"/>
<autoload name="imu_nps"/>
<file name="imu_analog.h" dir="subsystems/imu"/>
<init fun="imu_analog_init()"/>
<periodic fun="imu_analog_periodic()"/>
<makefile target="!sim|nps|fbw">
<configure name="ADC_GYRO_NB_SAMPLES" default="16"/>
<configure name="ADC_ACCEL_NB_SAMPLES" default="16"/>
<define name="IMU_TYPE_H" value="subsystems/imu/imu_analog.h" type="string"/>
<file name="imu_analog.c" dir="subsystems/imu"/>
ifeq ($(ARCH), lpc21)
ifneq ($(GYRO_P),)
ifneq ($(GYRO_Q),)
ifneq ($(GYRO_R),)
ifneq ($(ACCEL_X),)
ifneq ($(ACCEL_Y),)
ifneq ($(ACCEL_Z),)
else ifeq ($(ARCH), stm32)
$(error Not implemented for the stm32 yet... should be trivial, just do it...)