kriswiner / IIS3DWB

Arduino sketches for ST's IIS3DWB vibration analyzer accelerometer
22 stars 12 forks source link

Basic code data sampling #6

Open felipecookh opened 3 years ago

felipecookh commented 3 years ago

Hi Kris, once again, thanks for your code. To give back some contribution to you, I wanted to comment that I used your basic code to gather certain number of samples (instead of using the FIFO) and then apply the FFT.

But using your basic code, to me happened that some data points were corrupted with wrong values (around 10 of 2048 points), even with the if(IIS3DWB_DataReady) .

I've solved the problem using something like:

` for(int i = 0; i < samples; i+=1) {

     while(!IIS3DWB_DataReady){}; //this one changes with INT1

     IIS3DWB_DataReady = false;
     IIS3DWBstatus = IIS3DWB.DRstatus(); // read data ready status

     if (IIS3DWBstatus & 0x01) {         // if new accel data is available, read it
       // Handle data
     }
     else{
          Serial.println("Data cycle not functioning!"); 
          while(1){};
     }
 }`

I've prefered this direct implementation instead of your FIFO code because using that mode, between each cycle of the watermark stop, 3 values where missing from the begining of each new cycle (I've checked with the timestamp and tag counter values).

Regards,

kriswiner commented 3 years ago

Thanks for the note Felipe, What MCU are you using? Are you using an Arduino core, which one? I am wondering if your missing data has more to do with the I2C implementation rather than anything to do with the sketch per se

On Mon, Sep 20, 2021 at 5:36 PM felipecookh @.***> wrote:

Hi Kris, once again, thanks for your code. To give back some contribution to you, I wanted to comment that I used your basic code to gather certain number of samples (instead of using the FIFO) and then apply the FFT.

But using your basic code, to me happened that some data points were corrupted with wrong values (around 10 of 2048 points), even with the if(IIS3DWB_DataReady) .

I've solved the problem using something like:

` for(int i = 0; i < samples; i+=1) {

 while(!IIS3DWB_DataReady){}; //this one changes with INT1

 IIS3DWB_DataReady = false;
 IIS3DWBstatus = IIS3DWB.DRstatus(); // read data ready status

 if (IIS3DWBstatus & 0x01) {         // if new accel data is available, read it
   // Handle data
 }
 else{
      Serial.println("Data cycle not functioning!");
      while(1){};
 }

}`

I've prefered this direct implementation instead of your FIFO code because using that mode, between each cycle of the watermark stop, 3 values where missing from the begining of each new cycle (I've checked with the timestamp and tag counter values).

Regards,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/IIS3DWB/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKTWUZVJGZTIJA5FUMLUC7HRRANCNFSM5ENELGVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

kriswiner commented 3 years ago

Forgot this is an SPI sensor. Still which MCU and which core?

On Mon, Sep 20, 2021 at 5:55 PM Tlera Corporation @.***> wrote:

Thanks for the note Felipe, What MCU are you using? Are you using an Arduino core, which one? I am wondering if your missing data has more to do with the I2C implementation rather than anything to do with the sketch per se

On Mon, Sep 20, 2021 at 5:36 PM felipecookh @.***> wrote:

Hi Kris, once again, thanks for your code. To give back some contribution to you, I wanted to comment that I used your basic code to gather certain number of samples (instead of using the FIFO) and then apply the FFT.

But using your basic code, to me happened that some data points were corrupted with wrong values (around 10 of 2048 points), even with the if(IIS3DWB_DataReady) .

I've solved the problem using something like:

` for(int i = 0; i < samples; i+=1) {

 while(!IIS3DWB_DataReady){}; //this one changes with INT1

 IIS3DWB_DataReady = false;
 IIS3DWBstatus = IIS3DWB.DRstatus(); // read data ready status

 if (IIS3DWBstatus & 0x01) {         // if new accel data is available, read it
   // Handle data
 }
 else{
      Serial.println("Data cycle not functioning!");
      while(1){};
 }

}`

I've prefered this direct implementation instead of your FIFO code because using that mode, between each cycle of the watermark stop, 3 values where missing from the begining of each new cycle (I've checked with the timestamp and tag counter values).

Regards,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/IIS3DWB/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKTWUZVJGZTIJA5FUMLUC7HRRANCNFSM5ENELGVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

felipecookh commented 3 years ago

Yes, it is an SPI sensor. I'm using an Arduino Portenta, M7 core.

In your basic code, collect many successive samples and check if some are corrupted. Similarly, check in your FIFO code, using the timestamp and the counter tag, if some samples when the cycle begins again are missing.

Regards

kriswiner commented 3 years ago

I am pretty sure this is a Portenta issue but I will check when I get back to the IIS3DWB...

On Tue, Sep 21, 2021 at 1:35 PM felipecookh @.***> wrote:

Yes, it is an SPI sensor. I'm using an Arduino Portenta, M7 core.

In your basic code, collect many successive samples and check if some are corrupted. Similarly, check in your FIFO code, using the timestamp and the counter tag, if some samples when the cycle begins again are missing.

Regards

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/IIS3DWB/issues/6#issuecomment-924363535, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKXI2WB7UFCIQNLUOODUDDUAFANCNFSM5ENELGVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.