-
Notifications
You must be signed in to change notification settings - Fork 537
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
Feat stepper current sensing #421
Conversation
Hi @askuric Just one idea.
and this in StepperMotor:
So you don't have to check if it's a BLDC or stepper motor:
And we can keep phase currents and AB currents as members to be reused by other algorithms like sensorless or displayed in the main loop. |
Makes perfect sense! Your idea makes perfect sense and we could definitely go in this direction. The only issue that I see is that the Maybe we could create a special set of functions for steppers to avoid this if statement, something like |
getStepperFOCCurrents could return ABcurrents directly so no need for getStepperABCurrents ? |
True, but then the Let me be clear, I think that this is very edgy use-case. Most of the users will never call these functions anyway. I am just concerned a bit with the simplicity/clarity of it. If we have some functions that are available but do not return good results I am a bit uncomfortable about it. I think that your approach is great and it resolves this issue almost completely. Especially since all the current values would be available in the motor class, so no need to calculate them outside. But still if someone really wants to calculate only the Alpha/beta currents outside the motor for steppers and if they call |
I think there is some confusion. |
Do you mean |
Yeah sorry I am getting confused with all the currents :) |
So as this change would change the API a bit (with the currents being available to the end users) I'd rather include the stepper current sensing code as a minimal working example, and then we can make these optimizations later, another PR. And cover all the edge cases. Let me know what you think guys (@Candas1, @runger1101001). |
So this is the initial PR that extends the
StepperMotor
class to support the current sensingThe PR brings several changes:
StepperMotor
class is extended to support thefoc_current
torque controlCurrentSense
class is extended to support Stepper motors (and drivers)InlineCurrentSense
andLowsideCurrentSense
are extended as wellCurrentSense
class and separated for BLDC and Stepper driversFOCDriver
and theBLDCDriver
andStepperDriver
extend itI've tested the code and it seems to be working on the SimpleFOC StepShield using inline and low-side current sensing.
More testing is needed to make it more robust, but its a good start I'd say.