|
Re: PID In-Range Ideas
You combine a check of error with a timer.
The psudocode would be:
Code:
int timer = 0; //Make sure you use a signed type to prevent underflow
int delta_t = time_now - time_last; //delta_t is millisecond loop time - in LabVIEW it would be a Tick Count block and a shift register/feedback node to store the last time
if(abs(error) < threshold) timer += delta_t;
else timer -= delta_t;
if(timer <= 0) timer = 0;
if(timer >= threshold) fire();
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor
"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
|