Stepper Motor Timer Driver
Stepper Motor Timer Driver
Stepper Motor Timer Driver Overview
The primary function of the Stepper Motor Timer Driver is to ensure that the stepper motor is driven with the correct timing, ensuring smooth and precise movements. It works by generating pulses at a specified rate, which are sent to the stepper motor driver circuit. The timing of these pulses determines the speed and direction of the motor’s rotation.
Application Interface
This driver implements the stepper driver using the following
Module |
Description |
---|---|
rs_stepper_timer_driver_init |
Initializes the timer based stepper driver |
rs_stepper_timer_driver_set_timer |
To sets the timer for the driver |
rs_stepper_timer_driver_set_enable_pin |
To sets the enable pin for the driver |
rs_stepper_timer_driver_set_direction_pin |
To sets the direction pin for the driver |
rs_stepper_timer_driver_set_pulse_pin |
To sets the pulse pin for the driver |
rs_stepper_timer_driver_set_limit_pin |
To sets the limit pin for the driver |
rs_stepper_timer_driver_timer_on |
To on the timer of the driver |
rs_stepper_timer_driver_timer_callback |
To call from the timer interrupt |
rs_stepper_timer_driver_process |
To process the stepper timer driver |
Stepper Motor Timer Driver Header details
Documentation from the relevant header as follows:
Typedefs
-
typedef struct __rs_stepper_timer_driver_config rs_stepper_timer_driver_config_t
Functions
-
rs_ret_val_t rs_stepper_timer_driver_init(rs_stepper_timer_driver_config_t *ptr_smt_drv, void *ptr_sm_config)
Initializes the timer based stepper driver.
This function initializes the timer based stepper driver unit
- Parameters:
ptr_smt_drv – [in] - Pointer to timer based stepper motor driver
ptr_sm_config – [in] - Pointer to higher level stepper module
- Returns:
Zero on success or negative error code
-
rs_ret_val_t rs_stepper_timer_driver_set_timer(rs_stepper_timer_driver_config_t *ptr_smt_drv, uint8_t u8_timer_unit, uint8_t u8_timer_channel)
Sets the timer for the driver.
This function assigns the timer unit and channel for the given stepper driver
- Parameters:
ptr_smt_drv – [in] - Pointer to timer based stepper motor driver
u8_timer_unit – [in] - Timer unit corresponding to the driver
u8_timer_channel – [in] - Timer channel corresponding to the driver
- Returns:
Zero on success or negative error code
-
rs_ret_val_t rs_stepper_timer_driver_set_enable_pin(rs_stepper_timer_driver_config_t *ptr_smt_drv, uint8_t u8_port, uint32_t u32_pin)
-
rs_ret_val_t rs_stepper_timer_driver_set_direction_pin(rs_stepper_timer_driver_config_t *ptr_smt_drv, uint8_t u8_port, uint32_t u32_pin)
-
rs_ret_val_t rs_stepper_timer_driver_set_pulse_pin(rs_stepper_timer_driver_config_t *ptr_smt_drv, uint8_t u8_port, uint32_t u32_pin)
-
rs_ret_val_t rs_stepper_timer_driver_set_limit_pin(rs_stepper_timer_driver_config_t *ptr_smt_drv, uint8_t u8_port, uint32_t u32_pin, uint8_t u8_active_state)
-
struct __rs_stepper_timer_driver_config
Public Members
-
rs_stepper_driver_config_t driver_config
Generic Stepper Motor Driver configuration
-
uint8_t port_direction
Set Direction Ports
-
uint32_t pin_direction
Set Direction pin
-
uint8_t port_enable
Set Enable Ports
-
uint32_t pin_enable
Set Enable pin
-
uint8_t port_pulse
Set Pulse Ports
-
uint32_t pin_pulse
Set Pulse pin
-
uint8_t port_limit
Set limit Ports
-
uint32_t pin_limit
Set limit_pin
-
uint8_t active_state_limit
Active state when in limits
-
uint8_t timer_unit
Timer unit to use
-
uint8_t timer_channel
Timer channel to use
-
uint64_t u64_holding_time
Z Motor Press & Hold the Panel key
-
uint32_t new_step_delay
Holds next delay period
-
int32_t last_accel_delay
Remember the last step delay used when decel_raterating.
-
int64_t step_count
Counting steps when moving.
-
int32_t rest
Keep track of remainder from new_step-delay calculation to incrase accurancy
-
uint32_t timer_freq
Set timer frequency
-
uint8_t run_state
What part of the speed ramp we are in.
-
uint8_t dir
Direction stepper motor should move.
-
uint32_t step_delay
Peroid of next timer delay. At start this value set the accelration rate.
-
uint32_t decel_start
What step_pos to start decelaration
-
int32_t decel_val
Sets deceleration rate.
-
int32_t min_delay
Minimum time delay (max speed)
-
int32_t accel_count
Counter used when accelerateing/decelerateing to calculate step_delay.
-
uint8_t timer_gpio_state
set timer gpio state
-
float alpha
motor step angle
-
uint64_t alpha_timer_freq_x100
Find the max speed
-
int32_t timer_freq_100
find the acceleration
-
uint64_t alpha_sq
use to find the acceleration
-
int32_t alpha_X20000
find max speed limit
-
uint16_t spr
Number of steps per round on stepper motor in use
-
rs_handle_t timer_handle
-
rs_timer_config_t timer_unit_config
-
rs_timer_channel_config_t timer_channel_config
-
rs_stepper_driver_config_t driver_config