Go to Post No matter what you do and how well you try to protect them, some people are just out there to be candidates for the Darwin Awards! - Jay H 237 [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 12-02-2010, 10:22
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 333
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
CAN Position control code?

Greetings!

Has anyone modded the CANJaguar.cpp code for position control? Willing to share the code by any chance?

TIA,

Mike
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2010, 10:31
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: CAN Position control code?

It's in SVN. http://firstforge.wpi.edu/integratio...ystem=exsy1002
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2010, 10:48
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 333
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: CAN Position control code?

Hmm... The code in SVN seems to use only the kPercentVoltage control mode.

switch (m_controlMode)
{
case kPercentVoltage:
sendMessage(LM_API_VOLT_T_EN | m_deviceNumber, NULL, 0);
break;
default:
return;
}

I was looking for something that implemented the kPosition control mode...

TIA,

Mike
Reply With Quote
  #4   Spotlight this post!  
Unread 12-02-2010, 15:25
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: CAN Position control code?

Is this what you are asking about? http://www.chiefdelphi.com/forums/sh...ad.php?t=82458
Reply With Quote
  #5   Spotlight this post!  
Unread 12-02-2010, 17:19
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 333
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: CAN Position control code?

Yup, something like that. Unfortunately, he never got an answer.

TIA,

Mike
Reply With Quote
  #6   Spotlight this post!  
Unread 12-02-2010, 21:58
simpsonboy77 simpsonboy77 is offline
Registered User
AKA: Garrett Dicken
FRC #0041 (RoboWarriors)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: New Jersey
Posts: 88
simpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond repute
Re: CAN Position control code?

Ok, here is my best shot at answering this. We literally got it working about 4 hours ago, and even then it would stop working randomly (no change of code in between). Your mileage may vary.

We attached a 100k potentiometer (we had no 10k's which the manual calls for) to the signal pin of the jaguar.

First add this to the switch statement in InitJaguar()

case kPosition:
sendMessage(LM_API_POS_EN | m_deviceNumber,NULL,0);
break;


This sets the jaguar into position mode. Again, not sure if this is right, I'm just going through everything I changed.
Initialize the CANJaguar object.

My line looks like Kicker = new CANJaguar(6,CANJaguar::kPosition); The 6 is the CAN ID.

Then I have in my teleop init portion the following. I put it there because it didn't seem to work while in disabled. I think its because you cannot send CAN frames because that could be used to make a motor move. And if you are disabled, this is against the rules .

Kicker->SetPositionReference(CANJaguar::kPosRef_Potentiom eter);
Kicker->ConfigPotentiometerTurns(1);
Kicker->ConfigNeutralMode(CANJaguar::kNeutralMode_Brake );

Wait(.001);
Kicker->SetPID(300,.001,0);
Kicker->EnableControl();


Note mine are pointer references, so you might need to use the . operator instead. After some experimenting the first line must be first. Otherwise you get errors, but if you enable/disable the robot a few times it starts working.
My PID constants are not tuned, but it gets the motor moving at a reasonable rate. We are using a CIM with a 9:1 or a 12:1.

I put that wait(.001) in there because it seems that it fails less. I'm thinking maybe the bus needs some time to clear or something, I honestly have no idea.

Then in your teleop or autonomous use the Set method. Values are between 0 and 1 I think. I'm not sure if it includes -1 to 0. My guess is no because the Get returns a float between 0 and 1.


If you post questions I'll try my best to answer.

Once again, I just got this working so I may be wrong. I am just telling you most of my steps I took to get it working.
__________________
2017 Shenzhen, China Regional CSA
2013 - Present MAR Control System Adviser and FTAA
2009 - Present Programming an Electrical Mentor Team 41
2007 - 2008 Team 41 Lead Programmer, Electrical
2005 - 2008 Team 41 Member
2008 NYC Regional Winner

Last edited by simpsonboy77 : 12-02-2010 at 22:01.
Reply With Quote
  #7   Spotlight this post!  
Unread 13-02-2010, 01:08
daltore's Avatar
daltore daltore is offline
Electronics/programming/design
AKA: Aaron Osmer
FRC #3529 (ausTIN CANs)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2007
Location: San Antonio, TX
Posts: 272
daltore has a spectacular aura aboutdaltore has a spectacular aura aboutdaltore has a spectacular aura about
Send a message via AIM to daltore Send a message via MSN to daltore Send a message via Yahoo to daltore
Re: CAN Position control code?

A little background on the 10k potentiometer value in the manual:

The Luminary Micro ARM processor that's in the Jaguar operates off of 3.3v, but the ADC is only 3v tolerant. They have a 1k resistor connected in series to the power pin on the pot input on the Jaguar, so you have to use a 10k pot to cause a voltage drop across the 1k resistor of .3v and the voltage drop across the entire potentiometer of 3v.

By using a 100k pot instead of a 10k, you're causing a voltage drop of 3.27v across the potentiometer. This means that if you pull the pot all the way down to its minimum resistance, the ADC is experiencing 3.27v, which is .27v greater than it was rated for. This might be why you had sporadic results.

If you don't have a 10k pot on hand, don't use a lower value, as that will cause more current to flow, which is also not necessarily good. If you have some spare resistors lying around, try putting them in series or parallel with the two extremes of the potentiometer to achieve 10k. This may reduce your resolution, but it won't break the Jaguar. If you don't have any resistors, wait until the next day.

This is just my take on it, if it works fine for you, go for it, but it may or may not be risky.
Reply With Quote
  #8   Spotlight this post!  
Unread 13-02-2010, 02:26
simpsonboy77 simpsonboy77 is offline
Registered User
AKA: Garrett Dicken
FRC #0041 (RoboWarriors)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: New Jersey
Posts: 88
simpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond repute
Re: CAN Position control code?

The added voltage ran across my mind, but the potentiometer was mounted in some C channel since it was previously a throttle control for the 2008 robot. So there are physical stops that prevent it from going under .4 and over 2.8.

Also the the original poster, if you post what code you have currently, we could help you debug it better.
__________________
2017 Shenzhen, China Regional CSA
2013 - Present MAR Control System Adviser and FTAA
2009 - Present Programming an Electrical Mentor Team 41
2007 - 2008 Team 41 Lead Programmer, Electrical
2005 - 2008 Team 41 Member
2008 NYC Regional Winner
Reply With Quote
  #9   Spotlight this post!  
Unread 13-02-2010, 11:46
heydowns's Avatar
heydowns heydowns is offline
Registered User
AKA: Jeff Downs
FRC #1511 (Rolling Thunder)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Ra-Cha-Cha
Posts: 142
heydowns has a reputation beyond reputeheydowns has a reputation beyond reputeheydowns has a reputation beyond reputeheydowns has a reputation beyond reputeheydowns has a reputation beyond reputeheydowns has a reputation beyond reputeheydowns has a reputation beyond reputeheydowns has a reputation beyond reputeheydowns has a reputation beyond reputeheydowns has a reputation beyond reputeheydowns has a reputation beyond repute
Re: CAN Position control code?

Quote:
Originally Posted by taichichuan View Post
Yup, something like that. Unfortunately, he never got an answer.

TIA,

Mike
Quote:
Originally Posted by Joe Ross
I just responded to that thread. If that doesn't answer your question, please follow up.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Position Control using potentiometer? biojae CAN 13 03-02-2010 20:12
More CAN control questions Geek 2.0 Electrical 0 12-01-2010 13:40
CAN control weirdness nathanww Electrical 4 04-01-2010 21:13
can we control the amount of air to control the speed of the cylinder? Team2339 Pneumatics 22 11-02-2009 15:33
Where can I find motor control in Camera.c? sjung9442 Programming 3 31-01-2006 15:49


All times are GMT -5. The time now is 15:17.

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