Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
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.

Files

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">
<doc>
<description>
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
</description>
<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"/>
</section>
</doc>
<autoload name="imu_common"/>
<autoload name="imu_nps"/>
<header>
<file name="imu_analog.h" dir="subsystems/imu"/>
</header>
<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="ADC_CHANNEL_GYRO_NB_SAMPLES" value="$(ADC_GYRO_NB_SAMPLES)"/>
<define name="ADC_CHANNEL_ACCEL_NB_SAMPLES" value="$(ADC_ACCEL_NB_SAMPLES)"/>
<define name="IMU_TYPE_H" value="subsystems/imu/imu_analog.h" type="string"/>
<file name="imu_analog.c" dir="subsystems/imu"/>
<raw>
ifeq ($(ARCH), lpc21)
ifneq ($(GYRO_P),)
$(TARGET).CFLAGS += -DADC_CHANNEL_GYRO_P=$(GYRO_P) -DUSE_$(GYRO_P)
endif
ifneq ($(GYRO_Q),)
$(TARGET).CFLAGS += -DADC_CHANNEL_GYRO_Q=$(GYRO_Q) -DUSE_$(GYRO_Q)
endif
ifneq ($(GYRO_R),)
$(TARGET).CFLAGS += -DADC_CHANNEL_GYRO_R=$(GYRO_R) -DUSE_$(GYRO_R)
endif
ifneq ($(ACCEL_X),)
$(TARGET).CFLAGS += -DADC_CHANNEL_ACCEL_X=$(ACCEL_X) -DUSE_$(ACCEL_X)
endif
ifneq ($(ACCEL_Y),)
$(TARGET).CFLAGS += -DADC_CHANNEL_ACCEL_Y=$(ACCEL_Y) -DUSE_$(ACCEL_Y)
endif
ifneq ($(ACCEL_Z),)
$(TARGET).CFLAGS += -DADC_CHANNEL_ACCEL_Z=$(ACCEL_Z) -DUSE_$(ACCEL_Z)
endif
else ifeq ($(ARCH), stm32)
$(error Not implemented for the stm32 yet... should be trivial, just do it...)
endif
</raw>
</makefile>
</module>