'{$STAMP BS2} '{$PBASIC 2.0} 'example for controlling motor to run at reduced speeds 'J. Forkin, 3210 shadyway Drive, Pittsburgh, PA 15227, wa3tfs@arrl.net 'copy and modify as required, routines control motor1 only, modify for motor2 'code only works with TFS-2 interface board available at above address 'details on this and other boards on http://www.geocities.com/jimforkin2003/ '********************************************************************** 'place sensors, switches, relay contracts, etc in place of these buttons 'code is selected whenever input is pulled low 'inputs should be pulled high to +5vdc via a 1k to 4.7k resistor '*********************************************************************** strt: IF IN3 = 0 THEN clockwise1 'look for button press on in3 IF IN4 = 0 THEN clockwise2 'look for button press on in4 IF IN0 = 0 THEN clockwise 'look for button press on in0 IF IN2 = 0 THEN mtrcw1stop 'look for button press on in2 to stop GOTO strt 'look at buttons again '*********************************************************************** 'this routine runs motor1 at full speed 'once commanded, the motor will continue until told to stop clockwise: 'makes motor1 rotate clockwise LOW 14 'set t2 off HIGH 13 'set t3 off [inverse logic] HIGH 12 'set t4 on LOW 15 'set t1 on [inverse logic] RETURN '*********************************************************************** 'this routine runs motor1 at slightly reduced speed about 20% clockwise1: 'makes motor1 rotate clockwise LOW 14 'set t2 off HIGH 13 'set t3 off [inverse logic] HIGH 12 'set t4 on LOW 15 'set t1 on [inverse logic] PAUSE 20 'mtrcw1stop: 'stops motor1 from turning when in clockwise movement LOW 12 HIGH 15 PAUSE 20 'change this value to set motor speed, higher = slower RETURN '*********************************************************************** 'this routine runs motor1 at a more reduced rate about 30% clockwise2: 'makes motor1 rotate clockwise LOW 14 'set t2 off HIGH 13 'set t3 off [inverse logic] HIGH 12 'set t4 on LOW 15 'set t1 on [inverse logic] PAUSE 20 'mtrcw1stop: 'stops motor1 from turning when in clockwise movement LOW 12 HIGH 15 PAUSE 75 'change this value to set motor speed, higher = slower RETURN '*********************************************************************** 'this subroutine stops motor when it is running at full speed. mtrcw1stop: 'stops motor1 from turning when in clockwise movement LOW 12 HIGH 15 RETURN