I’m trying to make a button press open and close a motor. Should I make a SubVI to handle the flat sequence structure, move the flat sequence structure to Periodic Tasks, or use some other method to do this? I figured I’d ask here since I’m done wasting time on something that should be a simple task (thanks LabView :P).
Best describe the steps you want to take, e.g., what’s the sequence you want to have happen when that button is pressed.
Periodic Tasks is usually for sequences, because they often require delays-like push a button, run a motor for 5 seconds, then stop.
You can’t have any Delay in Teleop.
-Push a button
-Run motor for x ms (TBD)
-Hold motor for x ms and until button is released
-Run motor until a limit switch is activated
Here’s a similar example that runs in Periodic Tasks: Team358.org - Robotic Eagles - FIRST® Robotics Competition
The tie-in of waiting on a button release for the 3rd action step would require another While Loop inside the 3rd sequence frame that keeps checking for button=False, before completing.
Something like this, where it waits 1000ms and for button 2 to be False (either one finishes first it waits for the other to complete):
What do you mean by “hold motor”
Doesn’t that block all other execution in PeriodicTasks until the Sequence completes? I mean, yay not killing teleop, but that doesn’t seem like that much better of an option since you can only do one of these things at a time.
No, it doesn’t block any other loops or code in Periodic Tasks.
Everything in LabVIEW is executed in parallel unless explicitly tied together.
You could make a dozen copies of this same code and they’d all be running independently.
This is exactly what Periodic Tasks is for.
I hope that you were able to follow Mark’s example code and get it working. If not, please ask a more specific question, perhaps showing your code and/or including what you tried, how it failed to work, etc.
I’m also curious to understand what you expected the flat sequence to do versus what you discovered it to do?
Greg McKaskle
I just didn’t expect the flat sequence structure to kill Teleop
In the example given above (http://www.team358.org/files/programming/ControlSystem2015-2019/labview/index.php#ButtonStartofTimedAction), what is the point of the Feedback Node? I have no clue what that does, and it seems unnecessary.
Can’t you click on the node (in LabVIEW of course) and get pop-up help which explains what it does?
I have before, but I still haven’t figured out how that would be useful in that particular situation. Which is where I don’t understand its use. The program I made works fine for ours, with the caveat that hitting A at any time the robot isn’t enabled requires the limit switch also be hit again to “reset” the cycle by ending the frame diagram. This is likely a non-issue, as the limit switch will always be pressed when our motor-driven gate is closed, although if anybody has some way to avoid this (not activating when not in Teleop, maybe?) we’ll take it.
The feedback node in that use prevents the sequence from running again immediately if the driver continues to hold down the button.
The button must be released and pressed again after the sequence ends to get the sequence to run a second (or nth) time.
It’s particularly useful with short sequences or forgetful drivers.
You can add in a Disabled check as well to prevent the sequence from being pre-triggered.
I just didn’t expect the flat sequence structure to kill Teleop
That was what I thought. It really isn’t the flat sequence, but what is in it.
The tele function is effectively a callback. It is called eery 20 milliseconds/fifty times per second. Your teleOp code therefore needs to respond to the joystick inputs and finish in about 20ms or it will be too busy to process the next one. The events aren’t queued or you would have the robot running delayed joystick info - acting laggy and generally very difficult to control.
So if you put code into tele that doesn’t return, that doesn’t work very well. If it takes seconds to return, then tele is delayed for that time. It is the code inside the sequence that delays, not the sequence itself.
The sequence simply runs one frame after the other. When if finishes, the other code downstream runs. When tele is finished, it waits for the next joystick input.
Greg McKaskle