Go to Post Swerve is hard to get right. - marshall [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 02-02-2011, 12:18
Trump Trump is offline
Registered User
FRC #2053
 
Join Date: Feb 2010
Location: New York
Posts: 18
Trump is an unknown quantity at this point
A few Questions about proggramming with CAN

Hello,
This year my team decided that we would like to program the robot drive, and arm control using CANJaguars. We wanted to do this last year, however the CANJags weren't fully implemented yet.

So, before I begin programming i have a few questions.

1) We are using mecanum wheels for our drive train, My assumption after looking through the CANJaguar code is that all I need to do is set the control mode to kSpeed, and then set m_maxoutput to the physical max RPM of our slowest motor.

2) Does the CANJaguar class automatically use feedback from the encoders to correct its speed using PID? I'm assuming again that i would first need to set the speed reference to kSpeedRef_QuadEncoder, and then set the P, I, and D.

3) When the CANJag is set to KSpeed, the source code comments say the constructor will automatically set the speed reference to the quad encoder, but i don't see where in the constructor it does that.

4) I have some qualms about using the jags internal PID loop because of what was said on this thread http://www.chiefdelphi.com/forums/sh...t=90508&page=2 however it looks like they were using java. Can anyone confirm whether this is also happening with c++?

Finally, we are also going to be using an arm for our manipulator. I am planning on using potentiometers to determine position.

5) The CANJaguar class has a ConfigPotentiometerTurns(UINT16 turns) function, but the pots i was planning on using only turn 340 degrees(slightly less than 1 turn). Should I just use a 1, and then set soft position limits? For this I'm again assuming that the CANJaguar will automatically use feedback from the potentiometers and use PID to control the arms position.

6) Not really about CAN, but does anyone know if the potentiometers must be 10k, as per the jaguar manual, or is it possible to use other values?

If someone could answer these questions, or confirm/disconfirm my assumptions it would be a huge help! I've read through the CanJaguar source, and understand what each function does, however when I actually look at the functions I'm having trouble following how they are doing what they say they are doing.
Reply With Quote
  #2   Spotlight this post!  
Unread 03-02-2011, 11:40
dyanoshak dyanoshak is offline
Registered User
AKA: David Yanoshak
FRC #2158 (ausTIN CANs)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Austin, TX
Posts: 189
dyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond repute
Re: A few Questions about proggramming with CAN

Quote:
Originally Posted by Trump View Post
6) Not really about CAN, but does anyone know if the potentiometers must be 10k, as per the jaguar manual, or is it possible to use other values?
In short, It would be easiest to use a 10K pot.

You can use other values, but let's look at the schematic first (page 24 of the RDK-BDC24 User's Manual).

Notice there is a 1K resistor in series with the '+' pin on the Potentiometer input header J3. When a 10K pot is wired to this header as per the datasheet, the resistor and pot act as a voltage divider. This puts 3.0V across the pot (3.0V = [10K/(1K + 10K)]*3.3V) making 3V the maximum voltage the wiper can be. This is perfect because the ADC (Analog to Digital Converter) pins on the Jaguar's microcontroller can only read 0 - 3.0V.

The ADC on Jaguar is a 10-bit ADC, so it measures 0 - 3.0V in 1024 discrete steps. So if you were to use a lower resistance pot, let's say 5K, your wiper will swing between 0 and 2.75V (2.75V = [5K/(1K+5K)]*3.3V). This is well within the range of the ADC, but you are only measuring the full range of the pot with approximately 940 steps rather than 1024.

Let's say you go with a higher resistance pot, 20K, your wiper will swing between 0 and 3.14V. The ADC can still only measure up to 3.0V, so the last 0.14V will just cap the measurement at 3.0V. Let's say that you have a 10-turn pot; the last 0.14V can be equal to 160 degrees of undetected motion!

So in conclusion:

Yes, you can use different values of potentiometers, but be aware of how the different values can affect your system.

TI recommends using a 10K pot for simplicity and maximum resolution over the maximum range of the pot.

-David
Reply With Quote
  #3   Spotlight this post!  
Unread 03-02-2011, 12:11
dyanoshak dyanoshak is offline
Registered User
AKA: David Yanoshak
FRC #2158 (ausTIN CANs)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Austin, TX
Posts: 189
dyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond repute
Re: A few Questions about proggramming with CAN

