Stepper Manager
Stepper Manager Overview
A Stepper Manager is a software or hardware module designed to control and manage the operation of stepper motors efficiently. It provides an interface for configuring motor parameters, setting movement patterns, and ensuring accurate and synchronized control for a variety of motion control applications.
Usage
The API functions have the first argument as the config structure.
To drives the motor to the given count position
To get the current position of the motor.
To adjust speed, direction, or target position during operation.
Application Interface
Function |
Description |
---|---|
rs_stepper_manager_open |
Function to open the stepper manager |
rs_stepper_manager_set_driver |
Function to sets motor driver |
rs_stepper_manager_set_count_limits |
Function to set motor count limits |
rs_stepper_manager_set_rate_limits |
Function to set motor speed rate limits |
rs_stepper_manager_get_current_count |
Gets the current position of the stepper |
rs_stepper_manager_detect_zero_pos |
Function to Perform Zero Point Detection for the stepper |
rs_stepper_manager_set_target_count |
Function to set the motor to given position |
rs_stepper_manager_process |
Stepper Motor processsing function to be called continously |
Error Code
Every API’s for the stepper manager returns some success or failure values. Please refer below section,
Stepper Manager Header Details
Documentation from the relevant header as follows:
Typedefs
-
typedef struct tag_rs_stepper_manager_config rs_stepper_manager_config_t
Structure For Stepper Motor configuration
Functions
-
rs_ret_val_t rs_stepper_manager_init(rs_stepper_manager_config_t *ptr_stepper_motor)
Configures the Stepper Motor.
This function initializes the motor as per the given configuration information
- Parameters:
ptr_stepper_motor – [in] - Pointer to stepper motor configuration
- Returns:
0
-
rs_ret_val_t rs_stepper_manager_set_count_limits(rs_stepper_manager_config_t *ptr_stepper_motor, int32_t i32_min_count, int32_t i32_max_count)
Set motor count limits.
This function sets the minimum and maximum values possible to driver the motor to
- Parameters:
ptr_stepper_motor – [in] - Pointer to stepper motor
i32_min_count – [in] - Set motor minimum value or the maximum value in reverse
i32_max_count – [in] - Set motor maximum value
- Returns:
0
-
rs_ret_val_t rs_stepper_manager_set_rate_limits(rs_stepper_manager_config_t *ptr_stepper_motor, uint32_t u32_max_pulse_rate, uint32_t u32_max_count_rate_per_sec)
Set motor speed rate limits.
This function sets the minimum and maximum rates possible to driver the motor to
- Parameters:
ptr_stepper_motor – [in] - Pointer to stepper motor
u32_max_pulse_rate – [in] - Maximum pulse rate
u32_max_count_rate_per_sec – [in] - Max Count Rate Per Second For Acceleration And Deceleration
- Returns:
0
-
rs_ret_val_t rs_stepper_manager_set_target_count(rs_stepper_manager_config_t *ptr_stepper_motor, int32_t i32_target_count)
Set the motor to given position.
This function drives the motor to the given count position
- Parameters:
ptr_stepper_motor – [in] - Pointer to stepper motor
i32_target_count – [in] - Count value to move the stepper position to
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rs_stepper_manager_set_driver(rs_stepper_manager_config_t *ptr_stepper_motor, rs_stepper_driver_config_t *ptr_stepper_driver)
Sets the motor driver.
This function assigns the stepper motor driver through which the motor has to be driven
- Parameters:
ptr_stepper_motor – [in] - Pointer to stepper motor
ptr_stepper_driver – [in] - Pointer to stepper motor driver
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rs_stepper_manager_set_state(rs_stepper_manager_config_t *ptr_stepper_motor, uint32_t u32_on)
Set the motor state.
This function starts/stops driving the stepper motor
- Parameters:
ptr_stepper_motor – [in] - Pointer to stepper motor
u32_on – [in] - Non Zero value to start and 0 to stop the motor drive
- Returns:
Zero on success or negative error code
-
void rs_stepper_manager_process(rs_stepper_manager_config_t *ptr_stepper_motor)
Stepper motor processsing function to be called continously.
This function process the stepper motor and drives in necessary direction and must be called continoulsy
- Parameters:
ptr_stepper_motor – [in] - Pointer to stepper motor
- Returns:
0 on success or error code on failure
-
int32_t rs_stepper_manager_get_current_count(rs_stepper_manager_config_t *ptr_stepper_motor)
Gets the current position of the stepper.
This function is used to get the current position of the stepper motor
- Parameters:
ptr_stepper_motor – [in] - Pointer for stepper motor configuration
- Returns:
Current stepper position
-
rs_ret_val_t rs_stepper_manager_detect_zero_pos(rs_stepper_manager_config_t *ptr_stepper_motor)
Perform Zero Point Detection for the stepper.
This function moves the stepper motor to its Zero position
- Parameters:
ptr_stepper_motor – [in] - Pointer to stepper motor
- Returns:
Zero if in zero position or negative error code
-
struct tag_rs_stepper_manager_config
- #include <rs_stepper_manager.h>
Structure For Stepper Motor configuration
Public Members
-
int32_t i32_target_count
Count to set the motor position to
-
int32_t i32_min_count
Minimum count that can be set for the motor
-
int32_t i32_max_count
Maximum count that can be set for the motor
-
uint32_t u32_max_count_per_sec
Maximum count per second that the motor can be driven
-
uint32_t u32_max_count_rate_per_sec
Maximum Acceleration Per Second accepted
-
int32_t i32_current_position
Current motor position
-
uint8_t u8_in_zero_point
Flag to indicate if the motor is in Zero Position
-
uint8_t u8_state
Operating State Of Stepper Motor
-
uint32_t u32_last_call_time_ms
Last Call Time In Milli Seconds
-
uint32_t u32_max_pulse_rate
Max Pulse For Max Speed Of The Motor. ToReview
-
int8_t s8_move_dir
Set The Motor Direction For Move Forward Or Backward
-
uint16_t u16_zpd_const_speed
Set constant speed for zero position detection
-
rs_stepper_driver_config_t *ptr_stepper_driver
Pointer to the stepper driver
-
int32_t i32_target_count