View Single Post
  #6   Spotlight this post!  
Unread 12-01-2007, 14:46
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: Potentiometer PID

Quote:
Originally Posted by DustinB_3 View Post
Thanks for the whitepaper
I think I understand fairly well, would this work:

int Target;
int Error;
int Gain = 0.5;
int Drive;
int Arm_Out;

if ( p1_sw_trig == 1 )
{
Target = 600 ;
}
else if ( p2_sw_trig == 1 )
{
Target = 1000 ;
}
else if ( p3_sw_trig == 1 )
{
Target = 1600 ;
}
Arm_Out = Get_ADC_Result(2); //GetAnalogInput(Port) Checks the Port and Return 0-1024
Error = (Arm_Out - Target); // Computes Error Based on How Far you are from the goal
Drive = ((Gain * Error)+127); // Based on the gain it outputs a number and then add 127 so the Victor Understands
pwm01 = Drive;
The analog inputs on the RC vary from 0 to 1024.

A target of 1600 would cause the arm motor to continue to run indefinately.

[EDIT]

This depends on what line you have defined in Kevin's code.

[/EDIT]
__________________

Last edited by DanDon : 12-01-2007 at 16:02.