• 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

  • 'The goal is to do the data collection at 833 Hz for hours'

    Would you point to a page within the datasheet, that suggests using that frequency or range of frequencies for your use. When I read over, my interpretation of how to request data was a bit different.

    How are the gyro, or accelerometer used? It might be that your requirement is different than I envision.

    Are you picking up the device from a stationary position and expecting the Espruino device to respond to that input?



    p. 35 of datasheet
    Are we in 'continuous' mode?

    Is so, the FIFO buffer is probably filling up before each data item is removed from the buffer and the device is cramming in bytes until errors in output are seen. Could this be a possibility?



    How often do you actually need the data, the device outputs? It seems that it is desired in the msec range, but my interpretation is that reading those values should be in the many tens of msec range, say every half second or so.

  • I just tried setInterval(extraction,150);
    but it is only outputting one correct data set this time.

    8539 -645 -18294 -256 126 4104 -668 4262111 0.02233409881
    11 15 15 229 225 227 -669 3328 0.02214241027
    11 11 19 229 227 223 -653 4864 0.02214145660
    

    Oh sorry, on page 57/114 FIFO ODR can be 833Hz frequency range from 12.5 to 6.6kHz. so we choose 833Hz because it is a nice frequency for the algorithm that we are developing for processing the data

  • I will integrate the gyro over that time period, so I think I will every single set of data that output at 833Hz,
    then I will use UART to pass the integrated data and accelerometer to the data handling unit.

    "Is so, the FIFO buffer is probably filling up before each data item is removed from the buffer and the device is cramming in bytes until errors in output are seen. Could this be a possibility?"

    I think this is possible. but if this is true, wouldn't it make it very hard to pull the data in high frequency?

    Haha have a good time

About

Avatar for Robin @Robin started