Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Stepper Motion Controller Interface

Interfaces for stepper motion controllers. More...

Files

file  stepper_ctrl.h
 Main header file for stepper motion controller driver API.

Enumerations

enum  stepper_ctrl_direction { STEPPER_CTRL_DIRECTION_NEGATIVE = 0 , STEPPER_CTRL_DIRECTION_POSITIVE = 1 }
 Stepper Motion Controller direction options. More...
enum  stepper_ctrl_run_mode { STEPPER_CTRL_RUN_MODE_HOLD = 0 , STEPPER_CTRL_RUN_MODE_POSITION = 1 , STEPPER_CTRL_RUN_MODE_VELOCITY = 2 }
 Stepper Motion Controller run mode options. More...
enum  stepper_ctrl_event { STEPPER_CTRL_EVENT_STEPS_COMPLETED = 0 , STEPPER_CTRL_EVENT_LEFT_END_STOP_DETECTED = 1 , STEPPER_CTRL_EVENT_RIGHT_END_STOP_DETECTED = 2 , STEPPER_CTRL_EVENT_STOPPED = 3 }
 Stepper Motion Controller Events. More...

Functions

int stepper_ctrl_set_reference_position (const struct device *dev, const int32_t value)
 Set the reference position.
int stepper_ctrl_get_actual_position (const struct device *dev, int32_t *value)
 Get the actual step count.
int stepper_ctrl_set_event_cb (const struct device *dev, stepper_ctrl_event_callback_t callback, void *user_data)
 Set the callback function to be called when a stepper motion controller event occurs.
int stepper_ctrl_set_microstep_interval (const struct device *dev, const uint64_t microstep_interval_ns)
 Set the time interval between steps in nanoseconds with immediate effect.
int stepper_ctrl_move_by (const struct device *dev, const int32_t micro_steps)
 Set the micro-steps to be moved from the current position i.e.
int stepper_ctrl_move_to (const struct device *dev, const int32_t micro_steps)
 Set the absolute target position of the stepper.
int stepper_ctrl_run (const struct device *dev, const enum stepper_ctrl_direction direction)
 Run the stepper with a given step interval in a given direction.
int stepper_ctrl_stop (const struct device *dev)
 Stop the stepper.
int stepper_ctrl_is_moving (const struct device *dev, bool *is_moving)
 Check if the stepper is currently moving.

Detailed Description

Interfaces for stepper motion controllers.

Since
4.0
Version
0.9.0

Enumeration Type Documentation

◆ stepper_ctrl_direction

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Stepper Motion Controller direction options.

Enumerator
STEPPER_CTRL_DIRECTION_NEGATIVE 

Negative direction.

STEPPER_CTRL_DIRECTION_POSITIVE 

Positive direction.

◆ stepper_ctrl_event

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Stepper Motion Controller Events.

Enumerator
STEPPER_CTRL_EVENT_STEPS_COMPLETED 

Steps set using move_by or move_to have been executed.

STEPPER_CTRL_EVENT_LEFT_END_STOP_DETECTED 

Left end switch status changes to pressed.

STEPPER_CTRL_EVENT_RIGHT_END_STOP_DETECTED 

Right end switch status changes to pressed.

STEPPER_CTRL_EVENT_STOPPED 

Stepper has stopped.

◆ stepper_ctrl_run_mode

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Stepper Motion Controller run mode options.

Enumerator
STEPPER_CTRL_RUN_MODE_HOLD 

Hold Mode.

STEPPER_CTRL_RUN_MODE_POSITION 

Position Mode.

STEPPER_CTRL_RUN_MODE_VELOCITY 

Velocity Mode.

Function Documentation

◆ stepper_ctrl_get_actual_position()

int stepper_ctrl_get_actual_position ( const struct device * dev,
int32_t * value )

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Get the actual step count.

