Step motor control


Results 1 to 23 of 23

Threaded View

  1. #1
    Join Date
    May 2010
    Posts
    43

    Default Step motor control

    Can someone write me code in picbasic for stepper motor control!

    I would like to control a stepper motor, for example:
    to turn through 360 degrees, and to stop, go back 180 degrees, and to stop, and so on,
    I would need a program that works fine, I have tried with some, but always the first mistake and the engine moves a step forward for some step,is not precision.
    I use pic 16f628,I forgot say that!

    I use this code,but make some mistake after few circle work,not back in same point:

    i var byte
    k var byte
    symbol brz=900 'speed



    '360 circle-----------------------------------------
    allcircle:
    pause 500
    For k = 1 to 4
    For i = 1 to 128

    PULSOUT PORTB.0,brz
    PULSOUT PORTB.1,brz
    PULSOUT PORTB.2,brz
    PULSOUT PORTB.3,brz
    next i
    next k

    pause 2500
    goto halfcircle
    '-----------------------------------------

    '180circle-----------------------------------------
    halfcircle:
    For k = 1 to 2
    For i = 1 to 128

    PULSOUT PORTB.3,brz
    PULSOUT PORTB.2,brz
    PULSOUT PORTB.1,brz
    PULSOUT PORTB.0,brz

    NEXT I
    next k

    pause 2500
    goto minushalfcircle
    '-----------------------------------------

    'minus180circle-----------------------------------------
    minushalfcircle:
    For k = 1 to 2
    For i = 1 to 128

    PULSOUT PORTB.3,brz
    PULSOUT PORTB.2,brz
    PULSOUT PORTB.1,brz
    PULSOUT PORTB.0,brz

    NEXT I
    next k

    pause 2500
    '-----------------------------------------
    GOTO allcircle
    Last edited by dragan77; - 5th September 2011 at 11:33.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts