The attached program AGmagtest.js uses the LSM9DS1.js module and the preceding calibrations to produce data in engineering units.
//autocalc 0=raw, 1=raw-offset, 2 Engineering Units var autocalc=2;
W.AGwrite(W.REGval.ODR_G,1);//do gyro and acceleration //W.AGwrite(W.REGval.ODR_G,0);//do acceleration only.
M magnetometer values are in Gauss, G gyroscope values are in degrees per second A acceleration values are in g, (1= Earth gravity)
M,0.0150,-0.0847,-0.1949,G,0.3582,-0.1057,-0.1222,A,0.0839,-0.0478,0.9993, M,0.0172,-0.0830,-0.1933,G,0.3358,-0.1581,-0.1297,A,0.0869,-0.0552,1.0039, M,0.0172,-0.0830,-0.1933,G,0.3433,-0.1655,-0.1297,A,0.0841,-0.0479,1.0000, M,0.0172,-0.0830,-0.1933,G,0.3807,-0.1057,-0.1222,A,0.0831,-0.0438,0.9987, M,0.0151,-0.0866,-0.1965,G,0.4031,-0.2104,-0.1222,A,0.0817,-0.0398,0.9956, M,0.0151,-0.0866,-0.1965,G,0.3807,-0.0833,-0.1222,A,0.0821,-0.0416,0.9960, M,0.0151,-0.0866,-0.1965,G,0.4031,-0.1879,-0.1147,A,0.0831,-0.0460,0.9991, M,0.0162,-0.0845,-0.1933,G,0.3732,-0.0982,-0.1446,A,0.0822,-0.0459,1.0009, M,0.0162,-0.0845,-0.1933,G,0.3059,-0.1132,-0.1297,A,0.0834,-0.0461,1.0031, >clearInterval();
M,0.0154,-0.0826,-0.1849,A,0.0864,-0.0516,1.0014, M,0.0154,-0.0826,-0.1849,A,0.0868,-0.0537,1.0017, M,0.0154,-0.0826,-0.1849,A,0.0858,-0.0549,1.0009, M,0.0154,-0.0826,-0.1849,A,0.0862,-0.0567,1.0032, M,0.0154,-0.0826,-0.1849,A,0.0861,-0.0594,1.0028, M,0.0154,-0.0826,-0.1849,A,0.0852,-0.0598,1.0009, M,0.0154,-0.0826,-0.1849,A,0.0883,-0.0601,0.9992, M,0.0154,-0.0826,-0.1849,A,0.0877,-0.0574,0.9964, >clearInterval();
1 Attachment
@ClearMemory041063 started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
AGmagtest1.js
The attached program AGmagtest.js uses the LSM9DS1.js module and the preceding calibrations to produce data in engineering units.
The variable autocalc controls the type of units displayed.
//autocalc 0=raw, 1=raw-offset, 2 Engineering Units
var autocalc=2;
In the function setupAG() the gyro ODR determines if gyro data are available.
W.AGwrite(W.REGval.ODR_G,1);//do gyro and acceleration
//W.AGwrite(W.REGval.ODR_G,0);//do acceleration only.
Here is sample output with autocalc=2 and ODR_G=1
M magnetometer values are in Gauss,
G gyroscope values are in degrees per second
A acceleration values are in g, (1= Earth gravity)
Changing ODR_G to 0 produces:
1 Attachment