Running Loop in Parallel

I am working on a program that will set the angle of a shooter. The program is attached below. The program works but when active it everything else in teleop stops running until the loops finish. I know this is because it has to run the entire loop before it can continue on doing other things. After doing some research I think I need to move this vi to Periodic Tasks. Will this allow me to run this program and drive at the same time? Also can I use joystick buttons in Periodic Tasks the same way I would in Teleop?





Correct! You do not want to have any loops that might take longer then 20ms to run inside your Teleop VI.

Move that function to Periodic inside it own continuous running while loop (wire a false to the conditional terminal). Put the get joystick (Enable) inside the outer loop. Put a short delay in the false case or “Disable” state to keep it from grabbing all the CPU time.

I think you will want to put the get “Disable Limit” inside the “Move Down for 1/2 second” loop so that it is updated each time around that loop.

Post back your changes.

I updated the code.

LabVIEW Periodic Tasks Loop.PNG




LabVIEW Periodic Tasks Loop.PNG

Yes, but that’s not the only way to do it.

The other way is to use a state machine instead. Here are some threads you might find useful:

http://www.chiefdelphi.com/forums/showpost.php?p=1130036&postcount=2

http://www.chiefdelphi.com/forums/showpost.php?p=1228104&postcount=3

http://www.chiefdelphi.com/forums/showpost.php?p=1228668&postcount=4

Agree about the state machine!

But so for your code, I not sure you have it quite right.

Is the code with the two while loops “Move Down until limit switch” and “Angle” inside the “Set Angle Preset 1” subVI?

Do you expect the “Disable Limit” Boolean input to change while looping around the “Move Down until limit switch” loop? If so that will not work because “Disable Limit” will only have the value passed in when the subVI was called and not any new value from the joystick. To update from the joystick as it loops, you will need to put a Joystick Get inside the “Move Down until limit switch”

I’m not too sure just how this angle setting is to work. It seems you have a ‘home’ position (Top Angle Limit) that you move to start and then iterate around a 10+ms loop a number of times read from the Dashboard until you HOPE to be at the angle you desire.

You are correct on how the angle adjustment is going to work. It goes up until it hits the limit switch then goes down for a set amount of time. I am hoping to replace the time function with a gyro but I have been unable to get a good reading from the gyro.

I am currently not too worried about the “Disable Limit” not working but I may change it if need be but I believe it worked in its current state.

Have you looked into using a potentiometer? The gyro will drift over time and will be effected by bumps and bangs as you move around the field.

That just got brought up in this topic http://www.chiefdelphi.com/forums/showthread.php?p=1236323#post1236323 I am going to look into it.