 |
| Experiment 5. Stepper Motor Drive |
|
|
|
|
|
|
| The Experiment 5 we will test Use PIC16F628 to Drive Stepper Motor, for Article & Types of Stepping Motors you and see links as Resources ,Tools & Related Menu below |
This Experiment use Unipolar Motors 9-24 V 7.5 Degree/Step , and use IC ULN2003 for Drive |
|
|
Figure 5.1 schematic for Experiment 5 Stepper Motor Drive |
| Assemble circuit as figure 5.1 and Download Program to PIC16F628 from Figure 5.1 VR 100k use for adjust frequency clock of PIC16F628 when run in mode ER |
|
|
 |
| Source Code For Experiment 5 |
|
|
|
|
|
|
| list p= 16 f 628 |
|
; list directive to define processor |
| #include <p 16 f 628. inc> |
|
; processor specific variable definitions |
| __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _ER_OSC_NOCLKOUT & _MCLRE_ON & _LVP_OFF |
| COUNT |
equ |
0 x 20 |
|
| DUMMY 1 |
equ |
0 x 21 |
|
| DUMMY 2 |
equ |
0 x 22 |
|
|
|
|
|
|
org |
0 x 000 |
; Reset Vetor Address |
|
bsf |
STATUS,RP 0 |
; Set RB 4- RB 7 For Drive Stepper Motor |
|
movlw |
b' 00001111 ' |
|
|
movwf |
PORTB |
|
|
bcf |
STATUS,RP 0 |
|
|
|
|
|
| Begin |
movlw |
.12 |
; Loop 12 Time For 7.5 Degree/Step |
|
|
|
; 4x12x7.5 = 360 |
|
movwf |
COUNT |
|
| Loop |
movlw |
b' 00010000 ' |
; 1 Phase Full Step |
|
movwf |
PORTB |
|
|
call |
Delay |
; Change Delay For Change Speed |
|
movlw |
b' 00100000 ' |
|
|
movwf |
PORTB |
|
|
call |
Delay |
|
|
movlw |
b' 01000000 ' |
|
|
movwf |
PORTB |
|
|
call |
Delay |
|
|
movlw |
b' 10000000 ' |
|
|
movwf |
PORTB |
|
|
call |
Delay |
|
|
decfsz |
COUNT,f |
; Check Loop = 12 Time ? |
|
goto |
Loop |
; If Not Loop Again |
|
|
|
|
|
movlw |
.12 |
; Reverse Move 12 Time |
|
movwf |
COUNT |
|
| Loop 2 |
movlw |
b' 01000000 ' |
|
|
movwf |
PORTB |
|
|
call |
Delay |
|
|
movlw |
b' 00100000 ' |
|
|
movwf |
PORTB |
|
|
call |
Delay |
|
|
movlw |
b' 00010000 ' |
|
|
movwf |
PORTB |
|
|
call |
Delay |
|
|
movlw |
b' 10000000 ' |
|
|
movwf |
PORTB |
|
|
call |
Delay |
|
|
decfsz |
COUNT,f |
; Check Loop = Time ? |
|
goto |
Loop 2 |
|
|
goto |
Begin |
; If Yes Start Again |
|
|
|
|
| Delay |
movlw |
0 x 20 |
; Delay Between Step |
|
movwf |
DUMMY 1 |
|
| Delay 1 |
clrf |
DUMMY 2 |
|
|
decfsz |
DUMMY 2 ,f |
|
|
goto |
$-1 |
|
|
decfsz |
DUMMY 1 ,f |
|
|
goto |
Delay 1 |
|
|
return |
|
|
|
|
|
|
|
END |
; end of program |
|
|
|
|
|
|
|
|
|
| |
Name List |
Quantity |
MPLAB |
- |
PIC16F628 |
1 |
4 MHz Crystal |
1 |
Push Button Switch 1 PC |
1 |
33 pF Capacitors |
2 |
4.7K Resistors |
1 |
47K Resistors |
1 |
100K Variable Resistors( VR) |
1 |
ULN2003 |
1 |
Unipolar Motors |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
| Resources ,Tools & Related |
|
|
|
|
|
|
|
|
|
|