Let's Go!
11-25-2009, 12:01 AM
I am using 2 hb25's to operate motors.·i want one motor to turn a turntable to a predefined position every time at the beginning of the overall routine. i am using a stop switch connected to pin 3 of the bs2, and upon closing, the switch should take the bs2 pin 3 active high and go to a routine to reset the beginning position of the turntable by ramping up and then down and stopping.
my active high switch works, the typical routines work, but i can't get this above described routine to work. i have tried many cominations of if...then, etc but i can't get it to go to the "reset" as seen below.
i have listed the appropriate code and i would appreciate any ideas.
·' {$STAMP BS2}
' {$PBASIC 2.5}
'simple test of cart and tt
'11-23-09
'i/o definitions
turntable···· PIN·· 13
cart··· PIN·· 15
'variables
index·· VAR·· Word
'initialization
DO: LOOP· UNTIL turntable = 1···· 'hb25-1
LOW turntable
PAUSE 5
PULSOUT turntable, 750
DO:· LOOP· UNTIL cart = 1······ 'hb25-2
LOW cart
PAUSE 5
PULSOUT cart, 750
PAUSE 5000
'program code
main:
'Turntable reset to beginning position
PAUSE 20
FOR index = 0 TO 50····· 'ramp up,do this routine until pin 3 goes high, 2" per move
PULSOUT turntable, 750 - index······· 'R to Left, reverse index, short moves
PAUSE 20
NEXT
PAUSE 20
FOR index = 50 TO 0········ 'ramp down, then make pin 3 decision below
PULSOUT turntable, 750 - index
PAUSE 20
NEXT
'i feel this next code needs work, or placed elsewhere
IF (IN3 = 1) THEN RESET···· 'after above routine, if pin 3 = active 1 then goto 'reset:mechanical pin is tied to 'turntable
GOTO main·············· 'goto main and move tt another 2" to position tt,if in3 = 0
RESET:·· 'this routine will place tt position in same start position every time
PAUSE 20
FOR index = 0 TO 150
PULSOUT turntable, 750 + index·· 'ramp up, L to R, FWD, move tt fwd to start position
PAUSE 20
NEXT
PAUSE 20
FOR index = 150 TO 0··· 'ramp down
PULSOUT turntable, 750 + index··· 'L TO R, fwd TO start position
PAUSE 20
NEXT·····
'turntable is now reset to it's beginning position
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The smarter I get, the more I understand I don't know!
my active high switch works, the typical routines work, but i can't get this above described routine to work. i have tried many cominations of if...then, etc but i can't get it to go to the "reset" as seen below.
i have listed the appropriate code and i would appreciate any ideas.
·' {$STAMP BS2}
' {$PBASIC 2.5}
'simple test of cart and tt
'11-23-09
'i/o definitions
turntable···· PIN·· 13
cart··· PIN·· 15
'variables
index·· VAR·· Word
'initialization
DO: LOOP· UNTIL turntable = 1···· 'hb25-1
LOW turntable
PAUSE 5
PULSOUT turntable, 750
DO:· LOOP· UNTIL cart = 1······ 'hb25-2
LOW cart
PAUSE 5
PULSOUT cart, 750
PAUSE 5000
'program code
main:
'Turntable reset to beginning position
PAUSE 20
FOR index = 0 TO 50····· 'ramp up,do this routine until pin 3 goes high, 2" per move
PULSOUT turntable, 750 - index······· 'R to Left, reverse index, short moves
PAUSE 20
NEXT
PAUSE 20
FOR index = 50 TO 0········ 'ramp down, then make pin 3 decision below
PULSOUT turntable, 750 - index
PAUSE 20
NEXT
'i feel this next code needs work, or placed elsewhere
IF (IN3 = 1) THEN RESET···· 'after above routine, if pin 3 = active 1 then goto 'reset:mechanical pin is tied to 'turntable
GOTO main·············· 'goto main and move tt another 2" to position tt,if in3 = 0
RESET:·· 'this routine will place tt position in same start position every time
PAUSE 20
FOR index = 0 TO 150
PULSOUT turntable, 750 + index·· 'ramp up, L to R, FWD, move tt fwd to start position
PAUSE 20
NEXT
PAUSE 20
FOR index = 150 TO 0··· 'ramp down
PULSOUT turntable, 750 + index··· 'L TO R, fwd TO start position
PAUSE 20
NEXT·····
'turntable is now reset to it's beginning position
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The smarter I get, the more I understand I don't know!