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

setOffset() fails when called again #51

Closed
fahadshihab opened this issue Dec 31, 2023 · 7 comments
Closed

setOffset() fails when called again #51

fahadshihab opened this issue Dec 31, 2023 · 7 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@fahadshihab
Copy link

The setOffset() function does not work as expected when called more than once after the program starts. This makes it difficult to zero again when the program is running.

The current workaround is to use setOffset() in conjunction with getOffset() but the user has to implement the math for it.

@RobTillaart RobTillaart self-assigned this Dec 31, 2023
@RobTillaart RobTillaart added question Further information is requested bug Something isn't working labels Dec 31, 2023
@RobTillaart
Copy link
Owner

Thanks for reporting the issue.
I will look into it later this week

The setOffset() function does not work as expected when called more than once after the program starts.

Can you elaborate, give examples what you expect?
e.g setOffset(0) should it remove all offset or not change the current offset?

@RobTillaart
Copy link
Owner

just a thought, do you need a function like

  • increaseOffset(float degrees) increase or decrease the current offset with degrees

@fahadshihab
Copy link
Author

Suppose, at system start, the encoder reads 200 degrees.
Then when setOffset(-200) is called, the encoder now reads 0 degrees.
Then the system is moved to, say, 30 degrees. The encoder now reads 30 degrees.
When setOffset(-30) is called, the encoder reads 200 degrees, instead of zero.

The problem is that the setOffset() function sets the offset value directly instead of taking into account that the offset has been previously set.

@fahadshihab
Copy link
Author

Yes, something like increaseOffset() or setReference(float) could work.

setReference(float angle) could calculate the offset automatically and set the current encoder reading to angle. I feel it's a much more useful function when the readings must be reset multiple times in a program.

RobTillaart added a commit that referenced this issue Dec 31, 2023
@RobTillaart
Copy link
Owner

@fahadshihab

I have created a develop branch which includes the increaseOffset() function.
Please verify if this meet your needs. If so I will merge it into version 0.5.1

@RobTillaart
Copy link
Owner

@fahadshihab
Did you verify the increaseOffset() function yet?

@fahadshihab
Copy link
Author

Yup. This works. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants