【本文發布于https://blog.csdn.net/Stack_/article/details/132236329,未經允許不得轉載,轉載須注明出處】
雙極性步進電機(兩相四線步進電機),原理的東西就先不講太多了,還沒搞清楚,邊查資料邊寫代碼來理解吧。
此電路使用4片CMS6324去驅動2個H橋,每片CMS6324驅動的橋的同一側,其自帶硬件死區,所以不需要考慮死區插入的問題。如果不是這樣的電路,則需要注意上下橋臂同時導通短路的問題。
一、電機基本原理圖 內部簡化圖
二、簡單的驅動代碼
#define MOTOR_A_P_PORT PORT1 //P15 A+
#define MOTOR_A_P_PIN PIN5#define MOTOR_A_N_PORT PORT1 //P14 A-
#define MOTOR_A_N_PIN PIN4#define MOTOR_B_P_PORT PORT1 //P13 B+
#define MOTOR_B_P_PIN PIN3#define MOTOR_B_N_PORT PORT1 //P12 B-
#define MOTOR_B_N_PIN PIN2#define MOTOR_A_P__SET() PORT_SetBit(MOTOR_A_P_PORT, MOTOR_A_P_PIN)
#define MOTOR_A_P__RESET() PORT_ClrBit(MOTOR_A_P_PORT, MOTOR_A_P_PIN)#define MOTOR_A_N__SET() PORT_SetBit(MOTOR_A_N_PORT, MOTOR_A_N_PIN)
#define MOTOR_A_N__RESET() PORT_ClrBit(MOTOR_A_N_PORT, MOTOR_A_N_PIN)#define MOTOR_B_P__SET() PORT_SetBit(MOTOR_B_P_PORT, MOTOR_B_P_PIN)
#define MOTOR_B_P__RESET() PORT_ClrBit(MOTOR_B_P_PORT, MOTOR_B_P_PIN)#define MOTOR_B_N__SET() PORT_SetBit(MOTOR_B_N_PORT, MOTOR_B_N_PIN)
#define MOTOR_B_N__RESET() PORT_ClrBit(MOTOR_B_N_PORT, MOTOR_B_N_PIN)PORT_Init(MOTOR_A_P_PORT, MOTOR_A_P_PIN, OUTPUT); //P15 A+PORT_Init(MOTOR_A_N_PORT, MOTOR_A_N_PIN, OUTPUT); //P14 A-PORT_Init(MOTOR_B_P_PORT, MOTOR_B_P_PIN, OUTPUT); //P13 B+PORT_Init(MOTOR_B_N_PORT, MOTOR_B_N_PIN, OUTPUT); //P12 B-PORT_Init(PORT3, PIN0, OUTPUT); //P30 CMS6021 POWER_EN, 使能CMS6324供電PORT_SetBit(PORT3, PIN0);while(1){#if (0) //四拍#if (0) //四拍正轉//A+MOTOR_A_P__SET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B+MOTOR_A_P__RESET();MOTOR_B_P__SET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//A-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__SET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__SET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);#else //四拍反轉//A+MOTOR_A_P__SET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__SET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//A-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__SET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B+MOTOR_A_P__RESET();MOTOR_B_P__SET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);#endif#else //八拍#if (0) //八拍正向//A+MOTOR_A_P__SET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//A+ B+MOTOR_A_P__SET();MOTOR_B_P__SET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B+MOTOR_A_P__RESET();MOTOR_B_P__SET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B+ A-MOTOR_A_P__RESET();MOTOR_B_P__SET();MOTOR_A_N__SET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//A-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__SET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//A- B-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__SET();MOTOR_B_N__SET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__SET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B- A+MOTOR_A_P__SET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__SET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);#else //八拍反向//A+MOTOR_A_P__SET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B- A+MOTOR_A_P__SET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__SET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__RESET();MOTOR_B_N__SET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//A- B-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__SET();MOTOR_B_N__SET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//A-MOTOR_A_P__RESET();MOTOR_B_P__RESET();MOTOR_A_N__SET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B+ A-MOTOR_A_P__RESET();MOTOR_B_P__SET();MOTOR_A_N__SET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//B+MOTOR_A_P__RESET();MOTOR_B_P__SET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);//A+ B+MOTOR_A_P__SET();MOTOR_B_P__SET();MOTOR_A_N__RESET();MOTOR_B_N__RESET();UserTimer_Reset(&timer_delay);while(UserTimer_Read(&timer_delay) < TIMEOUT_1MS);#endif#endif}
黃波形為 A+ |
藍波形為 B+ |
紫波形為 A- |
綠波形為 B- |
三、抓取步進電機驅動芯片/驅動器的四線波形進行對比
以上為波形研究,待續