• Hi Robin and AkosLukacs,

    Thank you for taking your time helping me.

    Here is my code and output for measuring one read_FIFO, (compare with 1/833Hz = 0.0012s). I just realized getTime() was actually returning million seconds (Correct me if I am wrong), the speed is actually very fast if the value that return is ms. (500-1000 times fast than the data generated).

    I am concerning if that's my IMU's configuration, I will double-check that.

    However, when I decrease the speed to 52Hz or 26 Hz, the data was actually generated properly. and when I optimize the code, a couple more correct data set will appear before it gets messed up.

    Not really sure what might be the issue now.

    var t = getTime();
    var elapsed = 0;
    console.log( "start of SPI call " + (getTime()-t) + " " + t );
    //extraction();
    
    omx  = read_FIFO(ss);
    
    elapsed = getTime()-t;
    console.log( "elapsed " + elapsed );
    
    

    And the corresponding output is:

    start of SPI call 0.00700378417 946685774.25032615661
    elapsed 0.01593494415
    

    Enable extraction and disable read_FIFO() in the code

    start of SPI call 0.00715160369 946686294.47058963775
    elapsed 0.02543163299
    

    The code to run one complete extraction() with no print

    var t = getTime();
    var elapsed = 0;
    console.log( "start of SPI call " + (getTime()-t) + " " + t );
    
    
    
    function extraction()
    {
                  omx  = read_FIFO(ss),
                  omy  = read_FIFO(ss),
                  omz  = read_FIFO(ss),
                  ax   = read_FIFO(ss),
                  ay   = read_FIFO(ss),
                  az   = read_FIFO(ss),
                  temp = read_normal(ss),
                  tm   = readtime(ss)
    }
    
    extraction();
    
    elapsed = getTime()-t;
    console.log( "elapsed " + elapsed );
    
    

    Output

    start of SPI call 0.00709629058 946686935.69506931304
    elapsed 0.04530811309
    

    Here is my read_FIFO code, I am calling two SPI_read in this function, FIFO_DATA_OUT_H/L are two registers to store the generated FIFO data

    function read_FIFO(ss)
    {
      return signshort(SPI_read(FIFO_DATA_OUT_H,ss)<<­8|SPI_read(FIFO_DATA_OUT_L,ss));
    }
    

    Thank you very much.

  • Thr 2019.11.07

    My DISCLAIMER from #16 still applies,

    Hi @user101931, a quick cursory peek implies the SPI part of the code is working as it should. The timing values don't appear out of range. I'll do a math check this weekend.


    'a couple more correct data set will appear before it gets messed up'

    What isn't shown is the repeating part. Would you please post the setInterval() line of code.



    Although not absolutely needed, but . . . It would help immensely if you could also provide a timing check on just single individual lines, so that some quick mental cross checks could be performed.

    // such as
    
    ax   = read_FIFO(ss);
    
    // from inside the read_FIFO() function - a single request
    SPI_read(FIFO_DATA_OUT_H,ss);
    
    


    'I just realized getTime() was actually returning million seconds (Correct me if I am wrong)'

    There are a few links in other posts within this thread, searching w3schools.com and MDN developer.mozilla.org should allow the discovery of that answer. If you are still stuck, please post the final links where discovery ends, and I'll do some digging after that. I'm sure the learning how to find those links will enhance the discovery process and boost your ego. ;-)

    When successful, please post the link for future enthusiasts reading this thread. Thanks.

    I'll have a bit of time to dig into this over the weekend.

    Is this the datasheet for the device?

    https://www.st.com/resource/en/datasheet­/lsm6dsl.pdf

About

Avatar for user101931 @user101931 started