Skip to content

Commit c1867ad

Browse files
committed
User can now configure the IMU full scale and filter bandwidth from Menu 3
1 parent 23e0349 commit c1867ad

File tree

5 files changed

+317
-21
lines changed

5 files changed

+317
-21
lines changed
3.57 KB
Binary file not shown.

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
Find way to store device configs into EEPROM
3333
Log four pressure sensors and graph them on plotter
3434
(checked) Test GPS - not sure about %d with int32s. Does lat, long, and alt look correct?
35-
Test NAU7802s
36-
Test SCD30s
37-
Add a 'does not like to be powered cycled' setting for each device type.
35+
(done) Test NAU7802s
36+
(done) Test SCD30s (Add an extended delay for the SCD30. (Issue #5))
37+
(won't do?) Add a 'does not like to be powered cycled' setting for each device type. I think this has been superceded by "Add individual power-on delays for each sensor type?.
3838
(done) Add support for logging VIN
3939
(done) Investigate error in time between logs (https://github.com/sparkfun/OpenLog_Artemis/issues/13)
4040
(done) Invesigate RTC reset issue (https://github.com/sparkfun/OpenLog_Artemis/issues/13 + https://forum.sparkfun.com/viewtopic.php?f=123&t=53157)
@@ -44,8 +44,7 @@
4444
(done) Add a fix so that the MS8607 does not also appear as an MS5637
4545
(done) Add "set RTC from GPS" functionality
4646
(done) Add UTCoffset functionality (including support for negative numbers)
47-
Figure out how to give the u-blox time to establish a fix if it has been powered down between log intervals.
48-
Maybe add a waitForValidFix feature? Or maybe we can work around using a big value for "Set Qwiic bus power up delay"?
47+
(done) Figure out how to give the u-blox time to establish a fix if it has been powered down between log intervals. The user can specify up to 60s for the Qwiic power-on delay.
4948
Add support for VREG_ENABLE
5049
(done) Add support for PWR_LED
5150
(done) Use the WDT to reset the Artemis when power is reconnected (previously the Artemis would have stayed in deep sleep)
@@ -69,6 +68,7 @@
6968
(done) Change detectQwiicDevices so that the MCP9600 (Qwiic Thermocouple) is detected correctly
7069
(done) Add support for the MPRLS0025PA micro pressure sensor
7170
(done) Add support for the SN-GCJA5 particle sensor
71+
(done) Add IMU accelerometer and gyro full scale and digital low pass filter settings to menuIMU
7272
*/
7373

7474
const int FIRMWARE_VERSION_MAJOR = 1;
@@ -82,7 +82,7 @@ const int FIRMWARE_VERSION_MINOR = 7;
8282
// the variant * 0x100 (OLA = 1; GNSS_LOGGER = 2; GEOPHONE_LOGGER = 3)
8383
// the major firmware version * 0x10
8484
// the minor firmware version
85-
#define OLA_IDENTIFIER 0x117
85+
#define OLA_IDENTIFIER 0x117 // Stored as 279 decimal in OLA_settings.txt
8686

8787
#include "settings.h"
8888

@@ -681,7 +681,35 @@ void beginIMU()
681681
checkBattery();
682682
delay(1);
683683
}
684-
684+
685+
//Update the full scale and DLPF settings
686+
ICM_20948_Status_e retval = myICM.enableDLPF(ICM_20948_Internal_Acc, settings.imuAccDLPF);
687+
if (retval != ICM_20948_Stat_Ok)
688+
{
689+
Serial.println(F("Error: Could not configure the IMU Accelerometer DLPF!"));
690+
}
691+
retval = myICM.enableDLPF(ICM_20948_Internal_Gyr, settings.imuGyroDLPF);
692+
if (retval != ICM_20948_Stat_Ok)
693+
{
694+
Serial.println(F("Error: Could not configure the IMU Gyro DLPF!"));
695+
}
696+
ICM_20948_dlpcfg_t dlpcfg;
697+
dlpcfg.a = settings.imuAccDLPFBW;
698+
dlpcfg.g = settings.imuGyroDLPFBW;
699+
retval = myICM.setDLPFcfg((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), dlpcfg);
700+
if (retval != ICM_20948_Stat_Ok)
701+
{
702+
Serial.println(F("Error: Could not configure the IMU DLPF BW!"));
703+
}
704+
ICM_20948_fss_t FSS;
705+
FSS.a = settings.imuAccFSS;
706+
FSS.g = settings.imuGyroFSS;
707+
retval = myICM.setFullScale((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), FSS);
708+
if (retval != ICM_20948_Stat_Ok)
709+
{
710+
Serial.println(F("Error: Could not configure the IMU Full Scale!"));
711+
}
712+
685713
online.IMU = true;
686714
}
687715
else

Firmware/OpenLog_Artemis/menuIMU.ino

Lines changed: 258 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,296 @@ void menuIMU()
1111

1212
if (settings.enableIMU == true)
1313
{
14-
Serial.print(F("2) Toggle Accelerometer Logging: "));
14+
Serial.print(F("2) Accelerometer Logging: "));
1515
if (settings.logIMUAccel) Serial.println(F("Enabled"));
1616
else Serial.println(F("Disabled"));
1717

18-
Serial.print(F("3) Toggle Gyro Logging: "));
18+
Serial.print(F("3) Gyro Logging: "));
1919
if (settings.logIMUGyro) Serial.println(F("Enabled"));
2020
else Serial.println(F("Disabled"));
2121

22-
Serial.print(F("4) Toggle Magnotometer Logging: "));
22+
Serial.print(F("4) Magnotometer Logging: "));
2323
if (settings.logIMUMag) Serial.println(F("Enabled"));
2424
else Serial.println(F("Disabled"));
2525

26-
Serial.print(F("5) Toggle Temperature Logging: "));
26+
Serial.print(F("5) Temperature Logging: "));
2727
if (settings.logIMUTemp) Serial.println(F("Enabled"));
2828
else Serial.println(F("Disabled"));
29+
30+
if (online.IMU == true)
31+
{
32+
Serial.print(F("6) Accelerometer Full Scale: +/- "));
33+
switch (settings.imuAccFSS)
34+
{
35+
case 0:
36+
Serial.println(F("2g"));
37+
break;
38+
case 1:
39+
Serial.println(F("4g"));
40+
break;
41+
case 2:
42+
Serial.println(F("8g"));
43+
break;
44+
case 3:
45+
Serial.println(F("16g"));
46+
break;
47+
default:
48+
Serial.println(F("UNKNOWN"));
49+
break;
50+
}
51+
52+
Serial.print(F("7) Accelerometer Digital Low Pass Filter: "));
53+
if (settings.imuAccDLPF)
54+
{
55+
Serial.println(F("Enabled"));
56+
Serial.print(F("8) Accelerometer DLPF Bandwidth (Hz): "));
57+
switch (settings.imuAccDLPFBW)
58+
{
59+
case 0:
60+
Serial.println(F("246.0 (3dB) 265.0 (Nyquist)"));
61+
break;
62+
case 1:
63+
Serial.println(F("246.0 (3dB) 265.0 (Nyquist)"));
64+
break;
65+
case 2:
66+
Serial.println(F("111.4 (3dB) 136.0 (Nyquist)"));
67+
break;
68+
case 3:
69+
Serial.println(F("50.4 (3dB) 68.8 (Nyquist)"));
70+
break;
71+
case 4:
72+
Serial.println(F("23.9 (3dB) 34.4 (Nyquist)"));
73+
break;
74+
case 5:
75+
Serial.println(F("11.5 (3dB) 17.0 (Nyquist)"));
76+
break;
77+
case 6:
78+
Serial.println(F("5.7 (3dB) 8.3 (Nyquist)"));
79+
break;
80+
case 7:
81+
Serial.println(F("473 (3dB) 499 (Nyquist)"));
82+
break;
83+
default:
84+
Serial.println(F("UNKNOWN"));
85+
break;
86+
}
87+
}
88+
else
89+
{
90+
Serial.println(F("Disabled (Bandwidth is 1209 Hz (3dB) 1248 Hz (Nyquist))"));
91+
}
92+
93+
Serial.print(F("9) Gyro Full Scale: +/- "));
94+
switch (settings.imuGyroFSS)
95+
{
96+
case 0:
97+
Serial.println(F("250dps"));
98+
break;
99+
case 1:
100+
Serial.println(F("500dps"));
101+
break;
102+
case 2:
103+
Serial.println(F("1000dps"));
104+
break;
105+
case 3:
106+
Serial.println(F("2000dps"));
107+
break;
108+
default:
109+
Serial.println(F("UNKNOWN"));
110+
break;
111+
}
112+
113+
Serial.print(F("10) Gyro Digital Low Pass Filter: "));
114+
if (settings.imuGyroDLPF)
115+
{
116+
Serial.println(F("Enabled"));
117+
Serial.print(F("11) Gyro DLPF Bandwidth (Hz): "));
118+
switch (settings.imuGyroDLPFBW)
119+
{
120+
case 0:
121+
Serial.println(F("196.6 (3dB) 229.8 (Nyquist)"));
122+
break;
123+
case 1:
124+
Serial.println(F("151.8 (3dB) 187.6 (Nyquist)"));
125+
break;
126+
case 2:
127+
Serial.println(F("119.5 (3dB) 154.3 (Nyquist)"));
128+
break;
129+
case 3:
130+
Serial.println(F("51.2 (3dB) 73.3 (Nyquist)"));
131+
break;
132+
case 4:
133+
Serial.println(F("23.9 (3dB) 35.9 (Nyquist)"));
134+
break;
135+
case 5:
136+
Serial.println(F("11.6 (3dB) 17.8 (Nyquist)"));
137+
break;
138+
case 6:
139+
Serial.println(F("5.7 (3dB) 8.9 (Nyquist)"));
140+
break;
141+
case 7:
142+
Serial.println(F("361.4 (3dB) 376.5 (Nyquist)"));
143+
break;
144+
default:
145+
Serial.println(F("UNKNOWN"));
146+
break;
147+
}
148+
}
149+
else
150+
{
151+
Serial.println(F("Disabled (Bandwidth is 12106 Hz (3dB) 12316 Hz (Nyquist))"));
152+
}
153+
}
29154
}
155+
30156
Serial.println(F("x) Exit"));
31157

32-
byte incoming = getByteChoice(menuTimeout); //Timeout after x seconds
158+
int incoming = getNumber(menuTimeout); //Timeout after x seconds
33159

34-
if (incoming == '1')
160+
if (incoming == 1)
35161
{
36162
settings.enableIMU ^= 1;
37163
if (settings.enableIMU == true) beginIMU();
38164
else online.IMU = false;
39165
}
40166
else if (settings.enableIMU == true)
41167
{
42-
if (incoming == '2')
168+
if (incoming == 2)
43169
settings.logIMUAccel ^= 1;
44-
else if (incoming == '3')
170+
else if (incoming == 3)
45171
settings.logIMUGyro ^= 1;
46-
else if (incoming == '4')
172+
else if (incoming == 4)
47173
settings.logIMUMag ^= 1;
48-
else if (incoming == '5')
174+
else if (incoming == 5)
49175
settings.logIMUTemp ^= 1;
50-
else if (incoming == 'x')
176+
else if ((incoming == 6) && (online.IMU == true))
177+
{
178+
Serial.println(F("Enter Accelerometer Full Scale (0 to 3): "));
179+
Serial.println(F("0: +/- 2g"));
180+
Serial.println(F("1: +/- 4g"));
181+
Serial.println(F("2: +/- 8g"));
182+
Serial.println(F("3: +/- 16g"));
183+
int afs = getNumber(menuTimeout); //x second timeout
184+
if (afs < 0 || afs > 3)
185+
Serial.println(F("Error: Out of range"));
186+
else
187+
{
188+
settings.imuAccFSS = afs;
189+
ICM_20948_fss_t FSS;
190+
FSS.a = settings.imuAccFSS;
191+
FSS.g = settings.imuGyroFSS;
192+
ICM_20948_Status_e retval = myICM.setFullScale((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), FSS);
193+
if (retval != ICM_20948_Stat_Ok)
194+
{
195+
Serial.println(F("Error: Could not configure the IMU!"));
196+
}
197+
}
198+
}
199+
else if ((incoming == 7) && (online.IMU == true))
200+
{
201+
settings.imuAccDLPF ^= 1;
202+
ICM_20948_Status_e retval = myICM.enableDLPF(ICM_20948_Internal_Acc, settings.imuAccDLPF);
203+
if (retval != ICM_20948_Stat_Ok)
204+
{
205+
Serial.println(F("Error: Could not configure the IMU!"));
206+
}
207+
}
208+
else if ((incoming == 8) && (online.IMU == true) && (settings.imuAccDLPF == true))
209+
{
210+
Serial.println(F("Enter Accelerometer DLPF Bandwidth (0 to 7): "));
211+
Serial.println(F("0: 246.0 (3dB) 265.0 (Nyquist) (Hz)"));
212+
Serial.println(F("1: 246.0 (3dB) 265.0 (Nyquist) (Hz)"));
213+
Serial.println(F("2: 111.4 (3dB) 136.0 (Nyquist) (Hz)"));
214+
Serial.println(F("3: 50.4 (3dB) 68.8 (Nyquist) (Hz)"));
215+
Serial.println(F("4: 23.9 (3dB) 34.4 (Nyquist) (Hz)"));
216+
Serial.println(F("5: 11.5 (3dB) 17.0 (Nyquist) (Hz)"));
217+
Serial.println(F("6: 5.7 (3dB) 8.3 (Nyquist) (Hz)"));
218+
Serial.println(F("7: 473 (3dB) 499 (Nyquist) (Hz)"));
219+
int afbw = getNumber(menuTimeout); //x second timeout
220+
if (afbw < 0 || afbw > 7)
221+
Serial.println(F("Error: Out of range"));
222+
else
223+
{
224+
settings.imuAccDLPFBW = afbw;
225+
ICM_20948_dlpcfg_t dlpcfg;
226+
dlpcfg.a = settings.imuAccDLPFBW;
227+
dlpcfg.g = settings.imuGyroDLPFBW;
228+
ICM_20948_Status_e retval = myICM.setDLPFcfg((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), dlpcfg);
229+
if (retval != ICM_20948_Stat_Ok)
230+
{
231+
Serial.println(F("Error: Could not configure the IMU!"));
232+
}
233+
}
234+
}
235+
else if ((incoming == 9) && (online.IMU == true))
236+
{
237+
Serial.println(F("Enter Gyro Full Scale (0 to 3): "));
238+
Serial.println(F("0: +/- 250dps"));
239+
Serial.println(F("1: +/- 500dps"));
240+
Serial.println(F("2: +/- 1000dps"));
241+
Serial.println(F("3: +/- 2000dps"));
242+
int gfs = getNumber(menuTimeout); //x second timeout
243+
if (gfs < 0 || gfs > 3)
244+
Serial.println(F("Error: Out of range"));
245+
else
246+
{
247+
settings.imuGyroFSS = gfs;
248+
ICM_20948_fss_t FSS;
249+
FSS.a = settings.imuAccFSS;
250+
FSS.g = settings.imuGyroFSS;
251+
ICM_20948_Status_e retval = myICM.setFullScale((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), FSS);
252+
if (retval != ICM_20948_Stat_Ok)
253+
{
254+
Serial.println(F("Error: Could not configure the IMU!"));
255+
}
256+
}
257+
}
258+
else if ((incoming == 10) && (online.IMU == true))
259+
{
260+
settings.imuGyroDLPF ^= 1;
261+
ICM_20948_Status_e retval = myICM.enableDLPF(ICM_20948_Internal_Gyr, settings.imuGyroDLPF);
262+
if (retval != ICM_20948_Stat_Ok)
263+
{
264+
Serial.println(F("Error: Could not configure the IMU!"));
265+
}
266+
}
267+
else if ((incoming == 11) && (online.IMU == true) && (settings.imuGyroDLPF == true))
268+
{
269+
Serial.println(F("Enter Gyro DLPF Bandwidth (0 to 7): "));
270+
Serial.println(F("0: 196.6 (3dB) 229.8 (Nyquist) (Hz)"));
271+
Serial.println(F("1: 151.8 (3dB) 187.6 (Nyquist) (Hz)"));
272+
Serial.println(F("2: 119.5 (3dB) 154.3 (Nyquist) (Hz)"));
273+
Serial.println(F("3: 51.2 (3dB) 73.3 (Nyquist) (Hz)"));
274+
Serial.println(F("4: 23.9 (3dB) 35.9 (Nyquist) (Hz)"));
275+
Serial.println(F("5: 11.6 (3dB) 17.8 (Nyquist) (Hz)"));
276+
Serial.println(F("6: 5.7 (3dB) 8.9 (Nyquist) (Hz)"));
277+
Serial.println(F("7: 361.4 (3dB) 376.5 (Nyquist) (Hz)"));
278+
int gfbw = getNumber(menuTimeout); //x second timeout
279+
if (gfbw < 0 || gfbw > 7)
280+
Serial.println(F("Error: Out of range"));
281+
else
282+
{
283+
settings.imuGyroDLPFBW = gfbw;
284+
ICM_20948_dlpcfg_t dlpcfg;
285+
dlpcfg.a = settings.imuAccDLPFBW;
286+
dlpcfg.g = settings.imuGyroDLPFBW;
287+
ICM_20948_Status_e retval = myICM.setDLPFcfg((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), dlpcfg);
288+
if (retval != ICM_20948_Stat_Ok)
289+
{
290+
Serial.println(F("Error: Could not configure the IMU!"));
291+
}
292+
}
293+
}
294+
else if (incoming == STATUS_PRESSED_X)
51295
break;
52-
else if (incoming == STATUS_GETBYTE_TIMEOUT)
296+
else if (incoming == STATUS_GETNUMBER_TIMEOUT)
53297
break;
54298
else
55299
printUnknown(incoming);
56300
}
57-
else if (incoming == 'x')
301+
else if (incoming == STATUS_PRESSED_X)
58302
break;
59-
else if (incoming == STATUS_GETBYTE_TIMEOUT)
303+
else if (incoming == STATUS_GETNUMBER_TIMEOUT)
60304
break;
61305
else
62306
printUnknown(incoming);

0 commit comments

Comments
 (0)