AMCBLDC: Fix computation of angle when using quadrature encoder #332
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is aimed at the AMCBLDC Hal, to fix:
Detection of the sector of the phases
line 231 in pwm.c
In this line we compute the sector that the electric angle belongs to = [0, 1, ..., 5].
Casting to int16 would cause sector to have the values [-5 -3 -1 1 3 5], which would mess up the later computations
Desynching between hall sensors angle and quadrature encoder angle
A reset function of the quadrature encoder angle is applied whenever a full rotation is done.
A full rotation is defined as the transition between sector 5 and sector 0.
This procedure is also used to during calibration step 0, to transition to step 1:
Then, we compute the offset by taking the average of the 6 values, and apply it.
cc @sgiraz @pattacini @valegagge