Skip to content

Split Stepper Motion Controller <-> Stepper Driver #89786

@jilaypandya

Description

@jilaypandya

Is your enhancement proposal related to a problem? Please describe.

Currently Stepper API combines Motion Controller and Stepper Driver under a single api with following functions.

Current API
img

However, as one can see in the block diagram of TMC5041(Dual controller/driver for up to two 2-phase bipolar stepper motors with Integrated motion controller with SPI interface) is a controller with MotionController + Stepper Driver.

Additionally all the STEP/DIR Drivers such as the tmc2209 are just stepper drivers which has a "Software Motion Controller" integrated within them.

TMC5041 Split between motion_controller and stepper_driver

As one can see there is one motion_controller pe stepper_driver

Image

Describe the solution you'd like

Hence the cleaner approach would be to seperate "Motion Controller" from the actual "Stepper Driver" with the following API structure.
Proposed Split
controller->driver

Describe alternatives you've considered

Additional context

Further context can be understood by the following image, here TMC429 is a Stepper Motion Controller Driver, whereas TMC2660 Stepper Driver.

Stepper Motion Controller Stepper Driver Notes
TMC429 TMC2660 TMC2209 and other step/dir driver might be compatible as well
zephyr,stepper-control (workqueue/counter/ramp) TMC22xx, DRV84xx, A4979 zephyr stepper control driver is a sw driver
TMC50XX Stepper Motion Controller TMC5XXX Stepper Driver TMC5XXX Series are a combined packagage (something like TMC429 + TMC2660 packed together)
Image

DTS
There are two Approaches as how the DTS could look like

&spi1 {
        /** SPI Settings **/
	tmc50xx: tmc50xx@0 {
		compatible = "adi,tmc50xx";
		reg = <0>;
		spi-max-frequency = <DT_FREQ_M(1)>; /* Maximum SPI bus frequency */

		#address-cells = <1>;
		#size-cells = <0>;

		clock-frequency = <DT_FREQ_M(10)>; /* Internal/External Clock frequency */

		tmc_stepper_controller: tmc_stepper_controller@0 {
			compatible = "adi,tmc50xx_stepper_control";
			reg = <0>;

			/* ADI TMC ramp generator as well as current settings */
			vstart = <1000>;
			vstop = <10>;
			a1 = <10000>;
			v1 = <50000>;
			d1 = <14000>;

			tmc5xxx_stepper_custom: tmc5xxx_stepper {
				compatible = "adi,tmc5xxx_stepper_driver";
				/* common stepper controller settings */
				micro-step-res = <256>;
				/* ADI TMC stallguard settings specific to TMC50XX */
				activate-stallguard2;
			};
		};
	};
};
/ {
	gpio_stepper: gpio_stepper {
		compatible = "zephyr,gpio-stepper";
		status = "okay";
		micro-step-res = <2>;
		gpios = <&gpioa 9 GPIO_ACTIVE_HIGH>,	/* D8 */
			<&gpioc 7 GPIO_ACTIVE_HIGH>,	/* D9 */
			<&gpiob 0 GPIO_ACTIVE_HIGH>,	/* D10 */
			<&gpioa 7 GPIO_ACTIVE_HIGH>;	/* D11 */
	};
};


/ {
	stepper_control: stepper_control {
		compatible = "zephyr,stepper-control";
		status = "okay";
		stepper = <&gpio_stepper>;
		step-tick-ns = <1000000>;
	};
};

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions