View Single Post
  #2   Spotlight this post!  
Unread 21-01-2010, 16:51
mattbutts mattbutts is offline
Registered User
FRC #1741 (Red Alert)
Team Role: Mentor
 
Join Date: Oct 2009
Rookie Year: 2009
Location: Greenwood, IN
Posts: 4
mattbutts is an unknown quantity at this point
Re: Black Jaguar RS232->CAN - anyone?

Quote:
Originally Posted by woodk View Post
...
I also added a method to set the PID constants:

/**
* Set the Jaguar PID constants.
*
* The inputs are any floating point values
*
* @param outputValue The P I and D constants for the motor control.
*/
void CANJaguar::SetPIDConstants(float kp, float ki, float kd)
{
UINT32 messageID;
UINT8 dataBuffer[8];
UINT8 dataSize;

// Send Kp:
switch(m_controlMode)
{
case kCurrent:
messageID = LM_API_ICTRL_PC | m_deviceNumber;
break;
case kSpeed:
messageID = LM_API_SPD_PC | m_deviceNumber;
break;
default:
;
}
INT32 value = (INT32)(kp*65536.0);
*((INT32*)dataBuffer) = swap32(value);
dataSize = sizeof(INT32);
sendMessage(messageID, dataBuffer, dataSize);

// Send Ki:
switch(m_controlMode)
{
case kCurrent:
messageID = LM_API_ICTRL_IC | m_deviceNumber;
break;
case kSpeed:
messageID = LM_API_SPD_IC | m_deviceNumber;
break;
default:
;
}
value = (INT32)(ki*65536.0);
*((INT32*)dataBuffer) = swap32(value);
dataSize = sizeof(INT32);
sendMessage(messageID, dataBuffer, dataSize);

// Send Kd:
switch(m_controlMode)
{
case kCurrent:
messageID = LM_API_ICTRL_DC | m_deviceNumber;
break;
case kSpeed:
messageID = LM_API_SPD_DC | m_deviceNumber;
break;
default:
;
}
value = (INT32)(kd*65536.0);
*((INT32*)dataBuffer) = swap32(value);
dataSize = sizeof(INT32);
sendMessage(messageID, dataBuffer, dataSize);

}
...
This is what I needed! Thanks!

I am assuming this will show up in the source code soon, but we are starting to test it now so I wanted to get something going.

Thanks again,
Matt
Reply With Quote