Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   A few Questions about proggramming with CAN (http://www.chiefdelphi.com/forums/showthread.php?t=90761)

Trump 02-02-2011 12:18

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.

dyanoshak 03-02-2011 11:40

Re: A few Questions about proggramming with CAN
 
Quote:

Originally Posted by Trump (Post 1014105)
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

dyanoshak 03-02-2011 12:11

Re: A few Questions about proggramming with CAN
 
Quote:

Originally Posted by Trump (Post 1014105)
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 (Post 1014105)
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

jhersh 03-02-2011 19:54

Re: A few Questions about proggramming with CAN
 
Quote:

Originally Posted by Trump (Post 1014105)
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 (Post 1014105)
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 (Post 1014105)
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

EricVanWyk 03-02-2011 20:28

Re: A few Questions about proggramming with CAN
 
Quote:

Originally Posted by Trump (Post 1014105)
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.

jhersh 03-02-2011 20:48

Re: A few Questions about proggramming with CAN
 
Quote:

Originally Posted by Trump (Post 1014105)
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

Trump 03-02-2011 23:44

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?

jhersh 04-02-2011 03:48

Re: A few Questions about proggramming with CAN
 
Quote:

Originally Posted by Trump (Post 1015332)
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.


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

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