Shop OBEX P1 Docs P2 Docs Learn Events
Need help with code and connection — Parallax Forums

Need help with code and connection

SARALSARAL Posts: 8
edited 2008-08-28 20:26 in BASIC Stamp
I wrote this code to run a BS2P microcontroller (on BOE) running a driver and a stepper motor. The motor (PR 266-02A) and the driver (CSD 2120-T) are custom configured from Oriental Motors. My question is I have called for I/O pins 12, 13 and 15 in my code but I was told that stepper motor requires inputs in pulses. Now, do I have to give a separate command invoking pulse in the program? If so how to do that? You can see the breadboard config and the function ports (such as power, timing, Direction, Pulse controls) in the links provided below.


Breadboard: http://www.parallax.com/desktopmodules/catalookstore/ImageViewer.aspx?link=Images/Prod/2/288/28850-L.jpg&desc=Board+of+Education+Development+Board+(USB)&PortalID=0&viewerid=-1&mid=-1
Function ports on the driver: http://www.sal.wisc.edu/pfis/docs/archive/public/Product Manuals/orientalmotors/CSD2120-TU.pdf

Here's the program:

' {$STAMP BS2}
' {$PBASIC 2.0}
REVS VAR Byte
STEPS VAR Word
SPEED VAR Byte
T_VAR VAR Byte
DIR VAR Byte
INDEX VAR Byte
PATT VAR Byte
I VAR Byte
J VAR Byte

T_INT CON 5000
DIRA=$F ' low four bits are outputs

TOP:
REVS = 2 ' revolutions
STEPS = REVS * 200 ' number of steps
SPEED=(IND & %0011) ' S13 and S12
LOOKUP SPEED, [noparse][[/noparse]50, 75, 100, 200], T_VAR
DIR= IN15 ' read the direction
BRANCH DIR, [noparse][[/noparse]ONE_W_H]

ONE_W_H:
PAUSE T_INT
FOR I = 0 TO 5
I= I+1
ONE_H:
FOR INDEX=0 TO 7
LOOKUP INDEX, [noparse][[/noparse]$1, $3, $2, $6, $4, $C, $8, $9], PATT
OUTA = PATT
PAUSE T_VAR
STEPS=STEPS-1 ' decrement number of steps left
IF (STEPS=0) THEN ONE_H
IF (I=6) THEN TURN
NEXT
GOTO ONE_H

TURN:
REVS = 2 ' revolutions
STEPS = REVS * 200 ' number of steps
SPEED=(IND & %0011) ' S13 and S12
LOOKUP SPEED, [noparse][[/noparse]50, 75, 100, 200], T_VAR
DIR= IN15 ' read the direction
BRANCH DIR, [noparse][[/noparse]OTHER_W_H]

OTHER_W_H:
PAUSE T_INT
FOR J = 0 TO 5
J = J+1
OTHER_H:
FOR INDEX=7 TO 0
LOOKUP INDEX, [noparse][[/noparse]$1, $3, $2, $6, $4, $C, $8, $9], PATT
OUTA = PATT
PAUSE T_VAR
STEPS = STEPS - 1 ' decrement number of steps left
IF (STEPS = 0) THEN OTHER_H
IF (J = 6) THEN DONE
NEXT
GOTO OTHER_W_H

DONE:
DEBUG "DONE"
OUTA = 0 ' turn off all windings
DONE_1: GOTO DONE_1


I appreciate your time

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-08-28 20:26
    Hello,

    Your duplicate post in the Stamps in Class forum was removed. Cross posting is not allowed on our forums.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
Sign In or Register to comment.