Rotate a stepper motor?

Thread Starter

donnyjason

Joined Feb 6, 2011
4
Hello there,

I'm still new in programming. I need to know how to program to rotate a stepper motor. Just basic code is enough as I'm totally know nothing although I have read some notes on stepper.
I would really appreciate for your help. Thanks.
 

Thread Starter

donnyjason

Joined Feb 6, 2011
4
Hi,

I have two unipolar stepper motor. Both have 5 pins. I plan to use PIC uC later to control the motor instead of adruino because I have the uC board already.
Does it answer your question Bertus?
 

Thread Starter

donnyjason

Joined Feb 6, 2011
4
this is the program i have just written. any wrong with it? the motor suppose to rotate only clockwise but then when tested it rotate both way after reset button on uC is pressed.

LIST P=16F877A
#INCLUDE <P16F877A.INC>
__CONFIG 0X3F32

X1 EQU 0X20
X2 EQU 0X21
X3 EQU 0X22


PORTB equ 0x06
status equ 0x03

org 0x00
goto start
org 0x06

start bcf STATUS,RP0
bcf status,RP0
CLRF PORTB

BSF STATUS,RP0
BCF STATUS,RP1
movlw B'11110000' ;same as 0xF0, 0 means ouput,1 input motor output
movwf ADCON1
CLRF TRISB

BCF STATUS,RP0
BCF STATUS,RP1
CLRF PORTB


main:
movlw b'00001010'
movwf PORTB
call delay

movlw b'00001001'
movwf PORTB
call delay

movlw b'00000101'
movwf PORTB
call delay

movlw b'00000110'
movwf PORTB
call delay

goto main

delay:
MOVLW D'25'
MOVWF X3
B3 MOVLW D'25'
MOVWF X2
B2 MOVLW D'25'
MOVWF X1
B1 DECFSZ X1
GOTO B1
DECFSZ X2
GOTO B2
DECFSZ X3
GOTO B3
RETURN
END
 

beenthere

Joined Apr 20, 2004
15,819
One very important question - how have you interfaced the stepper with the microprocessor? Simply attaching wires is not going to work.
 
Top