Log in

View Full Version : Running Motor for X Milliseconds


DWirth
09-02-2010, 23:17
Hello,
I'm working on programming our kicker which our team would like to wind up at certain tensions. To do this, I want to have the CIM motor to run for a certain amount of milliseconds if one button is pressed on the joystick. It would be nice if I could use a couple different buttons for different times. Then use a limit switch to tell the motor so stop all the way back no matter what time I select. However, I am not sure how to make the motor set speed vi to run continuously for a set amount of time. Does anyone have any ideas on how I can achieve that? Thanks for your help.
Dillon Wirth

Ziaholic
09-02-2010, 23:51
I just posted a reply in a different thread that almost applies to your situation.

It's not exactly what you're looking for, but it involves writing code that runs in TeleOp, but takes longer than the 20msec main-loop time. It involves using shift registers to provide feedback from loop-to-loop in your teleop routines.

Here's a link (http://www.chiefdelphi.com/forums/showpost.php?p=916862&postcount=11) to that thread.

Alan Anderson
10-02-2010, 07:54
It sounds like what you want is in three parts. First, start a motor running forward when a button is pressed. Second, stop the motor a certain amount of time after the motor is started. Third, if the motor isn't running forward, run it backward until a limit switch activates. Is that right?

You'll need a "rising edge detector" to find the start of the button press. Then you'll want something that runs the motor until a certain time has elapsed. The attached code fragment shows a way to do that.

I'll leave it up to you to figure out how to make the motor run the other way only when it's not being told to run forward and the limit switch is not active.