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

Hall sensor without interrupt #424

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

Candas1
Copy link
Collaborator

@Candas1 Candas1 commented Jul 17, 2024

This code will allow running a hall sensor without interrupt if the interrupts if enableinterrupts() is not used.
It will poll the hall sensor states during the sensor.update instead.
There are also small optimizations of the hall sensor updatestate code.

More details in this issue.

@askuric askuric linked an issue Jul 18, 2024 that may be closed by this pull request
@askuric
Copy link
Member

askuric commented Jul 18, 2024

I am in for merging this. for the v2.3.4!
I'll integrate it to the docs as well.

@askuric askuric added this to the 2.3.4_Release milestone Jul 18, 2024
@runger1101001 runger1101001 merged commit 31ed492 into simplefoc:dev Jul 19, 2024
22 checks passed
@askuric
Copy link
Member

askuric commented Jul 20, 2024

Hey @Candas1,

Would you have time to add an exmaple code in the library examples folder of how to use this new HallSensor. :D
I think the ideal would be to add it in the examples/utils/sensor_test folder:
https://github.com/simplefoc/Arduino-FOC/tree/master/examples/utils/sensor_test

@Candas1
Copy link
Collaborator Author

Candas1 commented Jul 20, 2024

Hi @askuric,

It will just work by commenting enableinterrupt().

So it might not require an additional example, but I can add a comment there. Most important might be to explain in the docs when to use it.

Looking at the folder you shared, I have one doubt. Is this still required ?

  • it works only on arduino's (can number of interrupt be a bottleneck on stm32 or esp32 ? )
  • it requires an additional library
  • as it runs each listener one by one, it can potentially run updateState() several times and with partial information if more than one hall state changed
  • my code needs sensor.update() to run often enough so it can be impacted by a delay in the loop (happened to a user yesterday), pcimanager seems to rely on global interrupts

@askuric
Copy link
Member

askuric commented Jul 20, 2024

Ok cool!
I'd still add an example to make sure that peole don't get ocnfused, but I can do it quickly as its so simple, don't worry about it.

Yeah, I'd still keep the software interrupts for now, we can remove them in the future releases.

I'm updating the docs at the moment. Would you agree with this statement?

RULE OF THUMB: Hardware/Software or No interrupts?

  • Start with the no interrupts and see if the performance is good enough for your application.
  • If the performance is not good enough and if you have enough hardware interrupt pins, try using hardware interrupts.
  • Otherwise, if you are using Arduino boards, try using software interrupts. (worst performance solution to be expected)

@Candas1
Copy link
Collaborator Author

Candas1 commented Jul 20, 2024

Yes that's ok.

We will get more feedback in the future as users experiment, so we can add more details later if needed. (fast vs slow hardware, fast vs slow motor, accuracy for velocity control, ....)

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

Successfully merging this pull request may close these issues.

[FEATURE] Hall sensor without interrupt
3 participants