Go to Post Strategy is rarely static, and how you design your robot isn't always the best way to win the game. - Bill Moore [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #8   Spotlight this post!  
Unread 21-01-2010, 09:45
woodk woodk is offline
Registered User
FRC #2809
 
Join Date: Jan 2009
Location: Kingston, Ontario, Canada
Posts: 31
woodk has a spectacular aura aboutwoodk has a spectacular aura aboutwoodk has a spectacular aura about
Re: Black Jaguar RS232->CAN - anyone?

Quote:
Originally Posted by mattbutts View Post
We are also looking at this. I was planning to have one of the students on our team write the functionality for the speed control mode, but I am having a hard time finding the structure for the different CAN messages.

Specifically, looking through the code, it looks like the only trusted messages listed are for enabling different modes and setting their target. In speed control, we would need to know what the messages look like for defining the P and I gains as well as the encoder information.

Unless these can be set in the Jaguar using the BDCOM utility and will stick through power cycles.

Anyone know where I can find this information?
I couldn't find this information anywhere, so I used a program to monitor the serial port while BDCOM is running. From this, I modified CANJaguar.cpp and was able to get speed control working (I think). I haven't added the method to set the number of encoder lines yet, so I don't know what "units" the speed is in. I haven't got current mode working. The values sent by DBComm seem to be somewhat random, and the "control" does not seem to work anyway. Current control on the Jaguars with the original firmware (not updated with FRC firmware) seems to work (form bdc-comm-cli.exe) , but the updated ones do not ... I don't know if there is a new command or way of sending the current setpoints ... I guess we'll have to see if they release updated code samples.

You need to add new "case"s for kSpeed to InitJaguar, Set (and Get if you want). In Set, the case I added is: (set speed uses a 16.16 signed fixed point number)
case kSpeed:
messageID = LM_API_SPD_T_SET | m_deviceNumber;
INT32 value32 = (INT32)(outputValue*65536.0 );
*((INT32*)dataBuffer) = swap32(value32);
dataSize = sizeof(INT32);
break;

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);

}


Hope this helps. Have fun!

- Kevin
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial to CAN Gateway in new Black Jaguars? dmcguire3006 Electrical 54 26-01-2010 07:32
Release Announcement for the MDL-BDC24 (Black Jaguar) JDNovak FRC Control System 2 16-12-2009 18:13
The Black Jaguar David Doerr FRC Control System 5 25-11-2009 15:43
Can I control a victor/jaguar with an RC receiver Bruceb Electrical 3 30-12-2008 10:50
Will ANYONE mess with the black balls? archiver 2001 0 23-06-2002 22:35


All times are GMT -5. The time now is 14:12.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi