Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   can drive (http://www.chiefdelphi.com/forums/showthread.php?t=101912)

Method 04-02-2012 00:44

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.

WizenedEE 04-02-2012 03:08

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.

Method 04-02-2012 04:26

Re: can drive
 
Quote:

Originally Posted by WizenedEE (Post 1119640)
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 (Post 1119640)
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 (Post 1119640)
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

Method 04-02-2012 13:54

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.


All times are GMT -5. The time now is 13:27.

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