View Single Post
  #4   Spotlight this post!  
Unread 02-02-2014, 07:21
Jared's Avatar
Jared Jared is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Aug 2013
Rookie Year: 2012
Location: Connecticut
Posts: 602
Jared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond repute
Re: Hmm...How can I respond quicker to encoder input?

Quote:
Originally Posted by Ginto8 View Post
If you're running your loop in teleopPeriodic(), your latency will probably be closer to 20ms (that's the default period). However, making a higher-frequency loop with a TimerTask is definitely feasible. 1ms, I'm not sure of, but what I'd do is bring it down to 10ms, then 5ms, and see how the CPU usage is affected (you can check that with the DS Log Viewer). As long as you stay below ~80%, you should be fine. You could push it higher if you're certain there won't be any occasional peaks that take up that 20%.
We used a TimerTask for our shooter control last year, and decreasing the loop time definitely made the shooter more responsive. As long as what's running isn't too complicated, you should be able to get the loop time down to 5 ms.

If you wanted to go even faster, you could make a new thread and call thread.yield(), so that it runs as fast as possible, without affecting your other threads.