View Single Post
  #2   Spotlight this post!  
Unread 12-01-2007, 12:29
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Potentiometer PID

Well the POT in an analog port will return 0 - 1024.

The code should explain the rest.
You probaly want to add a statement to make sure the number going into
the victor is between 0 and 255.


Code:
{
      if ( Button1 == 1 )
      {
            Target = 200 ;
      }
      else if ( Button2 == 1 )
      {
            Target = 400 ;
      }
      else if ( Button3 == 1 )
      {
            Target = 600 ;
      }
      Arm_Out = GetAnalogInput ( 1 ) ;  //GetAnalogInput(Port) Checks the Port and Return 0-1024
      Error = (Current - 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
      SetPWM ( 1 , Drive ) ;  //  SetPWM(Port,Speed)
}
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni

Last edited by Kingofl337 : 12-01-2007 at 12:34.