• Code to Read the Gyroscope and Accelerometer Using the FIFO

    The Gyroscope ODR (Output Data Rate) Also Controls the Accelerometer ODR if it is On.

    /*
    ODR_G 
    Gyroscope output data rate selection. Default value: 000
    Table 46
    | Value | ODR [Hz] | Cutoff [Hz] |
    | --- | --- | --- |
    | 0 | Power-down | n.a. |
    | 1 | 14.9 | 5 |
    | 2 | 59.5 | 19 |
    | 3 | 119 | 38 |
    | 4 | 238 | 76 |
    | 5 | 476 | 100 |
    | 6 | 952 | 100 |
    | 7 | n.a. | n.a.|
    */
    W.AGwrite(W.REGval.ODR_G,0);
    

    By setting it to 0 (Off) the Accelerometer is controlled by

    /*
    ODR_XL 
    Accelerometer Output data rate and power mode selection. default value: 000 
    ###### Table 68
    | ODR_XL | ODR selection [Hz] |
    | --- | --- |
    | 0 | Power-down |
    | 1 | 10 Hz |
    | 2 | 50 Hz |
    | 3 | 119 Hz |
    | 4 | 238 Hz |
    | 5 | 476 Hz |
    | 6 | 952 Hz |
    | 7 | n.a. |
    */
    W.AGwrite(W.REGval.ODR_XL,2);
    

    Producing this output:

    Alength= 30
    A=, -455,-1526,16800
    A=, -715,-1489,16801
    A=, -595,-1488,16801
    A=, -593,-1497,16854
    A=, -757,-1442,16755
    A=, -527,-1473,16816
    A=, -623,-1513,16852
    A=, -736,-1483,16771
    A=, -511,-1495,16811
    A=, -679,-1517,16867
    >clearInterval();
    

    Changing the gyro ODR to non zero

    W.AGwrite(W.REGval.ODR_G,1);
    

    Produces this output:

    Alength= 18
    G=, -741,206,-16, A=, -715,-1464,16811
    G=, -738,200,-19, A=, -787,-1478,16819
    G=, -734,197,-23, A=, -755,-1489,16795
    Alength= 18
    G=, -737,199,-20, A=, -854,-1499,16796
    G=, -740,201,-17, A=, -829,-1453,16775
    G=, -727,198,-17, A=, -788,-1484,16802
    >clearInterval();
    

    Some Notes

    G is Gyro X,Y ,and Z raw counts. A= Accelerometer X,Y, and Z raw counts.
    Note a new version of LSM9DS1.js is attached and the test program AGtest1.js
    The LSM9DS1.js goes in the modules subdirectory of your WebIDE project.
    The data are read every 200 ms, determined by a set interval.
    The ODR and the interval interact. At low ODR fewer samples are in the FIFO in a 200 ms interval.
    The FIFO can contain up to 32 samples and can be set to fewer samples if needed.


    2 Attachments

About