Go to Post Someday I will have to learn how tagging and reps work. I already know how search and brain farts work. - kstl99 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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-01-2011, 14:37
7-11number1 7-11number1 is offline
ROAR.
FRC #1711 (RAPTORS)
 
Join Date: Sep 2007
Rookie Year: 2006
Location: Traverse City, Michigan
Posts: 46
7-11number1 will become famous soon enough
Black Jaguars and CANBUS 2011

Does anyone have an working example of a simple demo robot that shows how to use the Java 2011 canbus class with the 2011 kit? I want to switch from PWM to CANBUS this year, but need an example to see how it all fits together.

Go FIRST!
-Michael
Team #1711
Reply With Quote
  #2   Spotlight this post!  
Unread 12-01-2011, 16:43
rrossbach rrossbach is offline
Registered User
AKA: Ron R
FRC #2607 (RoboVikings)
Team Role: Mentor
 
Join Date: Nov 2008
Rookie Year: 2008
Location: Warrington PA
Posts: 90
rrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to beholdrrossbach is a splendid one to behold
Re: Black Jaguars and CANBUS 2011

As far as the code goes, just create CANJaguar objects instead of Jaguar objects - for simple driving with a joystick everything else is the same between CAN and PWM. It also helps to do some exception handling when creating the objects, like this:

Code:
        while (leftMotor == null && ++maxRetries < 10) {
            try {
                leftMotor = new CANJaguar(1);
            } catch (Exception e) {
                System.out.println("CANJaguar(1) error " + e.getMessage());
                Timer.delay(.1);
            }
        }

        if (maxRetries >= 10)
            System.out.println("CANJaguar(1) did not initialize, cannot drive");
Aside from the code itself there are a bunch of other setup things to take care of other as well (flashing the firmware on the Jags, re-imaging the cRIO to use the CAN plugin, setting up the 2CAN if you're using that, etc). CAN also supports much more advanced control modes than just simple driving so you may want to consider that as well.

You'll find several threads about all of this in the CAN subforum under Electrical - if you need any further help feel free to ask!

- Ron
Team #2607 controls mentor
__________________

FIRST Mid-Atlantic Volunteer
FRC Team #2607 Mentor
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 10:25.

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