Shop OBEX P1 Docs P2 Docs Learn Events
help on stepper programming — Parallax Forums

help on stepper programming

ArchiverArchiver Posts: 46,084
edited 2003-03-22 15:29 in General Discussion
Hi,
I need some help on programming a stepper to turn accordingly based
on port6. If in6(port6) equals 1, the unipolar, 4-phase, 6-lead,
stepper turns 90 degrees(17 degrees/step) clockwise; after in6 goes
back to 0, the stepper returns to starting position.
The stepper stiffens as soon as powered up, and I can feel the
resistance. But it just sits there regardless the status of in6, so
if anyone knows the problem please kindly point it out. Am I pulsing
the ULN2003 incorrectly?

'*******************************************************************
'Using ports 7-10 to pulse the stepper motor, and a ULN2003 is used*
'to drive the 17 degree/step stepper motor**************************

output 7
output 8
output 9
output 10


'********************************************************************
'I/O definition *
'********************************************************************

coils VAR outB 'output to stepper coils

'********************************************************************
'EEPROM DATA *
'********************************************************************

step1 DATA %1100
step2 DATA %0110
step3 DATA %0011
step4 DATA %1001
step5 DATA %1100

'********************************************************************
'*Initilization *
'********************************************************************


DirB = %1111 'make stepper pins outputs

gate:

Read step1, coils
pause 100
Read step2, coils
pause 100
Read step3, coils
pause 100
Read step4, coils
pause 100
Read step5, coils
pause 100


NEXT:
puase 20
If in6=1 Then NEXT
If in6=0 Then CLOSE

CLOSE: 'than if pin6 is low(no car anymore), gate
closes
Read step4, coils
pause 100
Read step3, coils
pause 100
Read step2, coils
pause 100
Read step1, coils
pause 100


goto detect


Any help is greatly appreciated.

Mick

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-03-22 15:29
    Are you using BS2? There are several errors in your list which
    prevent compiling. If this is a complete listing you are missing the
    stamp declaration, using Reserved words for labels, using undefined
    labels, and using OUTB incorrectly.

    NEXT is a reserved word - use something else.
    your last statement GOTO DETECT - detect is not defined, did you mean
    where NEXT is?
    Apparantly you have wired your stepper to pins 7,8,9,10. From then
    on you refer to OUTB which is Pins 4,5,6,7.
    If you are using the current Stamp editor you need to start your
    listing with '{$STAMP BS2} (if you are using BS2).

    I'm just wondering how you got this listing loaded into your Stamp
    since as it stands it won't compile. Also, be prepared to alter the
    sequence of wiring to your stepper several times to get it to rotate
    and not just flip back and forth.

    Good luck

    --- In basicstamps@yahoogroups.com, "nobodywantstobeasucker"
    <nobodywantstobeasucker@y...> wrote:
    > Hi,
    > I need some help on programming a stepper to turn accordingly
    based
    > on port6. If in6(port6) equals 1, the unipolar, 4-phase, 6-lead,
    > stepper turns 90 degrees(17 degrees/step) clockwise; after in6 goes
    > back to 0, the stepper returns to starting position.
    > The stepper stiffens as soon as powered up, and I can feel the
    > resistance. But it just sits there regardless the status of in6,
    so
    > if anyone knows the problem please kindly point it out. Am I
    pulsing
    > the ULN2003 incorrectly?
    >
    > '*******************************************************************
    > 'Using ports 7-10 to pulse the stepper motor, and a ULN2003 is used*
    > 'to drive the 17 degree/step stepper
    motor**************************
    >
    > output 7
    > output 8
    > output 9
    > output 10
    >
    >
    > '*******************************************************************
    *
    > 'I/O definition
    *
    > '*******************************************************************
    *
    >
    > coils VAR outB 'output to stepper coils
    >
    > '*******************************************************************
    *
    > 'EEPROM DATA
    *
    > '*******************************************************************
    *
    >
    > step1 DATA %1100
    > step2 DATA %0110
    > step3 DATA %0011
    > step4 DATA %1001
    > step5 DATA %1100
    >
    > '*******************************************************************
    *
    > '*Initilization
    *
    > '*******************************************************************
    *
    >
    >
    > DirB = %1111 'make stepper pins outputs
    >
    > gate:
    >
    > Read step1, coils
    > pause 100
    > Read step2, coils
    > pause 100
    > Read step3, coils
    > pause 100
    > Read step4, coils
    > pause 100
    > Read step5, coils
    > pause 100
    >
    >
    > NEXT:
    > puase 20
    > If in6=1 Then NEXT
    > If in6=0 Then CLOSE
    >
    > CLOSE: 'than if pin6 is low(no car anymore),
    gate
    > closes
    > Read step4, coils
    > pause 100
    > Read step3, coils
    > pause 100
    > Read step2, coils
    > pause 100
    > Read step1, coils
    > pause 100
    >
    >
    > goto detect
    >
    >
    > Any help is greatly appreciated.
    >
    > Mick
Sign In or Register to comment.