PIC18F4550 雙極步進馬達 (Bipolar Stepper Motor) CCW (Counter Clock Wise, 逆時針) 轉動程式,雙極步進馬達 CCW (Counter Clock Wise, 逆時針) 轉動程式是 RA1→RA3→RA2→RA4 (A → B → -A → -B),是為了配合雙極步進馬達電路線圈的連接。首先是 RA1 ON (電流流入 A 至 –A ) ,然後需要 RA1 OFF,跟著 RA2 ON (電流流入 B 至 -B ) ,RA2 OFF,再將 RA2 ON (電流流入 -A 至 A ) ,RA2 OFF,最後是 RA4 ON (電流流入 -B 至 B ) ,RA4 OFF,循環這個 RA ON OFF 的順序,雙極步進馬達便會逆時針轉動。
▲ Teac 雙極步進馬達 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.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 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.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 } } |
▲ Teac 雙極步進馬達CCW 開始轉動 |
▲ Teac 雙極步進馬達CCW 轉動 |
氣溫:22.0 度 @ 22:00
相對濕度:百分之84%
天氣:微雨
沒有留言:
張貼留言