View Single Post
  #2   Spotlight this post!  
Unread 28-01-2004, 18:12
Guest
 
Posts: n/a
Re: PID control loop/Encoder question

If you use my code at the repository that you mentioned above, all that you have to do is call this function from your Default_Routine(). As in:
Code:
/* set actualLeft and actualRight to values from two encoders */
/* all other default routine code here */
pwm01=PID(left,actualLeft,&actualLeftLast,&sumLeft);
pwm02=PID(right,actualRight,&actualRightLast,&sumRight);
Then, place this in the global vars section:
Code:
int left=127, right=127;
int actualLeft,actualRight;
int actualRightLast=127,actualLeftLast=127;
int sumLeft=0,sumRight=0;
All code above assumes that left motors are pwm01, and right are pwm02.

I'm in the middle of writing an "Advanced Programming Guide" and when I'm done it'll be at the NRG website (see my sig), under "Resources." I'll be sure to include details about PID and encoders.