May 10th, 2010, 11:06 PM
Console application question, controlling a stepper motor
I have a console application that controls a stepper motor. Currently, the motor is controlled by issuing a series of signals through the parallel port to move the stepper motor through its steps. Each of these steps requires a 15ms delay between each call, therefore i am utilizing Thread.Sleep to pause the main thread while i issue the commands.
I would like to give the script an abort feature. Example: "Press any key to abort this action". once the key is pressed, i need to execute a few lines of code to turn off all ports used in the parallel port so i don't burn up the motor.
Can anyone offer direction on how to implement this type of behavior? can you offer a simple "hello world" example of how to implement this thread? would it require the use of threads?
I have attempted to place the business logic used in powering the motor in its own thread, but since i have to call Thread.Sleep during it's execution, the thread quits on its own.
Thanks for any advice.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!