View Single Post
  #4   Spotlight this post!  
Unread 14-11-2013, 02:05
TravSatEE's Avatar
TravSatEE TravSatEE is offline
Spacecraft Engineer and more
FRC #2035 (Robo Rockin' Bots)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Monterey, CA
Posts: 26
TravSatEE is infamous around these partsTravSatEE is infamous around these parts
Re: Running pid loops in a separate thread.

Quote:
Originally Posted by Hypnotoad View Post
I was wondering if anyone ran their pid loops separately from the main code in a different thread so as to get a higher refresh frequency.
The WPILIB implementation for java already uses threads for each PID controller. (See PIDCommand). However, the threads still have to lock internally with the Squawk JVM, so that field communication can occur. I don't know that you can improve your sampling rate. Can you clarify why you think you need a higher sampling/control rate? Are you having a stability issue? Your parameter tuning likely needs to be adjusted, but no change to sampling rate should be necessary.

Quote:
Originally Posted by Hypnotoad View Post
I fact, is multithreading even possible on the crio? I know that you can run separate loops in labview but I have read that the context switches eat the CPU. Is it possible in java?
The cRIO has a PowerPC processor and does run a real time operating system. So threads do exist for this configuration. Context switching is too low level to consider for FRC robotics -- the overhead is insignificant. This is not the cause of your issues with the PID controller.
__________________
I have a doctoral degree in electrical engineering. My FIRST mentoring philosophy is to encourage student-led activities and create a level playing field among all teams. I believe this approach results in an exciting game, rather than emphasis on a handful of dominant teams.

FIRST FRC Teams that I have mentored: 612, 342, 2035, and 5104. FIRST FRC Teams that I have helped through build seasons: 4171, 4255, and 5171.
Reply With Quote