Quote:
Originally Posted by Mark McLeod
It is more efficient to combine them into one loop, but not significantly. If they are affecting Teleop at all then you need to rethink your code design.
Before doing anything I'd suggest measuring the rates of all your loops to see how they are affecting overall timing.
One or more of your loops may not be running as fast as 20ms and that would impact Teleop worst of all.
Look under Support Code" in your project and you will see Elapsed Times.vi
Drop a copy of this vi into each of your loops, and into teleop, and give them unique names so they can be told apart.
Open the front panel of Elapsed Times and run your code in debug from Robot Main. Elapsed Times will tell you how long each loop is actually taking.
Each of your loops should be taking just a few ms longer than 20ms. If you see any that are taking significantly longer than that, then you will need to slow down the loop to a more reasonable time or you will need to streamline your code more.
|
Thanks, I'll check that.
And about the code design, our code design is based on state machines where every sub system has a different state machine in periodic tasks (a loop) which get commands from other vi's about state changes (or it changes states by itself, depends on the sub system)
for example,
we have the state machine for out hammer sub system (which kicks the ball)
the states it has:
1. Hammer Ready
2. Shooting
3. Hammer Down
4. Reloading
the loop runs in the periodic waiting for a command from any other vi (in the form of a global variable).
the teleop contains all the operating code and sends the commands according to the driver's actions.
so pressing on a certaing button will send a "Kick" command and the Hammer state machine will move to shooting state, in the shooting state we have all the code that control the hammer and actually make it kick and when it finishes kicking it automatically moves to 'Hammer Down' state.
What do you think about our code design?
we found it very easy to program and debug using this method.