DevLab_ICM20948 1.0.2 ICM-20948 9-Axis Motion Sensor Driver

Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
test.ino File Reference

Accelerometer DLPF validation sketch for the 7Semi ICM-20948. More...

`#include <Wire.h>`
`#include <DevLab_ICM20948.h>`
Include dependency graph for test.ino:

Go to the source code of this file.

## Classes
struct | configDLPF
| Gyroscope DLPF divider and timing configuration. More...

## Macros
#define | SDA_PIN 6
| I2C SDA pin used by the example board.
#define | SCL_PIN 7
| I2C SCL pin used by the example board.
#define | I2C_FREQ 400000UL
| I2C bus speed in hertz.
#define | ICM_ADDR 0x69
| ICM-20948 I2C address selected by the AD0 pin.

## Functions
void | printLinea ()
| Print a separator line to Serial.
void | printDobleLinea ()
| Print a double separator line to Serial.
bool | applySettings (uint8_t fs_idx, const configDLPF &cfg)
| Apply one accelerometer full-scale and DLPF configuration.
void | firstStage ()
| Verify the IMU identity register.
void | runSweep ()
| Run the accelerometer DLPF validation sweep and print samples.
void | setup ()
| Initialize I2C, reset/wake the IMU, enable sensors, and start sweep.
void | loop ()
| Optional post-sweep loop for manual accelerometer reads.

## Variables
const configDLPF | configsDLPF []
| Accelerometer DLPF configurations exercised by this validation.
const uint8_t | N_DLPF = sizeof(configsDLPF) / sizeof(configsDLPF[0])
| Number of accelerometer DLPF configurations.
const ICM20948_Accel_FullScale | accelCfg [] = { ICM20948_Accel_FullScale::G_2, ICM20948_Accel_FullScale::G_4, ICM20948_Accel_FullScale::G_8, ICM20948_Accel_FullScale::G_16}
| Accelerometer full-scale ranges available for validation.
const char * | etiquetasAccelCfg [] = {"+-2G","+-4G", "+-8G", "+-16G"}
| Text labels matching accelCfg.
const uint8_t | N_FS = 4
| Number of accelerometer full-scale ranges.
const ICM20948_Accel_DLPFCFG | accelDLPF [] = { ICM20948_Accel_DLPFCFG::DLPF0_246HZ, ICM20948_Accel_DLPFCFG::DLPF_246HZ, ICM20948_Accel_DLPFCFG::DLPF_111HZ, ICM20948_Accel_DLPFCFG::DLPF_50HZ, ICM20948_Accel_DLPFCFG::DLPF_24HZ, ICM20948_Accel_DLPFCFG::DLPF_12HZ, ICM20948_Accel_DLPFCFG::DLPF_6HZ,ICM20948_Accel_DLPFCFG::DLPF_473HZ }
| Accelerometer DLPF enum values matching configsDLPF.
const char * | etiquetasAccelDLPFCFG [] = { "246/265", "246/265", "111/136", "50.4/68.8","23.9/34.4", "11.5/17.0", "5.7/8.3","473/499"}
| Text labels describing accelDLPF bandwidth pairs.
const ICM20948_Accel_Average | accelAVG [] = {ICM20948_Accel_Average::AVG_1_OR_4 ,ICM20948_Accel_Average::AVG_8, ICM20948_Accel_Average::AVG_16, ICM20948_Accel_Average::AVG_32}
| Accelerometer averaging settings available for validation.
const char * | etiquetasAccelAVG [] = {"1 OR 4","8","16","32"}
| Text labels matching accelAVG.
const uint16_t | accelSR [] = {0, 1, 3, 5, 7 , 10, 15, 22, 31, 63, 127, 255, 513, 1022, 2044, 4095}
| Raw accelerometer sample-rate divider values for experiments.
const char * | etiquetasSR [] = { "1125.0","562.5", "281.3", "187.5","140.6", "102.3", "70.3", "48.9", "35.2", "17.6", "8.8", "4.4", "2.2", "1.1", "0.55", "0.27"}
| Text labels matching accelSR output data rates.
DevLab_ICM20948 | imu
| Global ICM-20948 driver instance.
uint8_t | total_pass = 0
| Count of validation passes reserved for future checks.
uint8_t | total_fail = 0
| Count of validation failures reserved for future checks.
uint8_t | total_warn = 0
| Count of validation warnings reserved for future checks.

