|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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?
|
|
#2
|
||||
|
||||
|
Re: Running Loop in Parallel
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. Last edited by Omar : 19-02-2013 at 09:11. |
|
#3
|
||||
|
||||
|
Re: Running Loop in Parallel
Quote:
|
|
#4
|
||||
|
||||
|
Re: Running Loop in Parallel
Quote:
The other way is to use a state machine instead. Here are some threads you might find useful: http://www.chiefdelphi.com/forums/sh...36&postcount=2 http://www.chiefdelphi.com/forums/sh...04&postcount=3 http://www.chiefdelphi.com/forums/sh...68&postcount=4 |
|
#5
|
||||
|
||||
|
Re: Running Loop in Parallel
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. |
|
#6
|
||||
|
||||
|
Re: Running Loop in Parallel
Quote:
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. |
|
#7
|
||||
|
||||
|
Re: Running Loop in Parallel
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.
|
|
#8
|
||||
|
||||
|
Re: Running Loop in Parallel
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|