We’ve been having trouble trying to get a timed action working. We’ve never had much luck with this, even when following Team 358’s awesome examples . We’ve searched different threads and tried many combinations of the instructions in those threads and the code still doesn’t work.
What we want: We want our hatch mechanism to rotate from a stored position inside the robot to a deployed position outside the robot, resting/stalling against a mechanical stop at either end of its travel. When a button is pressed, we want the Hatch Motor to run at -0.7 for 2 seconds and then at -0.1 indefinitely (securely storing the mechanism). When the same button is pressed again, we want the motor to run at 0.7 for 2 seconds and then at 0.1 indefinitely (securely deploying the mechanism).
This seems like an easy thing to accomplish in periodic tasks, but no dice. Here is our current labview code:
The button press boolean is written to a global variable in teleop and read in periodic tasks. The button works fine and the boolean responds as its supposed to, but the motor only seems to be executing the first frame of the flat sequence structure. What’s also odd is that there’s an irregular delay between when the boolean changes to when the motor reverses direction.
Don’t worry about the stall condition. We’re using a bag and only going to be stalling at low outputs. The Hatch Motor while loop in periodic tasks is duplicated to show the True and False cases, only one loop exists in the real code.
Thanks in advance for any help! We really appreciate it!