Jump to content

Reset the Hall Effect V2 counter with its periodic callback (uc bindings)


Recommended Posts

Hi,

I was wondering how to reset the Hall Effect V2 counter when using the periodic callback instead of the tf_hall_effect_v2_get_counter() function. I use the uc bindings.
tf_hall_effect_v2_get_counter() has an input parameter for that purpose, but the counter callback configuration does not.

I could not find out whether the callback resets the counter automatically by scanning through the uc bindings (I assume it does not though).

I like to always reset the counter when the periodic callback was triggered to measure the RPM of a wheel.

Any chance it can be done with the callback too?

Cheers,
Claudio

Edited by cl-
Link to comment
Share on other sites

Posted (edited)

I edited previous my post and wrote more details, but the forum kicked me out because it took "too long" to write. All my changes were lost somehow, which is strange.

Edited by cl-
Link to comment
Share on other sites

Posted (edited)

Once again (in short)

As it's not allowed to call tf_hall_effect_v2_get_counter() inside the callback handler, one possible approach would be to set a flag inside user_data to trigger a manual counter reset outside the callback handler. However, if the delay between the callback handler was triggered and the subsequent, manual counter reset outside the callback is too long, one might in theory miss counters when the counter frequency is very high (or am I wrong?). I doubt that might ever play a role in my special use case (20 counters per second), but if one would approximate the maximum of 10 kHz?

What's the right approach to reset the counter with the periodic callback? Or is it done automatically anyway, but it's just not "visible" in the source code?

Edited by cl-
Link to comment
Share on other sites

On 8/27/2022 at 2:26 PM, cl- said:

What's the right approach to reset the counter with the periodic callback?

This is not possible in a robust way right now. Even if the uC bindings would allow you to call the getter to reset the count in the callback, you could still lose count.

The callback doesn't rseet the count, only the getter with reset_counter=true does it.

If you want to use the callback ou can emultate a reset in your code by remembering the counter value from the previous callback call and subtract that from the new value.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...