gauteh / sfy

🌊 A lightweight wave buoy for near-shore deployments.
MIT License
45 stars 7 forks source link

Observed frequency is 48.57 Hz rather than 52 Hz (IMU datasheet) #125

Closed gauteh closed 1 year ago

gauteh commented 1 year ago
I am using the LSM6DSOX and ISM330DHCX in FIFO mode at 52 Hz or 208 Hz. For 52 Hz the real frequency turns out to be
 about 48.57 Hz, and proportionally so for 208 Hz. I am confirming this through the number of samples collected between GPS
 fixes and when comparing a signal against another type of sensor. The observed frequency is stable at this rate.

Could this be real or is there something wrong in my application? The FIFO is checked using an RTC and is never allowed to 
run full (the overflow, full, overflow_latched) bits are checked. I drain (pop) the number of samples available at the RTC
 interrupt, but do not reset it. Does operating the FIFO or draining it halt the FIFO or reduce the number of samples?

I observe the same both with the LSM6DSOX and the ISM330DHCX.

IMU configuration: [github.com/gauteh/sfy/blob/main/sfy-buoy/src/waves/mod.rs#L231](https://github.com/gauteh/sfy/blob/main/sfy-buoy/src/waves/mod.rs#L231)

FIFO drain function: [github.com/gauteh/sfy/blob/main/sfy-buoy/src/waves/mod.rs#L395](https://github.com/gauteh/sfy/blob/main/sfy-buoy/src/waves/mod.rs#L395)
gauteh commented 1 year ago

We are probably doing this correctly: https://community.st.com/s/question/0D73W000000bAS4SAM/detail?fromEmail=1&s1oid=00Db0000000YtG6&s1nid=0DB0X000000DYbd&s1uid=0053W000001snzQ&s1ext=0&emkind=chatterCommentNotification&emtm=1684313246967&emvtk=E54ccDtPqWVECsAa5CCiLUY.7M7t1PbWVtlIXpFI4Uk%3D

@akkermei

You are not making any errors in your application, consider that the spread can span the +-10% range so 
having 48.57 Hz instead of 52Hz is acceptable.
jerabaul29 commented 1 year ago

Ouch, +-10% is a lot of uncertainty. But if they say so... Good to keep in mind for future use :) .

gauteh commented 1 year ago

There was a bug in the dataset generation where I forgot to take the offset in the FIFO into account when generating the time vector. Fixed on main. This was a post-processing bug, so by re-running dataset-exports the error is gone and the frequency is much closer to 52 Hz (and no correction is usually necessary).

gauteh commented 1 year ago

I spoke too soon (again...): the variation in frequency is real, but I do not think it is an error on our part. For the buoys tested at sintef the frequencies are:

Run4: GPS estimated frequency for 23: 48.59990507831039 Hz
Run4: GPS estimated frequency for 16: 48.57685009487666 Hz
Run4: GPS estimated frequency for 25: 49.06564446574029 Hz
Run4: GPS estimated frequency for 1: 55.89519650655022 Hz
Run4: GPS estimated frequency for 2: 55.80381471389645 Hz

So within the 10%. The last two buoys are the SINTEF-built ones, with ISM330DHCX. The others are LSM6DSOX. Also they might be from the same batch.

gauteh commented 1 year ago

image

gauteh commented 1 year ago

ODR specified in the datasheet refers to typical value, so the actual ODR may differ from typical value.

You can get actual ODR of the device following equation "ODRactual" stated in section 6.4 Timestamp of both AN for LSM6DSOX and ISM330DHCX:

https://www.st.com/resource/en/application_note/an5398-ism330dhcx-alwayson-3d-accelerometer-and-3d-gyroscope-with-digital-output-for-industrial-applications-stmicroelectronics.pdf

https://www.st.com/resource/en/application_note/an5272-lsm6dsox-alwayson-3d-accelerometer-and-3d-gyroscope-stmicroelectronics.pdf