FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Help: Starving the RobotDrive loop.

Everything that I've been programmign has been basic so far, but I was trying to find a way to make a quick press of a button create a constant true current, and then the pulse of another button would make the current false. I thought I could accomplish this with a while loop and a shift register, but I don't know how to use them properly.

Here's the main section of the Tele op code. The while loop with the shift register is definately the problem. Program runs when it's not there, I get the error when it is.

Loop Error Teleop.png

Any help is appreciated!

0 Kudos
Message 1 of 4
(3,892 Views)

With LabVIEW being a data flow language, it helps to think of a While Loop as having three time regions: before, during, and after.

The terminals on the left are fed by the before.  Whatever gets placed there will be read once, with the exception of the shift register.  The terminals on the right won't be set until the last iteration of the While Loop and won't be available to the "after" until the last iteration is complete.

Keeping that in mind, the shift register will update every iteration and send its value back to the next iteration.  It will then read the same values that existed when the loop first started.  So, let's look at the two possible cases.  If it was originally greater or equal to one, the value of the shift register will be at least 1.  The two inputs will be the same values they were originally.  So they'll sum to that same value.  Let's just say they're exactly 1.  The second iteration the shift register will be 2.  The third iteration it will be 3, and so on.  At no point will that ever give you a false to the comparison to stop the loop.  The other case is where it isn't greater or equal to one.  It'll stop on the first iteration and feed out a false to the case structure.  The loop can only stop when the comparison is false so the case structure will never reach the true case.

I want to make sure I understand your desired functionality.  You have two buttons.  You want to press A and get a positive current and press B to get a negative current.  Between button presses, you want the value to remain what it was?

0 Kudos
Message 2 of 4
(2,981 Views)

Yes, and when the program starts its default is false. Thank you for the explanation.

0 Kudos
Message 3 of 4
(2,981 Views)

I was reading some articles online and found a way to make a T-flip flop (One press of a button changes the current to true when false and vice versa). Here's a picture below:

Teleoppppp.png

0 Kudos
Message 4 of 4
(2,981 Views)