PIC18F4550 單極步進馬達 (Two-Phase Unipolar Stepper Motor) CCW (Counter Clock Wise, 逆時針) 轉動程式基本上同 CW程式相同,但順序則是反方向轉動,所以線圈順序由 RA1→RA4→RA2→RA3 (A → -B → -A → B),馬達便會逆時針轉動。
▲ PIC18F4550 單極步進馬達 CCW 轉動程式流程圖 |
void main(void) { TRISA = 0b00000001; // Setup PORTA RA1 - RA7 as Output while(1) { LATAbits.LATA1 = 1; // RA0=1 LED=ON Scope=1 A+ White Delay10KTCYx(240); // 10,000 x 1 x (4 x 0.05us) = 2ms // Scope = 2ms LATAbits.LATA1 = 0; // RA1=0 LED=OFF Scope=50ms LATAbits.LATA4 = 1; // RA4=1 LED=ON Scope=1 B- Yellow Delay10KTCYx(240); // 10,000 x 1 x (4 x 0.05us) = 2ms // Scope = 2ms LATAbits.LATA4 = 0; // RA4=0 LED=OFF Scope=50ms LATAbits.LATA2 = 1; // RA2=1 LED=ON Scope=1 A- Red Delay10KTCYx(240); // 10,000 x 1 x (4 x 0.05us) = 2ms // Scope = 2ms LATAbits.LATA2 = 0; // RA2=0 LED=OFF Scope=50ms LATAbits.LATA3 = 1; // RA3=1 LED=ON Scope=1 B+ Blue Delay10KTCYx(240); // 10,000 x 1 x (4 x 0.05us) = 2ms // Scope = 2ms LATAbits.LATA3 = 0; // RA3=0 LED=OFF Scope=50ms } } |
該驅動器的序列如下圖所示只是1個週期 (A → -B → -A → B)。需要重複序列,使馬達逆時針轉動不斷。
Step | 白色 (A) | 黃色 (-B) | 紅色 (-A) | 黃藍色 (B) |
1 | X | 0 | 0 | 0 |
2 | 0 | X | 0 | 0 |
3 | 0 | 0 | X | 0 |
4 | 0 | 0 | 0 | X |
▲ Teac 單極步進馬達 CCW 轉動 |
▲ PIC18F4550 步進馬達 CCW 轉動程式運作中 |
氣溫:27.3 度 @ 22:00
相對濕度:百分之84%
天氣:大致多雲
沒有留言:
張貼留言