CAN from scratch

My primitive Google-fu has failed me, and searching Chief Deplhi has proved futile. So I’ll ask the question that so many beginners have asked before.

My team is in its second year. Last year, we controlled our (brown) Jaguars through PWM. This year, having acquired two black Jaguars, we want to try using the CAN bus to control drivetrain.

The only problem is, that we have no idea where to start.

First of all, how do I start the CAN bus? Is that port on the Digital I/O sidecar a CAN port? Or do I need a serial-CAN cable? Can I have brown Jaguars on the bus?

How do I interface to the CAN bus? Do I need to flash the cRIO with a new image? Does WPILib support CAN out of the box?

Any help will be immensely appreciated.

There are two options for creating a CAN network:

You can use a 2CAN as your CAN bus master (connecting to the cRIO via an ethernet cable)

OR

You can use a Black Jaguar as your CAN bus master (connecting to the cRIO via an RS232-CAN adapter).

Here’s an overview of the differences:

  • 2CAN provides access to the CAN bus at 5x the rate of the bridging Black Jaguar
  • You can update firmware directly from the 2CAN, whereas with the Black Jaguars, you must upate the firmware using an RS232 port (or converter) on your computer
  • 2CAN is more expensive
  • Using a black Jaguar will require you to make or buy RS232-CAN cable, wheras the 2CAN uses a common ethernet cable to connect to the cRIO

Now, picking one doesn’t prevent you from switching. You can always start with a bridging Black Jaguar, and switch to 2CAN if you decide you need a greater communication rate.
However, we can help you better if you decide which one to go with for now.

You can have a tan Jaguar on the bus. Any Jaguar on the bus requires a firmware update to be fully functional with CAN.

In software, it’s a very easy change. MotorDevRefs include PWM- and CAN-based controllers in the same typedef. You can convert to CAN just by changing how the motor is opened. (In LabVIEW, this is in Begin.vi. Make sure to replace the “DriveMotorOpen” with the one from the functions palette, so you can just use the polymorphic selector to change it to a CAN open.

If you’re using LabVIEW and the Black Jaguar CAN, I’ve put together a package to help you set up your Jaguars.
http://kamocat.com/robot/electrical/CAN_resources.zip

Thanks for the summary.

We are using C++, not Labview.

The link you gave me seems to be broken, I’m getting a “404” type page.

When you image the cRIO, it has an option for a CAN driver. Do I need to put anything there?

Check out our team’s wiki.

The wiki is a work in progress, but this article is complete. It goes over the basics of the CAN network.

EDIT: Nevermind, apparently the website currently has messed up permissions.

The link seems fine to me, perhaps you should try again

To switch C++ software to CAN, instead of creating Jaguar objects you should create CANJaguar objects. The only other change needed is updating the port numbers in the constructors with the CAN IDs of the jaguars.

In the cRIO imaging software you should select the method of connecting to the CAN bus you are using. If you are going with a serial-jaguar connection, select BlackJaguarBridge. If you’re using a 2CAN, select 2CANBridge (I’m not 100% sure those are the exact names)

@big1boom: When I try to load your page, I get this.

@Radical Pi: Really? When I try to open it, I get this.

Both: thanks for your insight.

You’re right, it is broken - I’m re-uploading the file right now.

At any rate, for C++ CAN, Radical Pi is the one to talk to. Unless you have hardware questions, I’ll leave you in his capable hands.

Interesting… The site is currently in Beta and we have been having a lot of trouble with permissions. Thanks for actually showing me what is wrong with it.

EDIT: If you don’t mind, could you try this. http://coolhub.imsa.edu/cybercollab/web/robotics-documentation/documentation/-/wiki/Main/Controller%20Area%20Network%20%28CAN%29

I may have given you a link for people who are logged in. If this link doesn’t work then I am going to have to get in contact with the development team.

That link works.

Some other things to be aware about:

CAN cable is pretty much standard phone cable (some small differences) so there is industry support for it. By that I mean we got a crimper that can make a cable in seconds, as opposed to PWM (don’t get me started).

The 2CAN has 2 ethernet and 1 CAN port on it; one ethernet goes to the c-RIO, the other goes to either the bridge or the camera (depending on what c-RIO port you plugged it into) and the CAN goes to a jaguar. It has a really nice web interface, which shows you, among other things, input and ?output voltages, temperature, fault condition (internal circuit breakers), current, and lots of other great stuff. It also makes it dead easy to do other fun stuff (setting IDs, reflashing firmware (which didn’t actually work for me…)) and is generally cool.

The only problem is it has a really short power cable coming out of it.

The black jaguar converter is also really nice, and much cheaper if you care about that.

This is being changed along with several other hardware features in the next revision of hardware.

http://www.chiefdelphi.com/media/papers/2433

i wrote that document on how to make the black jaguar method work from scratch.

hopefully that answers your questions.

If we use the Black Jaguar method, can we let that Jaguar have a function like controlling one motor? Or is it required that that Jaguar be left alone only as the CAN Bus Master?

Thank you.

The Black Jaguar can also control a motor.

I’ve seen no data to indicate that using this Jaguar to control a motor will impact the performance of your CAN bus.

The only exception to this is I would recommend against using the bridging Jag to control a high current motor (like a drive motor) that may potentially trip a breaker. If any other Jag trips a breaker, the rest of the Jags on the bus continue to function since the CAN bus is wired through on the PCB. If the bridge Jag’s breaker trips, the rest of the CAN bus is isolated from the cRIO so all motors will stop.

-Joe