## Detailed Description

Accelerometer DLPF validation sketch for the 7Semi ICM-20948.

Author
  Jonathan Mejorado Lopez

Runs an I2C accelerometer sweep across DLPF settings, prints sample data to Serial, and is intended for bench validation with the sensor flat and stationary.

Definition in file test.ino.

## Macro Definition Documentation

## ◆ I2C_FREQ

#define I2C_FREQ 400000UL

I2C bus speed in hertz.

Definition at line 20 of file test.ino.

## ◆ ICM_ADDR

#define ICM_ADDR 0x69

ICM-20948 I2C address selected by the AD0 pin.

Definition at line 26 of file test.ino.

## ◆ SCL_PIN

#define SCL_PIN 7

I2C SCL pin used by the example board.

Definition at line 18 of file test.ino.

## ◆ SDA_PIN

#define SDA_PIN 6

I2C SDA pin used by the example board.

Definition at line 16 of file test.ino.

## Function Documentation

## ◆ applySettings()

bool applySettings | ( | uint8_t | fs_idx,
|  | const configDLPF & | cfg
| ) |  |

Apply one accelerometer full-scale and DLPF configuration.

Parameters

  fs_idx | Index into accelCfg.
  cfg | DLPF timing and divider configuration.

Returns
  true if all configuration writes succeeded, otherwise false.

Definition at line 115 of file test.ino.

Here is the call graph for this function:

## ◆ firstStage()

void firstStage | ( |  | ) |

Verify the IMU identity register.

Definition at line 132 of file test.ino.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ loop()

void loop | ( |  | ) |

Optional post-sweep loop for manual accelerometer reads.

Definition at line 226 of file test.ino.

## ◆ printDobleLinea()

void printDobleLinea | ( |  | ) |

Print a double separator line to Serial.

Definition at line 104 of file test.ino.

Here is the caller graph for this function:

## ◆ printLinea()

void printLinea | ( |  | ) |

Print a separator line to Serial.

Definition at line 99 of file test.ino.

Here is the caller graph for this function:

## ◆ runSweep()

void runSweep | ( |  | ) |

Run the accelerometer DLPF validation sweep and print samples.

Definition at line 145 of file test.ino.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ setup()

void setup | ( |  | ) |

Initialize I2C, reset/wake the IMU, enable sensors, and start sweep.

Definition at line 187 of file test.ino.

Here is the call graph for this function:

## Variable Documentation

## ◆ accelAVG

const ICM20948_Accel_Average accelAVG[] = {ICM20948_Accel_Average::AVG_1_OR_4 ,ICM20948_Accel_Average::AVG_8, ICM20948_Accel_Average::AVG_16, ICM20948_Accel_Average::AVG_32}

Accelerometer averaging settings available for validation.

Definition at line 73 of file test.ino.

## ◆ accelCfg

const ICM20948_Accel_FullScale accelCfg[] = { ICM20948_Accel_FullScale::G_2, ICM20948_Accel_FullScale::G_4, ICM20948_Accel_FullScale::G_8, ICM20948_Accel_FullScale::G_16}

Accelerometer full-scale ranges available for validation.

Definition at line 61 of file test.ino.

## ◆ accelDLPF

const ICM20948_Accel_DLPFCFG accelDLPF[] = { ICM20948_Accel_DLPFCFG::DLPF0_246HZ, ICM20948_Accel_DLPFCFG::DLPF_246HZ, ICM20948_Accel_DLPFCFG::DLPF_111HZ, ICM20948_Accel_DLPFCFG::DLPF_50HZ, ICM20948_Accel_DLPFCFG::DLPF_24HZ, ICM20948_Accel_DLPFCFG::DLPF_12HZ, ICM20948_Accel_DLPFCFG::DLPF_6HZ,ICM20948_Accel_DLPFCFG::DLPF_473HZ }

