So right now here is the code for our climber in Telelop.vi.
Right now it’s set so that you can hold one button to make it go up and hold another button to make it go down.
We would like to change it so that you can press a button and it runs the motor in one direction for a certain amount of time (up) and press another button to make the motor run in the other direction for a certain amount of time (down).
We want to change it to a fixed time so the motor doesn’t snap the cable in the winch.
Could I use a Flat Sequence structure instead of what I have in telelop?
It’s easiest to place a timed action in Periodic Tasks.
Something like this: Team358.org - Robotic Eagles - FIRST® Robotics Competition
It can be done in Teleop with a constant time check, too.
If I did something like that in periodic tasks, do I still need to keep the code that’s already in telelop or should I delete it?
If you have a Set Output in Periodic Tasks, then never call Set Output anywhere else (Teleop, Autonomous Independent, Disabled).
The calls will fight each other.
Periodic Tasks runs at all times, Disabled, Auto, Teleop.
If you need to use this motor in Auto and in Teleop, then typically you’d use a global variable and some logic in Periodic Tasks to read that variable during Auto, and the joystick during Teleop.
What @Mark_McLeod mentioned will work, but it isn’t adviseable to run a mechanism with hardstops based on just time data. The robot will take a different amount of time to bring the arm down to lift the robot than to bring the arm down under no load. If the arm runs too long, it could damage the mechanism. You probably will want some form of limit switch to prevent the mechanism from breaking itself. You can then use these limit switches to detect if it is in the up or down position, and run the motors accordingly.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.