PDA

View Full Version : Need help with code and connection



SARAL
08-28-2008, 11:26 PM
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%2fProd%2f2%2f288%2f28 850-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%20Manuals/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, [50, 75, 100, 200], T_VAR
DIR= IN15 ' read the direction
BRANCH DIR, [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, [$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, [50, 75, 100, 200], T_VAR
DIR= IN15 ' read the direction
BRANCH DIR, [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, [$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

Chris Savage
08-29-2008, 04:26 AM
Hello,

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

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering