• Hi Robin,

    Thank you for helping me so much

    Sorry if I misunderstand, I am not so sure how to measure the repeated part if you mean measure how fast the interval is running.

    I put the measure time in the all read_FIFO, read_Normal, and read_Time and this is my output

    Read FIFO 0.00033950805 946686551.91729545593
    elapsed 0.00323581695
    Read FIFO 0.00033664703 946686551.92159366607
    elapsed 0.00324440002
    Read FIFO 0.00037765502 946686551.92586135864
    elapsed 0.00328826904
    Read FIFO 0.00033760070 946686551.93021202087
    elapsed 0.00324249267
    Read FIFO 0.00037860870 946686551.93448162078
    elapsed 0.00328826904
    Read FIFO 0.00033855438 946686551.93883323669
    elapsed 0.00324440002
    Read Normal 0.00038623809 946686551.94312000274
    elapsed 0.00335884094
    Read Time 0.00034713745 946686551.94751930236
    elapsed 0.00702095031
    8793 -567 -18040 -23 -102 4237 undefined 3902886 0.03861045837
    Read FIFO 0.00034427642 946686551.95695877075
    elapsed 0.00325965881
    Read FIFO 0.00038528442 946686551.96123790740
    elapsed 0.00331974029
    Read FIFO 0.00034427642 946686551.96561431884
    elapsed 0.00326347351
    Read FIFO 0.00038528442 946686551.96989727020
    elapsed 0.00330162048
    Read FIFO 0.00034523010 946686551.97425270080
    elapsed 0.00325775146
    Read FIFO 0.00034427642 946686551.97857093811
    elapsed 0.00325298309
    Read Normal 0.00034999847 946686551.98289966583
    elapsed 0.00330257415
    Read Time 0.00035190582 946686551.98722839355
    elapsed 0.00691509246
    8029 -1069 -14708 -24 -117 4237 undefined 3902939 0.03862571716
    

    and the code looks like this

    //Read timestamp function
    
    function readtime(ss)
    {
            var t = getTime();
            var elapsed = 0;
            console.log( "Read Time " + (getTime()-t) + " " + t );
            hi = SPI_read(FIFO_DATA_OUT_L,ss);
            hi2 = SPI_read(FIFO_DATA_OUT_H,ss);
            non = SPI_read(FIFO_DATA_OUT_L,ss);
            lo = SPI_read(FIFO_DATA_OUT_H,ss);
            step = SPI_read(FIFO_DATA_OUT_L,ss);
            step = SPI_read(FIFO_DATA_OUT_H,ss);
            hi2 = hi2 << 16;
            hi = hi << 8;
            Value = hi2 | hi | lo;
            elapsed = getTime()-t;
            console.log( "elapsed " + elapsed );
            return Value;
    }
    
    
    var st = 0;
    //var s2 = 0;
    //print( "OMX", "OMY", "OMZ","AX", "AY", "AZ",,"TEMP","TimeStamps");
    //var start = getTime();
    
    function extraction()
    {
           // "compiled";
              //print(Ntotaldata());
              st = getTime();
              //if(((SPI_read(FIFO_STATUS2,ss))&0b0001­0000) != 0b00010000)
              //{
                 console.log( 
                  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), 
                   getTime()-st);
             // }
    }
    
    
    setInterval(extraction,0.002);
    

    ss

    
    function read_FIFO(ss)
    {
      var test;
      var t = getTime();
      var elapsed = 0;
      console.log( "Read FIFO " + (getTime()-t) + " " + t );
      
      test = signshort(SPI_read(FIFO_DATA_OUT_H,ss)<<­8|SPI_read(FIFO_DATA_OUT_L,ss));
    
      elapsed = getTime()-t;
      console.log( "elapsed " + elapsed );
      return test
    }
    
    function read_normal(ss)
    {
      var test1;
      var t = getTime();
      var elapsed = 0;
      console.log( "Read Normal " + (getTime()-t) + " " + t );
      test = signshort(SPI_read(TEMP_OUT_H,ss)<<8 | SPI_read(TEMP_OUT_L,ss));
      elapsed = getTime()-t;
      console.log( "elapsed " + elapsed );
      return test1;
    }
    

    I believe the time I measure is in millisecond, and I also measure the clock frequency of the SPI is running correctly at 10 MHz, so I think both system and SPI should techninilly running fast enough? and thank you again : )

    yes, that is the IMU datasheet.

    I configured FIFO as continuous mode so I can keep the data from the IMU with a set timestamp and it can keep running for hours.

    The goal is to do the data collection at 833 Hz for hours and the output timestamps gap should be fixed (increment by 48 or 49 each timestamp). The FIFO mode provides the correct data but I have to reset every time to get the new set of data since it will stop filling after it full. The reset process result in missing some data, so it is not very ideal

    Attached is the SPI clock frequency measured from the oscilloscope

  • Sat 2019.10.44

    For L2

    'elapsed 0.00323581695'

    Three msec is about what I see with other devices using SPI

    L27 setInterval(extraction,0.002);

    Are you still getting errors with the above?

    A typical value for the duration would be 2 to represent 0.002, but my belief is that is still too small. I would expect a value around 50+

    Try setInterval(extraction,150);

    So my guess is that we need to look at how the request for data is made, not the actual transfer of data that seems to be returning accurate values. If setInterval() which needs to be in msec is changed to a value of 100-2000 does the error after around eight or so iterations still occur?



    Was the datasheet link in #19 accurate?

About

Avatar for Robin @Robin started