
30-01-2004, 00:42
|
|
Registered User
no team
|
|
Join Date: Jan 2004
Location: USA
Posts: 8
|
|
|
Re: PID control loop/Encoder question
Quote:
|
Originally Posted by SilverStar
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.
|
This answers my question completely. Thanks for clearing it up and thanks to everyone else for the responses.
|