Do you have an oscilloscope to see the stepper optical output signal? Sometimes an optical sensor output is just an open collector photo-transistor or photo-diode needing a pull up resistor, Sometimes they do it just to allow you to hook up the sensor to different voltage level technologies. You could check it out using a simple voltmeter at the opto-switch output and rotating the motor by hand. The best way to check it out nicely would make the motor run freely and scope the opto-switch output, include pull up resistors or else, until you have a pretty clean pulse. Wagner Andy Bassam wrote: > > I have included a file which will control a stepper motor. The > stepper motor that i am using has an opto-switch so when the > motor reaches a pre defined location it sends a high signal to the > PIC, Every aspect of the program works, ie direction, run. But we > cannot get the STOPTOP working, It seems the strpper motor > output is bouncing so when STOPTOP is reached it does not give > a clear high, I want to include a number of checks in the CLOCK > subroutine to stop the motor output from bouncing,