Quote:
Originally Posted by Greg McKaskle
While it is possible to do this in TeleOp using a state machine, it is probably easier to put this code into Periodic tasks. You can directly check the joystick button there, or you can check the button in teleOp and use a global or other notification mechanism to tell the periodic loop what to do.
The buttons will either add or remove some value to a common set point, and the loop will drive the motor as appropriate to get to the set point.
|
Both Greg and Stevil99 have made good points. I just want to point out some additional options.
As far as software, it may be advisable to use a pid, have the buttons select a set point (which is "remembered" either via a shift regiser or a feedback node), and some way of measuring the location of the elevator. My team typically utilizes encoders connected to the gear box (this yields a position relative to power up), alternatively, one could use a 10turn pot (yielding an absolute position). I won't go into details on that, but I am attaching an examples of what it could look like.
To change from encoder to pot, merely swap open the open and read vi's. This version would be for use in Teleop (it is designed based on the idea of a state machine, although not a true one), to put it in Time Tasks, switch the loop constant to false so it doesn't exit.