How do you use timer properly?

There is a peg on our robot that I would like to actuate by pressing a button. I would like to press button X and have the peg lower at X speed for X time, then travel the opposite direction to it’s starting configuration.

Here’s a pretty picture of our robot on our team blog: http://frc1529.wordpress.com/

http://img703.imageshack.us/img703/7541/liftpegrotate.th.png](http://img703.imageshack.us/i/liftpegrotate.png/)

Should this code work? cRIO went to the Techyard in the sky over the weekend. our new one ships in 2 weeks!! I need to get as much programming as I can without a bot to test with. =

the easiest way is to use a flat or stacked sequence structure with two frames. The first frame with the set speed at x power and a delay set to x milliseconds then the next frame with the return by doing the same thing in reverse

I don’t think it will work. It seems like it’s properly written to do what you want, but what you want is not compatible with the robot communication framework. Any delays like that in your Teleop code will prevent everything else from running and cause the safety watchpuppies to shut down all the robot outputs.

What you should do is learn how to implement a state machine. Your needs call for a case block with three cases: Idle, Lowering, and Raising. You will need to use shift registers or feedback nodes to hold the current state and remember an event time. In the Idle state, keep the motor off and use the button to change the state to Lowering. In the Lowering state, run the motor down and use a simple comparison to detect when X time has elapsed and change the state to Raising. In the Raising state, run the motor up and use a simple comparison to detect when X time has elapsed and change the state back to Idle.

Does this sound like something you can work with? If not, we can probably point you to a solid tutorial on state machines in LabVIEW. I’d rather not just give you working code until you’ve tried to understand the concepts on your own.

Thanks for pointing me to state machines. I’ve found a video tutorial from lvmastery.com on the subject. I’ll post back with my results.

Just as a thought…
In your code, why didn’t you make the nested case structure hold .25 for true and -.25 for false and hook that up to set motor?

I’ve watched this video all the way through once and I understand how it works except how/where to paste the info from the DIO’s to the main robot typedef. After watching the video I think I may want to put limit switches onto the manipulator. one is pressed at the top, when in idle state, and one at the bottom, to end the lowering state.
The video tutorial is from 2009 and the code is a little different in the main.vi.
Sorry if i didn’t explain too well the question i’m having, it’s ~7:45 into the tutorial. http://www.lvmastery.com/TipJar2009-02-08_1

You don’t have to use the typedef if you don’t understand it. You can just get the DIO values and use them directly.