Quote:
Originally Posted by Trump View Post
4) I have some qualms about using the jags internal PID loop because of what was said on this thread http://www.chiefdelphi.com/forums/sh...t=90508&page=2 however it looks like they were using java. Can anyone confirm whether this is also happening with c++?
The main discussion in that thread was over how to tune the PID constants. It might be hard to read through the discussion, but teams have had success tuning the Speed PID constants starting with I first.

Quote:
Originally Posted by Trump View Post
5) The CANJaguar class has a ConfigPotentiometerTurns(UINT16 turns) function, but the pots i was planning on using only turn 340 degrees(slightly less than 1 turn). Should I just use a 1, and then set soft position limits? For this I'm again assuming that the CANJaguar will automatically use feedback from the potentiometers and use PID to control the arms position.
Basically this converts the measured pot voltage into turns. For example, on a 1 turn pot, a 1.5V reading will convert to 0.5 turns. If you set a 10 turn pot, 1.5V will convert to 5 turns.

So for you, your 0 - 340 degree pot will read as 0 - 1 Turn.

-David
Reply With Quote
  #4   Spotlight this post!  
Unread 03-02-2011, 19:54
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: A few Questions about proggramming with CAN

Quote:
Originally Posted by Trump View Post
1) We are using mecanum wheels for our drive train, My assumption after looking through the CANJaguar code is that all I need to do is set the control mode to kSpeed, and then set m_maxoutput to the physical max RPM of our slowest motor.
You must be talking about RobotDrive. Just call SetMaxOutput() to set the speed that you want joystick full forward to mean. Remember that you may want to leave a little headroom for variations in battery voltage, chain tension, etc.

Quote:
Originally Posted by Trump View Post
2) Does the CANJaguar class automatically use feedback from the encoders to correct its speed using PID? I'm assuming again that i would first need to set the speed reference to kSpeedRef_QuadEncoder, and then set the P, I, and D.
You need to SetSpeedReference() and ConfigEncoderCodesPerRev() and SetPID() and lastly EnableControl().

Quote:
Originally Posted by Trump View Post
3) When the CANJag is set to KSpeed, the source code comments say the constructor will automatically set the speed reference to the quad encoder, but i don't see where in the constructor it does that.
That comment is outdated. It no longer does that since this year there is more than one option available. I just didn't notice that comment to delete it.

-Joe
Reply With Quote
  #5   Spotlight this post!  
Unread 03-02-2011, 20:28
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: A few Questions about proggramming with CAN

Quote:
Originally Posted by Trump View Post
4) I have some qualms about using the jags internal PID loop because of what was said on this thread http://www.chiefdelphi.com/forums/sh...t=90508&page=2 however it looks like they were using java. Can anyone confirm whether this is also happening with c++?
It is a real pity that one person's confusion was blown out of proportion like this. I hope that you aren't permanently scared off by what amounted to a disagreement on vocabulary.
Reply With Quote
  #6   Spotlight this post!  
Unread 03-02-2011, 20:48
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: A few Questions about proggramming with CAN

Quote:
Originally Posted by Trump View Post
4) I have some qualms about using the jags internal PID loop because of what was said on this thread http://www.chiefdelphi.com/forums/sh...t=90508&page=2 however it looks like they were using java. Can anyone confirm whether this is also happening with c++?
The link you cite is a really long thread that seems to have nothing to do with any actual perceived behavior that could have anything to do with the language you are programming in. Perhaps you can clarify what exactly you are concerned about.

-Joe
Reply With Quote
  #7   Spotlight this post!  
Unread 03-02-2011, 23:44
Trump Trump is offline
Registered User
FRC #2053
 
Join Date: Feb 2010
Location: New York
Posts: 18
Trump is an unknown quantity at this point
Re: A few Questions about proggramming with CAN

Thanks every one for the clarifications, as to the link i posted i was concerned basically because it seemed like people were having trouble getting the set function to work in speed mode. I just wanted to check to see if this was actually the case because i have no experience using CAN.

As to setting the speed reference I know we are using the quad encoders, do i still need to set the number of clicks?
Reply With Quote
  #8   Spotlight this post!  
Unread 04-02-2011, 03:48
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: A few Questions about proggramming with CAN

Quote:
Originally Posted by Trump View Post
Thanks every one for the clarifications, as to the link i posted i was concerned basically because it seemed like people were having trouble getting the set function to work in speed mode. I just wanted to check to see if this was actually the case because i have no experience using CAN.

As to setting the speed reference I know we are using the quad encoders, do i still need to set the number of clicks?
Yes, you still need to set the scaling.
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 14:44.

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