- Notifications
You must be signed in to change notification settings - Fork 8.2k
stepper_controller: introduce api #68774
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
stepper_controller: introduce api #68774
Conversation
f109e36 to 015041f Compare b75fd14 to 33f0828 Compare 309cc90 to 0ba0283 Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this mean to reset the internal position data to zero? unclear to me from the description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to reset all the registers to some default values. These register values could be entered through DTS, for now i have kinda hardcoded most of them in tmc5041_motor_reset. Use case could also be extended to reset some internal values as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds more like a "set limits" than "calibration", different name maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, you are right the calibration function basically sets the end limits currently. probably something like detect_end_limits would be more apt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not quite following, when is this going to get called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A callback calibrate_func would have to be registered using this function. Once registered, upon calling stepper_motor_calibratethe pre-registered calibrate_funcwould be called. The approach is comparable to https://docs.zephyrproject.org/latest/hardware/peripherals/gpio.html#c.gpio_init_callback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabiobaltieri : The idea behind this function is to perform referencing actions. Every time the motor controller (say, in this case, the trinamic 5041) starts up, the position is unknown. Ideally, one would travel to both the end stops, and say, on reaching the lower end stop, set the coordinate system, by resetting the current position to 0. Since, this is very hardware dependent (cause, one could either travel to both the end stops and detect a block, or using limit switches for detecting the end-stop), this referencing routine (here called as the ´calibrate´ function) is provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I still don't understand the whole mechanics of this, reading the driver code now, tmc5041_motor_set_position can set MOTOR_POSITION_MIN and MOTOR_POSITION_MAX, then tmc5041_motor_register_calibrate_func registers a callback but that only gets called from tmc5041_motor_calibrate, and all three are API functions so they are called by application? Or maybe a motion control algorithm, anyway I don't quite see the point, seems like a very complicated way of getting back the data that the application knew in the first place, or maybe it's just a bad example and there's cases where you read back the information from the controller? but then why bother with the callback, just return the data directly from the calibrate function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these should be exposed, if the device has some device specific properties that are worth exposing beyond the API, then the driver should just implement some extra driver specific functions. There's few instances of that in the code base, check sensors for examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. That's correct, these could be moved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this information really needs to be here? I'd imagine that this is could be set in the devicetree, configured at init time and then everything else just talks in either steps or mm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a provision to set these in device tree as well. These are here in order to change microsteps during runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some position control stuff, would it make sense for this API to be used for servos as well? Just thinking that the name may be more generic and not include stepper in it? Maybe motor_control or something
drivers/stepper_motor/Kconfig Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be cool to have a "dumb" enable/position/step gpio based driver as a sample, just as a minimum example and for something we folks can play at home with :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep for sure, I'll add one for the well known ULN2003 driver from arduino kit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabiobaltieri I have added a driver for controlling stepper motor with gpios. Currently i tested it with 4 pins. One could expand this driver though in the future.
| @jilaypandya tagging as RFC since this is introducing a new API and should probably go through the whole https://docs.zephyrproject.org/latest/contribute/proposals_and_rfcs.html#rfcs dance, but let's hear more comments before bringing it to the arch wg. |
0ba0283 to f7613ac Compare b5620ab to 6bb534d Compare
fabiobaltieri left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a couple styling nitpicks from me, great work
053f958 d706862 to 053f958 Compare 053f958 to 2e6cd17 Compare This commit introduces api for stepper motor controllers Signed-off-by: Dipak Shetty <dipak.shetty@zeiss.com> Signed-off-by: Florian Guhl <florian.guhl@zeiss.com> Signed-off-by: Jilay Pandya <jilay.pandya@zeiss.com> Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
This commit introduces a basic gpio stepper driver Signed-off-by: Jilay Pandya <jilay.pandya@zeiss.com> Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
Added stepper motor controller documentation entry to peripherals. Signed-off-by: Fabian Blatz <fabianblatz@gmail.com> Signed-off-by: Jilay Pandya <jilay.pandya@zeiss.com>
This commit introduces preliminary build all test for stepper driver Signed-off-by: Jilay Pandya <jilay.pandya@zeiss.com>
This commit adds stepper api and drivers to maintainers.yml Signed-off-by: Jilay Pandya <jilay.pandya@zeiss.com>
2e6cd17 to 452dedc Compare | I am unfortunately running up against a deadline and am not going to get a review in a reasonable amount of time, so please don't wait for me! Great work everyone; this is really exciting! |
wkhadgar left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just some really minor tweaks
| compliance checks should turn green, once this PR #77517 is merged |
main concerns addressed, will let other reviews follow
This PR is the reference implementation for this RFC: #68547
This commit introduces api for stepper motor control where stepper motors are childs of a stepper motor controller
This PR is created in response to the following review.
Rather than going for the
bus:motorapproach as done in this PR, this PR goes for the child binding approach.Device Tree Looks largely the same in both approaches.
Bindings

Example trinamic,tmc5041.yaml