Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to set the range and rate #1

Open
sandeepmistry opened this issue Jul 24, 2019 · 8 comments
Open

Add functions to set the range and rate #1

sandeepmistry opened this issue Jul 24, 2019 · 8 comments

Comments

@sandeepmistry
Copy link
Contributor

Feedback from @tigoe.

Would be good to add functions to set the range and rate, like with the old CurieIMU.

@cmaglie was there any reason why this wasn't included in the original MotionSense.h spec?

@cmaglie
Copy link

cmaglie commented Jul 25, 2019

No, we just didn't think about it.

BTW, what's the use-case for those functions?

@tigoe
Copy link

tigoe commented Jul 25, 2019 via email

@cmaglie
Copy link

cmaglie commented Jul 26, 2019

we can add a method like:

IMU.setAccelerometerRange(5.5)

that would give you the best sensitivity available for the given range (the sensor may have fixed ranges available say, 2G, 4G, 8G, in this case 8G will be selected to achieve the requested 5.5).

@cmaglie
Copy link

cmaglie commented Jul 26, 2019

About setting the reading frequency, we have a similar problem: the possible reading frequencies available may not match the requested one. This may lead to some troubles if you do calculations that involve time and you expect, say, 100 samples per second but you instead get 125.

The only way that comes to mind is to make two methods, one to set the desired frequency and another to query the real one:

IMU.setReadingFrequency(100.0);
float hz = IMU.getReadingFrequency();  // hz maybe be very different from 100.0

maybe it's worth using a name that implies that setting the frequency may not be accurate:

IMU.setReadingFrequencyAsCloseAsPossibleTo(100.0);

@tigoe
Copy link

tigoe commented Jul 26, 2019 via email

@tigoe
Copy link

tigoe commented Jul 26, 2019 via email

@cmaglie
Copy link

cmaglie commented Jul 26, 2019

We can surely include the specific values for the LSM6DS3 in the Arduino_LSM6DS3 library (and we could probably do that right now without much thinking).

What I want to achieve here is to find a "common" base class like the MotionSense.h, otherwise all the examples we make for the LSM6DS3 will be usable only on this sensor with this library (unless we start to tweak constants and values to make it work with another sensor/library).

So here I'm basically following Sandeep's question:

was there any reason why this wasn't included in the original MotionSense.h spec?

the reason is that we should basically think about a generic API that fits well on all sensors, so:

  • the measuring range could be surely approximated, the sensor would always return the best value it can within the requested range
  • about the sampling frequency there isn't much we can do, probably the sensor has his own sampling frequency (or just a few to choose from), so we could probably set the closest one but this could be very different from the one requested.

@tigoe
Copy link

tigoe commented Jul 26, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants