![]() |
Need help solving the CAN mystery
I'm one of the team mentors for FRC 4386.
We would like to use CAN Talon SRX controllers this year. We've always used PWM previously and I just can't seem to get my head wrapped around how CAN works. Specifically I'm having trouble even just declaring motor controllers and the setup and initialization code in the drivetrain subsystem. :confused: I've searched and just can't seem to find any code examples or documentation on how to get off the starting line, so to speak. If anyone out here can help me find some code examples or a good explanation of implementing CAN at the code level it would be greatly appreciated! We are also planning to use a Mechanum drive so any examples that you can point me to using that would be extra helpful. Thanks! |
Re: Need help solving the CAN mystery
This is what I taught the beginner programmers today with the standard Iterative robot provided by FIRST using two CAN Talons as the drive base. The code basically created one joystick intending to do Arcade Drive, two CAN Talons for the left and the right wheels and a drive base taking the two wheels. Then in TeleOp, you just call Arcade Drive and give it the joystick. That's it. Basically, I have added 5 lines to the Iterative Robot sample code and have a drivable robot base.
Note that the parameters passed to the CANTalon constructors are CAN IDs. In the code below, the left wheel has ID 3 and right wheel ID 4. CAN Talon motor controllers are connected to the CAN bus which is basically just two wires. All CAN devices tap onto these two wires. So when talking to them, you need to address the device by its CAN ID. So you need to set up each of the CAN Talon controller with its unique ID generally in the range of 1 to 63 (don't use 0 because that's the default ID came from the manufacturer). You need to use the web interface of the RoboRIO to change the CAN ID of each CAN Talon. You need to do this just once and the ID is saved in non-volatile memory in the controller. Code:
package org.usfirst.frc.team492.robot; |
Re: Need help solving the CAN mystery
BTW, here is an example for mecanum drive base. 8 lines total added to the standard Iterative robot code.
Code:
package org.usfirst.frc.team492.robot; |
Re: Need help solving the CAN mystery
|
Re: Need help solving the CAN mystery
Quote:
|
Re: Need help solving the CAN mystery
Quote:
Were our github examples helpful? Here's a java one with RobotDrive and many talons. https://github.com/CrossTheRoadElec/...bot/Robot.java And section 3.4 in the software reference manual specifically calls out how to use RobotDrive. |
| All times are GMT -5. The time now is 09:45. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi