Use rectifier DF02 + sn754410 H-bridge + XOR gates ;Pins DEVICE SX28, OSCHCS3, TURBO, STACKX, OPTIONX IRC_CAL IRC_FAST FREQ 50000000 'Pins StepperCoil1 var RB.0 OUTPUT StepperCoil2 var RB.1 OUTPUT StepperCoil3 var RB.2 OUTPUT StepperCoil4 var RB.3 OUTPUT FIDLEPulse var RB.5 INPUT SleepSense Var RB.6 INPUT 'Always high, unless powered down. 'Variables DutyCycle Var word StepPos var byte PULSEIN Pin 5 = Var(Y) ;range from 1 to 50 IdealStepPosition = Var(X) ;range from 1 to 250 'Main Protocol MAIN: IF SleepSense=0 THEN Pause 500 GOTO Main Poll Pin6 If Pin6 = True Call ClearCoils Else continue with "Main" Poll Y (5)Y=X Skip if not zero (snz) Bank 5 Write (X) Bank 5 Call ForwardStep (X) times Call Main ;Return to main If (Bank 5)-(X)<10 or (X)-(Bank 5)>10 Call Main else if ;nested if/then statement (Bank 5)-(X) = (x') = True ;if this is a positive number Clear Bank 5 Write (X+X') Bank 5 Call ForwardStep (X') times else (X)-(Bank 5) = (X') ;this will be positive Clean Bank 5 Write (X-X') Bank 5 Call ReverseStep (X') times Call Main ;Subroutines ForwardStep skip if not zero (snz) Bank 1 Output pin 1 (1) Write (1) Bank 1 Call HoldCoils skip if not zero (snz) Bank 2 Output pin 2 (1) Write (1) Bank 2 Call HoldCoils skip if not zero (snz) Bank 3 Output pin 3 (1) Write (1) Bank 3 Call HoldCoils skip if not zero (snz) Bank 4 Output pin 4 (1) Write (1) Bank 4 Call HoldCoils Clear Bank 1 Bank 2 Bank 3 Bank 4 Ret ReverseStep skip if not zero (snz) Bank 4 Output pin 4 (1) Write (1) Bank 4 Call HoldCoils skip if not zero (snz) Bank 3 Output pin 3 (1) Write (1) Bank 3 Call HoldCoils skip if not zero (snz) Bank 2 Output pin 2 (1) Write (1) Bank 2 Call HoldCoils skip if not zero (snz) Bank 1 Output pin 1 (1) Write (1) Bank 1 Call HoldCoils Clear Bank 1 Bank 2 Bank 3 Bank 4 Ret HoldCoils ;I want this routine to continue functioning, HIGH 1 ;until ForwardStep/ReverseStep is called on HIGH 2 ;again, or if ClearCoils is called on. HIGH 3 ;I don't know how to do that, though. HIGH 4 ret ClearCoils ;Shutdown routine LOW 1 LOW 2 LOW 3 LOW 4 Clear Bank5 ret