View Single Post
  #3   Spotlight this post!  
Unread 09-02-2014, 15:14
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Thread speed in C++

A couple suggestions - first one is to look at the PID class source code from WPIlib. They do actually spawn a Task for monitoring. The second thought is that you can write your own and your own task and if you're looking to limit the frequency with which it loops, simply use Wait() appropriately. If you'd like a Task base class, my team has a nice one called JankyTask where you can base your class on it and simply write your 'Run()' function and it will get called by the base class after a 2ms loop delay when it is running.

Testjig is at: https://github.com/bobwolff68/FRCTea...nkyTaskTestjig

And the base class itself is: https://github.com/bobwolff68/FRCTea...de/jankyTask.h and: https://github.com/bobwolff68/FRCTea.../jankyTask.cpp

Quote:
Originally Posted by ekapalka View Post
Hello! I'm writing a bunch of sample programmes to use as examples for teaching new programmers, and I'm currently working on PID. I know there's a PID class, but I would prefer to write my own as I have the capability. The PID loops I know of utilize time a lot, and tend to be a bit eccentric, so I was thinking of creating them in a separate thread (using the Task class). The thing I want to know is how fast threads execute. Is it 50Hz like the periodic methods or is it more akin to the discontinued continuous methods? Thanks!
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote