20#define I2C_FREQ 400000UL
45 { 0, 0, 265.0f, 1125.0f,
"DLPF0_246 | NBW=265Hz | ODR=1125Hz (4.2x)" },
46 { 1, 0, 265.0f, 1125.0f,
"DLPF_246 | NBW=265Hz | ODR=1125Hz (4.2x)" },
47 { 2, 1, 136.0f, 562.5f,
"DLPF_111 | NBW=136Hz | ODR= 562Hz (4.1x)" },
48 { 3, 3, 68.8f, 281.3f,
"DLPF_50 | NBW= 69Hz | ODR= 281Hz (4.1x)" },
49 { 4, 7, 34.4f, 140.6f,
"DLPF_24 | NBW= 34Hz | ODR= 141Hz (4.1x)" },
50 { 5, 15, 17.0f, 70.3f,
"DLPF_12 | NBW= 17Hz | ODR= 70Hz (4.1x)" },
51 { 6, 31, 8.3f, 35.2f,
"DLPF_6 | NBW= 8Hz | ODR= 35Hz (4.2x)" },
52 { 7, 0, 499.0f, 1125.0f,
"DLPF_473 | NBW=499Hz | ODR=1125Hz (2.3x)" },
70const 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"};
78const uint16_t
accelSR[] = {0, 1, 3, 5, 7 , 10, 15, 22, 31, 63, 127, 255, 513, 1022, 2044, 4095};
80const 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"};
100 Serial.println(F(
"------------------------------------------------------------"));
105 Serial.println(F(
"============================================================"));
135 Serial.println(F(
"ERROR: WHO_AM_I mismatch"));
136 while (1) delay(200);
138 Serial.print(F(
"WHO_AM_I = 0x"));
139 Serial.println(who, HEX);
147 Serial.println(
"Acelerometro ICM-200948 | UNIT Electronics");
149 Serial.println(F(
"Coloque el sensor plano y quieto mirando hacia arriba"));
151 for(uint8_t d = 0; d <
N_DLPF; d++){
153 Serial.printf(
" ODR = %.1fHz | Delay = %lums | Periodo= %.1fms\n",
configsDLPF[d].odr_hz,max((uint32_t)(10000.0f/
configsDLPF[d].odr_hz),(uint32_t)50),
158 Serial.println(F(
" ERROR: applySettings() fallo"));
162 uint32_t settle_ms = max((uint32_t)(10000.0f /
configsDLPF[d].odr_hz),
168 uint32_t periodo_ms = max((uint32_t)(1000.0f /
configsDLPF[d].odr_hz),
171 for (uint8_t r = 0; r < 3; r++) {
174 Serial.printf(
" [%d] Ax=%+.3f Ay=%+.3f Az=%+.3f g\n",
177 Serial.println(F(
" [?] readAccel() fallo"));
189 Serial.begin(115200);
191 Serial.println(F(
"ICM-20948 — I2C Basic"));
193 Serial.println(F(
" ICM-20948 VALIDACION ACELEROMETRO"));
199 Serial.println(F(
"ERROR: begin(I2C) failed"));
200 while (1) delay(200);
211 Serial.println(F(
"ERROR: setSensors failed"));
213 Serial.println(F(
" Sensor listo.\n"));
214 Serial.println(F(
" Sensor PLANO y QUIETO sobre la mesa."));
215 Serial.println(F(
" Iniciando en 5 segundos..."));
216 for (
int i = 5; i > 0; i--) {
217 Serial.printf(
" %d...\n", i);
bool setAccelScale(ICM20948_Accel_FullScale fullScale)
bool readAccel(float &x, float &y, float &z)
bool readWhoAmI(uint8_t &whoAmI)
bool beginI2C(uint8_t address=0x69, TwoWire &i2cPort=Wire, uint32_t i2cSpeed=400000)
bool setAccelDLPF(uint8_t dlpf, bool bypass)
bool setAccelDivRate(uint16_t divisor)
bool setSensors(bool accel_on, bool gyro_on, bool temp_on)
void applySettings()
Initialize the magnetometer and collect samples for each mode.
Gyroscope DLPF divider and timing configuration.
float odr_hz
Output data rate in hertz for timing calculations.
uint8_t dlpf_idx
Index into the gyroDLPF lookup table.
const char * nombre
Text label printed with each captured sample.
uint16_t div
Sample-rate divider written to the IMU register.
float nbw_hz
Noise bandwidth in hertz for reporting.
#define SCL_PIN
I2C SCL pin used by the example board.
const char * etiquetasAccelCfg[]
Text labels matching accelCfg.
const ICM20948_Accel_DLPFCFG accelDLPF[]
Accelerometer DLPF enum values matching configsDLPF.
uint8_t total_fail
Count of validation failures reserved for future checks.
void firstStage()
Verify the IMU identity register.
const char * etiquetasAccelAVG[]
Text labels matching accelAVG.
void printDobleLinea()
Print a double separator line to Serial.
const ICM20948_Accel_Average accelAVG[]
Accelerometer averaging settings available for validation.
void setup()
Initialize I2C, reset/wake the IMU, enable sensors, and start sweep.
#define SDA_PIN
I2C SDA pin used by the example board.
void runSweep()
Run the accelerometer DLPF validation sweep and print samples.
const uint8_t N_FS
Number of accelerometer full-scale ranges.
const uint8_t N_DLPF
Number of accelerometer DLPF configurations.
const char * etiquetasAccelDLPFCFG[]
Text labels describing accelDLPF bandwidth pairs.
void printLinea()
Print a separator line to Serial.
#define I2C_FREQ
I2C bus speed in hertz.
#define ICM_ADDR
ICM-20948 I2C address selected by the AD0 pin.
const configDLPF configsDLPF[]
Accelerometer DLPF configurations exercised by this validation.
DevLab_ICM20948 imu
Global ICM-20948 driver instance.
const char * etiquetasSR[]
Text labels matching accelSR output data rates.
uint8_t total_pass
Count of validation passes reserved for future checks.
uint8_t total_warn
Count of validation warnings reserved for future checks.
const uint16_t accelSR[]
Raw accelerometer sample-rate divider values for experiments.
const ICM20948_Accel_FullScale accelCfg[]
Accelerometer full-scale ranges available for validation.
void loop()
Optional post-sweep loop for manual accelerometer reads.