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 adds a function to characterise a motors resistance, d&q-axis inductance and electrical-zero-angle.
It should run on all platforms, as long as there is working current sensing (and optionally an angle sensor for the electrical zero only(!)), but I can only test on the ESP32, so it would be great if someone tried this out on other micros.
And perhaps someone could try the stepper motor support, because I´m not sure if the measurements will need a correction factor there.
In my experience, the resistance measurement is quite accurate for gimbal motors, with maybe -+10% for a drone type BLDC.
The inductances are less accurate and vary about +-10% for gimbals and can occasionally be as bad as +-20-50% for drone motors, but doing several measurements will usually reveal a pattern.
The electrical zero is a datum that pretty much comes out as a side-product of the d&q measurements, which is why i´ve included it. Whats very useful is that during the measurement the motor doesn´t move (or shouldn´t, at least), so the electrical zero is less dependant on low friction and pole pairs. As is, it can vary a bit, but this variance will not increase with higher pole count.
Due to there always being two possible values, we cannot easily determine the true zero, so we still need an approximate zero. That´s why this won´t replace our current zero finding method, only supplement it.
This is something we wanted for some time, but the question is whether my implementation is appropriate or a bit overkill.
I know the theory behind this code isn´t very simple, but I´ve tried to make the code somewhat understandable.
What do you think?