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
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!
|