|
Re: Black Jaguar RS232->CAN - anyone?
Hi Guys,
I think this is the last remaining method to implement speed control (with an encoder). I will test all of this tomorrow to see if it all works (along with woodk's code). Sorry about all the posts, I've been working on this a bit today. The following code is the method to tell the Jag the number of lines of the encoder (per revolution) attached to it. If you want you can just remove the kPosition. I've written the functions for that as well by using woodk's code as a blueprint (and the manual). If one needs to set the number of turns on a potentiometer attached to a motor (position mode only), just replace LM_API_CFG_ENC_LINES with LM_API_CFG_POT_TURNS (that should work).
void SetEncoder(UINT16 encoderLines);
void CANJaguar::SetEncoder(UINT16 encoderLines)
{
UINT32 messageID;
UINT8 dataBuffer[8];
UINT8 dataSize;
switch(m_controlMode)
{
case kPercentVoltage:
//Do nothing. An encoder is not used during Voltage mode
return;
case kSpeed:
case kPosition:
messageID = LM_API_CFG_ENC_LINES | m_deviceNumber;
*((UINT16*)dataBuffer) = swap16(encoderLines);
dataSize = sizeof(UINT16);
break;
default:
return;
}
sendMessage(messageID, dataBuffer, dataSize);
}
- Bryce
__________________
The opulence of the front office decor varies inversely with the fundamental solvency of the firm.
|