View Single Post
  #4   Spotlight this post!  
Unread 26-02-2012, 23:50
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
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
Reply With Quote