Shop OBEX P1 Docs P2 Docs Learn Events
Stp Mtr(ULN2003) Controler BS1->BS2 — Parallax Forums

Stp Mtr(ULN2003) Controler BS1->BS2

Ian S.Ian S. Posts: 1
edited 2007-02-28 04:17 in BASIC Stamp
Hi everyone

I am trying to use BS 1 application note(p.102) to run linear step motor with
BS2 program. Can anyone help me with this conversion please.

Thanks for your attention to this matter.

Ian

question as <
indicates

'{$STAMP BS2}
'****************************************************************************************
'BS1 TO BS2 conversion errors
'****************************************************************************************

'Basic Stamp I Application notes P.102
'
'A serial Stepper Motor Controller (ULN2003)
'
'Symbol Directn=b0
'Symbol Steps=w1
'Symbol i=w2
'Symbol Delay=b6
'Symbol Dir_cmd=b7


'DIRS=%01000011 : pins=%00000001 <
What does ":" and pins=%00000001 mean?
B1=%00000001 : Directn="+"
GOTO prompt 'Display prompt

Cmd: SERIN 7,N24000,Dir_cmd,#Steps,#Delay'Get order from terminal
IF Dir_cmd=Directn THEN Stepit 'Same direction? Begin
B1=B1^%00000011 'Else reverse(invert b1)

Stepit:
FOR i=1 TO Steps 'Number of Steps
pins = pins^B1 'Xor output with b1, then invert b1
B1=B1^%00000011 'to calculate the stepping sequence
PAUSE Delay 'Wait commanded delay between steps
NEXT

Directn=Dir_cmd 'Direction=New Direction

Prompt: SEROUT 6,N24000,(10,13,"step>") 'Show prompt,send return and linefeed to terminal
GOTO Cmd




'****************************************************************************************
'This is conversion welcomes for any suggestions
'****************************************************************************************


Directn VAR Nib 'Symbol Directn=B0
Steps VAR Word 'Symbol Steps=W1
i VAR Word 'Symbol i=W2
Delay VAR Byte 'Symbol Delay=B6
Dir_cmd VAR Byte 'Symbol Dir_cmd=B7

DIRS=%0000000001000011 : HIGH0 'initialize
B1=%0000000000000001 : Directn="+"
GOTO prompt 'Display prompt

Cmd: SERIN 7,396+$4000,[noparse][[/noparse]Dir_cmd,DEC Steps,DEC Delay] 'Get order from terminal
IF Dir_cmd=Directn THEN Stepit 'Same direction? Begin
B1=B1^%0000000000000011 '<
error on "="

Stepit:
FOR i=1 TO Steps 'Number of Steps
pins = pins^B1 'Xor output with b1, then invert b1
B1=B1^%0000000000000011 '<
error on "="
PAUSE Delay 'Wait commanded delay between steps
NEXT

Directn=Dir_cmd 'Direction=New Direction

Prompt: SEROUT 6,396+$4000,[noparse][[/noparse]10,13,"step>"] 'Show prompt,send return and linefeed to terminal
GOTO Cmd
Sign In or Register to comment.