View Single Post
  #2   Spotlight this post!  
Unread 19-02-2013, 05:06
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Tips, Tricks, and Tactics for Programming

Nicely done.

To address the debugging topic:

If you want to know how often a piece of code is running, there is a folder in the Robot project called Support Code, and it contains a VI called Elapsed Times. If you place that in your teleop or in a loop or other code that is run repeatedly, this VI will note how often it was called from various locations. You may want to pass in a better call name if you are calling it more than once from a VI.

When your app is running, you can open the panel to Elapsed Times and it will show the times between calls. This is not going to fix anything, but may help you understand which things are lagging and by how much.

Sometimes the code is always late, but other times it coincides with some logic like toggling a joystick button. If you follow the logic, you'll often find a wait statement. Delays in teleop cause the robot to ignore joystick input. The safety VIs will tell you about this and cut the motors. They can be disabled, but the ignored joystick will remain. Code sequences that take more than 20 or 40ms should be moved out of teleop. Replace the code with a trigger and put the response code into Periodic tasks.

Greg McKaskle
Reply With Quote