Thread: PID crossing 0
View Single Post
  #12   Spotlight this post!  
Unread 26-05-2011, 16:22
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PID crossing 0

Quote:
Originally Posted by ratdude747 View Post
edit- i see now... its the lowest integer function. however the equations doesn't work. did you mean somethign else?
What do you mean by "the equations don't work" ?

Please post an example.


Here's a complete C program. Compile and run it:

Code:
#include <math.h>
#include <stdio.h>

void test(double target, double measured){
double angle_error;
printf("\n%12.3f target\n%12.3f measured\n",target,measured);
angle_error=target-measured;
angle_error -= 360*floor(0.5+angle_error/360.0);
printf("%12.3f angle_error\n\n",angle_error);
}


int main(void){
   
test(2,359);
test(354,4);

return 0;

}

Here's the output:

Code:
       2.000 target
     359.000 measured
       3.000 angle_error


     354.000 target
       4.000 measured
     -10.000 angle_error


Last edited by Ether : 26-05-2011 at 16:35.
Reply With Quote