Skip to content

Conversation

@Santynolo
Copy link

This PR adds the following functions:

  • setCurrentAngle(float set_angle)
    Sets the current angle of the encoder by modifying the CNT register in the timer.
  • setEncoderCount(uint32_t ecount)
    Sets the CNT register in the timer.
  • getEncoderTimerHandle()
    Returns the encoder timer handle if the user wants to modify any register

I have also implemented the index pin function that was commented out, and added some debug messages to better debug issues caused by timer configuration and/or pin selection
Tested on an STM32G431 MCU the following:

  • setCurrentAngle()
  • setEncoderCount()
  • Index search

I have also modified the README to reflect these changes.
i'll come back to confirm the index search to be working, but it's so simple i don't see any potential issues.
I have left the ETR line not implemented since i think it's not really necessary? I don't see any potential benefits except full rotations tracking. But i've left a potential init structure commented out in the code for the future.

@Santynolo
Copy link
Author

I did forget to add pinMode here (and have added it)
image
But it seems like this does not work? This interrupt triggers after initFOC() fails to find the index on my end. If anyone could suggest why or test it out themselves (after adding pinMode after the if statement) it would be great...

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.

1 participant