Accelerometer DLPF enum values matching configsDLPF.

Definition at line 68 of file test.ino.

## ◆ accelSR

const uint16_t accelSR[] = {0, 1, 3, 5, 7 , 10, 15, 22, 31, 63, 127, 255, 513, 1022, 2044, 4095}

Raw accelerometer sample-rate divider values for experiments.

Definition at line 78 of file test.ino.

## ◆ configsDLPF

const configDLPF configsDLPF[]

Initial value:
= {
{ 0, 0, 265.0f, 1125.0f, "DLPF0_246 | NBW=265Hz | ODR=1125Hz (4.2x)" },
{ 1, 0, 265.0f, 1125.0f, "DLPF_246 | NBW=265Hz | ODR=1125Hz (4.2x)" },
{ 2, 1, 136.0f, 562.5f, "DLPF_111 | NBW=136Hz | ODR= 562Hz (4.1x)" },
{ 3, 3, 68.8f, 281.3f, "DLPF_50 | NBW= 69Hz | ODR= 281Hz (4.1x)" },
{ 4, 7, 34.4f, 140.6f, "DLPF_24 | NBW= 34Hz | ODR= 141Hz (4.1x)" },
{ 5, 15, 17.0f, 70.3f, "DLPF_12 | NBW= 17Hz | ODR= 70Hz (4.1x)" },
{ 6, 31, 8.3f, 35.2f, "DLPF_6 | NBW= 8Hz | ODR= 35Hz (4.2x)" },
{ 7, 0, 499.0f, 1125.0f, "DLPF_473 | NBW=499Hz | ODR=1125Hz (2.3x)" },
}

Accelerometer DLPF configurations exercised by this validation.

Definition at line 43 of file test.ino.

## ◆ etiquetasAccelAVG

const char* etiquetasAccelAVG[] = {"1 OR 4","8","16","32"}

Text labels matching accelAVG.

Definition at line 75 of file test.ino.

## ◆ etiquetasAccelCfg

const char* etiquetasAccelCfg[] = {"+-2G","+-4G", "+-8G", "+-16G"}

Text labels matching accelCfg.

Definition at line 63 of file test.ino.

## ◆ etiquetasAccelDLPFCFG

const char* etiquetasAccelDLPFCFG[] = { "246/265", "246/265", "111/136", "50.4/68.8","23.9/34.4", "11.5/17.0", "5.7/8.3","473/499"}

Text labels describing accelDLPF bandwidth pairs.

Definition at line 70 of file test.ino.

## ◆ etiquetasSR

const char* etiquetasSR[] = { "1125.0","562.5", "281.3", "187.5","140.6", "102.3", "70.3", "48.9", "35.2", "17.6", "8.8", "4.4", "2.2", "1.1", "0.55", "0.27"}

Text labels matching accelSR output data rates.

Definition at line 80 of file test.ino.

## ◆ imu

DevLab_ICM20948 imu

Global ICM-20948 driver instance.

Definition at line 85 of file test.ino.

## ◆ N_DLPF

const uint8_t N_DLPF = sizeof(configsDLPF) / sizeof(configsDLPF[0])

Number of accelerometer DLPF configurations.

Definition at line 58 of file test.ino.

## ◆ N_FS

const uint8_t N_FS = 4

Number of accelerometer full-scale ranges.

Definition at line 65 of file test.ino.

## ◆ total_fail

uint8_t total_fail = 0

Count of validation failures reserved for future checks.

Definition at line 90 of file test.ino.

## ◆ total_pass

uint8_t total_pass = 0

Count of validation passes reserved for future checks.

Definition at line 88 of file test.ino.

## ◆ total_warn

uint8_t total_warn = 0

Count of validation warnings reserved for future checks.

Definition at line 92 of file test.ino.