Note
This function does not guarantee that the returned position is the exact current position. For precise positioning, encoders should be used in addition to the stepper motion controller.
Parameters
devpointer to the device structure for the driver instance.
valueThe actual position to get in micro-steps
Return values
-EIOGeneral input / output error
-ENOSYSIf not implemented by device driver
0Success

◆ stepper_ctrl_is_moving()

int stepper_ctrl_is_moving ( const struct device * dev,
bool * is_moving )

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Check if the stepper is currently moving.

Parameters
devpointer to the device structure for the driver instance.
is_movingPointer to a boolean to store the moving status of the stepper
Return values
-EIOGeneral input / output error
-ENOSYSIf not implemented by device driver
0Success

◆ stepper_ctrl_move_by()

int stepper_ctrl_move_by ( const struct device * dev,
const int32_t micro_steps )

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Set the micro-steps to be moved from the current position i.e.

relative movement

Note
The stepper will move by the given number of micro-steps from the current position. This function is non-blocking.
Parameters
devpointer to the device structure for the driver instance.
micro_stepstarget micro-steps to be moved from the current position
Return values
-EIOGeneral input / output error
-EINVALIf the timing for steps is incorrectly configured
0Success

◆ stepper_ctrl_move_to()

int stepper_ctrl_move_to ( const struct device * dev,
const int32_t micro_steps )

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Set the absolute target position of the stepper.

Note
The stepper will move to the given micro-steps position from the reference position. This function is non-blocking.
Parameters
devpointer to the device structure for the driver instance.
micro_stepstarget position to set in micro-steps
Return values
-EIOGeneral input / output error
-EINVALIf the timing for steps is incorrectly configured
0Success

◆ stepper_ctrl_run()

int stepper_ctrl_run ( const struct device * dev,
const enum stepper_ctrl_direction direction )

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Run the stepper with a given step interval in a given direction.

Note
The stepper shall be set into motion and run continuously until stalled or stopped using some other command, for instance, stepper_stop(). This function is non-blocking.
Parameters
devpointer to the device structure for the driver instance.
directionThe direction to set
Return values
-EIOGeneral input / output error
-EINVALIf the timing for steps is incorrectly configured
-ENOSYSIf not implemented by device driver
0Success

◆ stepper_ctrl_set_event_cb()

int stepper_ctrl_set_event_cb ( const struct device * dev,
stepper_ctrl_event_callback_t callback,
void * user_data )

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Set the callback function to be called when a stepper motion controller event occurs.

Parameters
devpointer to the device structure for the driver instance.
callbackCallback function to be called when a stepper motion controller event occurs passing NULL will disable the callback
user_dataUser data to be passed to the callback function
Return values
-ENOSYSIf not implemented by device driver
0Success

◆ stepper_ctrl_set_microstep_interval()

int stepper_ctrl_set_microstep_interval ( const struct device * dev,
const uint64_t microstep_interval_ns )

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Set the time interval between steps in nanoseconds with immediate effect.

Note
Setting step interval does not set the stepper into motion, a combination of set_microstep_interval and move is required to set the stepper into motion.
Parameters
devpointer to the device structure for the driver instance.
microstep_interval_nstime interval between steps in nanoseconds
Return values
-EIOGeneral input / output error
-EINVALIf the requested step interval is not supported
-ENOSYSIf not implemented by device driver
0Success

◆ stepper_ctrl_set_reference_position()

int stepper_ctrl_set_reference_position ( const struct device * dev,
const int32_t value )

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Set the reference position.

Parameters
devpointer to the device structure for the driver instance.
valueThe reference position to set in micro-steps.
Return values
-EIOGeneral input / output error
-ENOSYSIf not implemented by device driver
0Success

◆ stepper_ctrl_stop()

int stepper_ctrl_stop ( const struct device * dev)

#include <zephyr/drivers/stepper/stepper_ctrl.h>

Stop the stepper.

Note
Cancel all active movements.
Parameters
devpointer to the device structure for the driver instance.
Return values
-EIOGeneral input / output error
-ENOSYSIf not implemented by device driver
0Success