maix.ext_dev.tmc2209
maix.ext_dev.tmc2209 module
You can use
maix.ext_dev.tmc2209
to access this module with MaixPy
This module is generated from MaixPy and MaixCDK
Module
No module
Enum
Variable
Function
slide_scan
def slide_scan(port: str, addr: int, baud: int, step_angle: float, micro_step: int, round_mm: float, speed_mm_s: float, dir: bool = True, use_internal_sense_resistors: bool = True, run_current_per: int = 100, hold_current_per: int = 100, conf_save_path: str = './slide_conf.bin', force_update: bool = True) -> None
Scan and initialize the slide with the given parameters
item | description |
---|---|
param | port: UART port, string type. addr: TMC2209 UART address, range 0x00~0x03, integer type. baud: UART baud rate, integer type. step_angle: Motor step angle, float type. micro_step: Motor micro step, options: 1/2/4/8/16/32/64/128/256, integer type. round_mm: Round distance in mm, float type. speed_mm_s: Speed of the slide in mm/s, float type. dir: Direction of movement, boolean type. Default is true. use_internal_sense_resistors: Enable internal sense resistors if true, disable if false, boolean type. Default is true. run_current_per: Motor run current percentage, range 0~100(%), integer type. Default is 100%. hold_current_per: Motor hold current percentage, range 0~100(%), integer type. Default is 100%. conf_save_path: Configuration save path, string type. Default is "./slide_conf.bin". force_update: Force update the configuration if true, boolean type. Default is true. |
C++ defination code:
void slide_scan(const char* port, uint8_t addr, long baud, /* Uart init param */ float step_angle, uint16_t micro_step, float round_mm, /* Motor init param */ float speed_mm_s, bool dir=true, bool use_internal_sense_resistors=true, uint8_t run_current_per=100, uint8_t hold_current_per=100, const std::string conf_save_path="./slide_conf.bin", bool force_update=true /* Driver init param */)
slide_test
def slide_test(port: str, addr: int, baud: int, step_angle: float, micro_step: int, round_mm: float, speed_mm_s: float, dir: bool = True, use_internal_sense_resistors: bool = True, run_current_per: int = 100, hold_current_per: int = 100, conf_save_path: str = './slide_conf.bin') -> None
Test the slide with the given parameters\nThis function tests the slide by moving it in the specified direction until a stall condition is detected, as defined in the configuration file.
item | description |
---|---|
param | port: UART port, string type. addr: TMC2209 UART address, range 0x00~0x03, integer type. baud: UART baud rate, integer type. step_angle: Motor step angle, float type. micro_step: Motor micro step, options: 1/2/4/8/16/32/64/128/256, integer type. round_mm: Round distance in mm, float type. speed_mm_s: Speed of the slide in mm/s, float type. dir: Direction of movement, boolean type. Default is true. use_internal_sense_resistors: Enable internal sense resistors if true, disable if false, boolean type. Default is true. run_current_per: Motor run current percentage, range 0~100(%), integer type. Default is 100%. hold_current_per: Motor hold current percentage, range 0~100(%), integer type. Default is 100%. conf_save_path: Configuration save path, string type. Default is "./slide_conf.bin". |
C++ defination code:
void slide_test(const char* port, uint8_t addr, long baud, /* Uart init param */ float step_angle, uint16_t micro_step, float round_mm, /* Motor init param */ float speed_mm_s, bool dir=true, bool use_internal_sense_resistors=true, uint8_t run_current_per=100, uint8_t hold_current_per=100, const std::string conf_save_path="./slide_conf.bin"/* Driver init param */)
Class
Slide
Slide Class
C++ defination code:
class Slide
__init__
def __init__(self, port: str, addr: int, baud: int, step_angle: float, micro_step: int, round_mm: float, speed_mm_s: float = -1, use_internal_sense_resistors: bool = True, run_current_per: int = 100, hold_current_per: int = 100, cfg_file_path: str = '') -> None
Constructor for Slide\nInitializes the Slide object with the specified parameters.
item | description |
---|---|
type | func |
param | port: UART port, string type. addr: TMC2209 UART address, range 0x00~0x03, integer type. baud: UART baud rate, integer type. step_angle: Motor step angle, float type. micro_step: Motor micro step, options: 1/2/4/8/16/32/64/128/256, integer type. round_mm: Round distance in mm, float type. speed_mm_s: Speed of the slide in mm/s, float type. Default is -1, indicating the use of a default speed factor. use_internal_sense_resistors: Enable internal sense resistors if TRUE, disable if FALSE, boolean type. Default is TRUE. run_current_per: Motor run current percentage, range 0~100(%), integer type. Default is 100%. hold_current_per: Motor hold current percentage, range 0~100(%), integer type. Default is 100%. cfg_file_path: Configuration file path, string type. Default is an empty string, indicating no configuration file. |
static | False |
C++ defination code:
Slide(const char* port, uint8_t addr, long baud, /* Uart init param */ float step_angle, uint16_t micro_step, float round_mm, /* Motor init param */ float speed_mm_s=-1, bool use_internal_sense_resistors=true, uint8_t run_current_per=100, uint8_t hold_current_per=100, std::string cfg_file_path="" /* Driver init param */)
load_conf
def load_conf(self, path: str) -> None
Load configuration from a file\nLoads the configuration settings for the slide from the specified file path.
item | description |
---|---|
type | func |
param | path: Path to the configuration file, string type. |
static | False |
C++ defination code:
void load_conf(std::string path)
move
def move(self, oft: float, speed_mm_s: int = -1, check: bool = True) -> None
Move the slide by a specified length\nMoves the slide by the specified length at the given speed. Optionally checks for stall conditions.
item | description |
---|---|
type | func |
param | oft: Length to move, float type. speed_mm_s: Speed in mm/s. Default is -1, indicating the use of the default speed set during initialization. check: Enable movement check if true, boolean type. Default is true. |
static | False |
C++ defination code:
void move(float oft, int speed_mm_s=-1, bool check=true)
reset
def reset(self, dir: bool = False, speed_mm_s: int = -1) -> None
Reset the slide position\nResets the slide position in the specified direction at the given speed.
item | description |
---|---|
type | func |
param | dir: Direction of reset, boolean type. Default is false. speed_mm_s: Speed in mm/s. Default is -1, indicating the use of the speed set during initialization. |
static | False |
C++ defination code:
void reset(bool dir=false, int speed_mm_s=-1)
stop_default_per
Get or set the stop default percentage\nRetrieves or sets the stop default percentage. If the parameter is -1, it returns the current setting.
item | description |
---|---|
type | func |
param | per: Stop default percentage, range 0~100(%), integer type. Default is -1, indicating no change. |
return | int Current stop default percentage if per is -1, otherwise the new set percentage. |
static | False |
C++ defination code:
int stop_default_per(int per=-1)
run_current_per
def run_current_per(self, per: int = -1) -> int
Get or set the run current percentage\nRetrieves or sets the run current percentage. If the parameter is -1, it returns the current setting.
item | description |
---|---|
type | func |
param | per: Run current percentage, range 0~100(%), integer type. Default is -1, indicating no change. |
return | int Current run current percentage if per is -1, otherwise the new set percentage. |
static | False |
C++ defination code:
int run_current_per(int per=-1)
hold_current_per
def hold_current_per(self, per: int = -1) -> int
Get or set the hold current percentage\nRetrieves or sets the hold current percentage. If the parameter is -1, it returns the current setting.
item | description |
---|---|
type | func |
param | per: Hold current percentage, range 0~100(%), integer type. Default is -1, indicating no change. |
return | int Current hold current percentage if per is -1, otherwise the new set percentage. |
static | False |
C++ defination code:
int hold_current_per(int per=-1)
use_internal_sense_resistors
def use_internal_sense_resistors(self, b: bool = True) -> None
Enable or disable internal sense resistors\nEnables or disables the internal sense resistors based on the provided boolean value.
item | description |
---|---|
type | func |
param | b: Boolean value to enable (true) or disable (false) internal sense resistors. Default is true. |
static | False |
C++ defination code:
void use_internal_sense_resistors(bool b=true)
ScrewSlide
ScrewSlide Class
C++ defination code:
class ScrewSlide
__init__
def __init__(self, port: str, addr: int, baud: int, step_angle: float, micro_step: int, screw_pitch: float, speed_mm_s: float = -1, use_internal_sense_resistors: bool = True, run_current_per: int = 100, hold_current_per: int = 100) -> None
Constructor for ScrewSlide
item | description |
---|---|
type | func |
param | port: UART port, string type. addr: TMC2209 UART address, range 0x00~0x03, integer type. baud: UART baud rate, integer type. step_angle: Motor step angle, float type. micro_step: Motor micro step, options: 1/2/4/8/16/32/64/128/256, integer type. screw_pitch: Screw pitch of the slide, integer type. speed_mm_s: Speed of the slide in mm/s, 10 means 10mm/s, float type. Default is -1, indicating the use of a default speed factor. use_internal_sense_resistors: Enable internal sense resistors if TRUE, disable if FALSE, boolean type. Default is TRUE. run_current_per: Motor run current percentage, range 0~100(%), integer type. Default is 100%. hold_current_per: Motor hold current percentage, range 0~100(%), integer type. Default is 100%. |
static | False |
C++ defination code:
ScrewSlide(const char* port, uint8_t addr, long baud, /* Uart init param */ float step_angle, uint16_t micro_step, float screw_pitch, /* Motor init param */ float speed_mm_s=-1, bool use_internal_sense_resistors=true, uint8_t run_current_per=100, uint8_t hold_current_per=100)
move
def move(self, oft: float, speed_mm_s: int = -1, callback: typing.Callable[[float], bool] = None) -> None
Move the slide by a specified length
item | description |
---|---|
type | func |
param | oft: Length to move, 10 means 10mm, float type. Positive values move the slide in the positive direction, negative values move it in the opposite direction. speed_mm_s: Speed in mm/s. Default is -1, indicating the use of the default speed set during initialization. callback: Callback function to be called during movement. The callback function receives the current progress percentage (0~100%) of the movement. If the callback returns true, the move operation will be terminated immediately. Default is nullptr. |
static | False |
C++ defination code:
void move(float oft, int speed_mm_s=-1, std::function<bool(float)> callback=nullptr)
reset
def reset(self, callback: typing.Callable[[], bool], dir: bool = False, speed_mm_s: int = -1) -> None
Reset the slide position
item | description |
---|---|
type | func |
param | callback: Callback function to be called during the reset loop. The reset operation will only terminate if the callback returns true. dir: Direction of reset. Default is false. speed_mm_s: Speed in mm/s. Default is -1, indicating the use of the speed set during initialization. |
static | False |
C++ defination code:
void reset(std::function<bool(void)> callback, bool dir=false, int speed_mm_s=-1)
run_current_per
def run_current_per(self, per: int = -1) -> int
Get or set the run current percentage
item | description |
---|---|
type | func |
param | per: Run current percentage, range 0~100(%). Default is -1, indicating no change and returning the current run current percentage. |
return | int Current run current percentage if per is -1, otherwise the new set percentage. |
static | False |
C++ defination code:
int run_current_per(int per=-1)
hold_current_per
def hold_current_per(self, per: int = -1) -> int
Get or set the hold current percentage
item | description |
---|---|
type | func |
param | per: Hold current percentage, range 0~100(%). Default is -1, indicating no change and returning the current hold current percentage. |
return | int Current hold current percentage if per is -1, otherwise the new set percentage. |
static | False |
C++ defination code:
int hold_current_per(int per=-1)
use_internal_sense_resistors
def use_internal_sense_resistors(self, b: bool = True) -> None
Enable or disable internal sense resistors
item | description |
---|---|
type | func |
param | b: Boolean value to enable (true) or disable (false) internal sense resistors. Default is true. |
static | False |
C++ defination code:
void use_internal_sense_resistors(bool b=true)