Rotate a stepper motor?

Discussion in 'Embedded Systems and Microcontrollers' started by donnyjason, Feb 8, 2011.

  1. donnyjason

    Thread Starter New Member

    Feb 6, 2011
    4
    0
    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.
     
  2. bertus

    Administrator

    Apr 5, 2008
    15,647
    2,346
  3. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
  4. donnyjason

    Thread Starter New Member

    Feb 6, 2011
    4
    0
    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?
     
  5. be80be

    Senior Member

    Jul 5, 2008
    431
    57
  6. donnyjason

    Thread Starter New Member

    Feb 6, 2011
    4
    0
    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
     
  7. beenthere

    Retired Moderator

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

    Thread Starter New Member

    Feb 6, 2011
    4
    0
    I connected the motor to the L293D (motor driver) then to the uC board at portb (pb0-pb3). any idea?
     
  9. russ_hensel

    Well-Known Member

    Jan 11, 2009
    818
    47
    Why not try boostc instead of asm. Free version should do fine.
    Easy to move back and forth to an Arduino and other processors.
    Many like asm, but many think they are nuts: see http://www.eevblog.com/tag/arduino/
    about 13 minutes in.
     
Loading...