Go to Post And the rest of the team helped them, encouraged them, and made a big deal about how awesome it was that we were competing for the Chairman's Award. - Carolyn_Grace [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-02-2012, 00:44
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
Post can drive

hello! I am using can jags and a custom drive-- not too complex atm but i have some bugs.

The code builds and runs on the robot but the indicator lights on the jags show no changes as the controllers are used.


//def so remotes work
#define IO (DriverStation::GetInstance()->GetEnhancedIO())

//declarations
CANJaguar lefty, righty, leftyB, rightyB, intake, arm, LTop, LBot;
Joystick pilot, copilot;

//constructs
DoctaEight(void):
pilot(1),
copilot(2),
lefty(2),
righty(3),
leftyB(4),
rightyB(5),
{
GetWatchdog().Kill();
lefty.ChangeControlMode(CANJaguar::kPercentVbus);
righty.ChangeControlMode(CANJaguar::kPercentVbus);
leftyB.ChangeControlMode(CANJaguar::kPercentVbus);
rightyB.ChangeControlMode(CANJaguar::kPercentVbus) ;
intake.ChangeControlMode(CANJaguar::kPercentVbus);
LTop.ChangeControlMode(CANJaguar::kPercentVbus);
LBot.ChangeControlMode(CANJaguar::kPercentVbus);
}

//drive
//negate is just a positive or negative char to turn the drive
void DoctaEight::drive(void)
{
GetWatchdog().Kill();
if (pilot.GetY() > 0 && pilot.GetX() >= 0)//forward right
{
lefty.Set(pilot.GetY() * negate);//left motors full
leftyB.Set(pilot.GetY() * negate);//left motors full
righty.Set(( pilot.GetY() - pilot.GetX() * 2 ) * negate);//right motors full dec by twiceX abs X
rightyB.Set(( pilot.GetY() - pilot.GetX() * 2 ) * negate);
}//(so up to x = 0 right rev and when y negative, backward curve)
else if (pilot.GetY() < 0 && pilot.GetX() > 0)//backward left
{
righty.Set(pilot.GetY() * negate * -1);
rightyB.Set(pilot.GetY() * negate * -1);
lefty.Set((pilot.GetY() - pilot.GetX() * 2) * negate);
leftyB.Set((pilot.GetY() - pilot.GetX() * 2) * negate);
}
else if (pilot.GetY() > 0 && pilot.GetX() <= 0)//forward left
{
righty.Set(pilot.GetY() * negate);
rightyB.Set(pilot.GetY() * negate);
lefty.Set((pilot.GetX() * 2 + pilot.GetY()) * negate);
leftyB.Set((pilot.GetX() * 2 + pilot.GetY()) * negate);
}
else if (pilot.GetY() < 0 && pilot.GetX() < 0)//back right
{
lefty.Set(pilot.GetY() * negate * -1);//left full back
leftyB.Set(pilot.GetY() * negate * -1);//left full back
righty.Set(( pilot.GetY() + pilot.GetX() * 2 ) * negate);//right morots full dec by twice abs X
rightyB.Set(( pilot.GetY() + pilot.GetX() * 2 ) * negate);
}
else
{
righty.Set(pilot.GetY() *negate);
rightyB.Set(pilot.GetY() *negate);
lefty.Set(pilot.GetY() *negate);
leftyB.Set(pilot.GetY() *negate);
}
}



We used 4prom modular cable- telephone wire- to connect the can jags to the Crio. The values set in the jags during firmware update are 2, 3, 4 and 5. Controllers are in USB ports on DS. When the Crio was imaged we selected 'black jaguar can jags crio connection' (that is not verbatim as i do not remember such)


Please assist.

Last edited by Method : 04-02-2012 at 02:22.
Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2012, 03:08
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
Re: can drive

So you have the db9 to rj-45 adapter wired up correctly with a terminating resistor and a 6 wire cable to the first black jaguar? And you have terminator on the other side as well?

I suspect the problem is in the "telephone wires" which are backwards from the wires the Jaguars use. If you hold a wire flat, the connectors should face different directions.

Also, do you have your initialization right? It appears that you have an extra comma at the end and the compiler doesn't like that.
Reply With Quote
  #3   Spotlight this post!  
Unread 04-02-2012, 04:26
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
Re: can drive

Quote:
Originally Posted by WizenedEE View Post
So you have the db9 to rj-45 adapter wired up correctly with a terminating resistor and a 6 wire cable to the first black jaguar? And you have terminator on the other side as well?
That sounds right but I am the programmer; not electronics. Ill respond to this shortly

Quote:
Originally Posted by WizenedEE View Post
I suspect the problem is in the "telephone wires" which are backwards from the wires the Jaguars use. If you hold a wire flat, the connectors should face different directions.
Thankyou- I'll look into it.

Quote:
Originally Posted by WizenedEE View Post
Also, do you have your initialization right? It appears that you have an extra comma at the end and the compiler doesn't like that.
Yes- sorry: my full code is far larger and I neglected to remove the comma
Reply With Quote
  #4   Spotlight this post!  
Unread 04-02-2012, 13:54
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
Re: can drive

CAN cables are not wired in opposite directions. Also, we have a terminal and the 6 wire is connected from the crio to the first black Jag.
Reply With Quote
Reply


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


All times are GMT -5. The time now is 03:02.

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