We are still trying to figure out how to implement can bus using LabView. The example was pretty specific to arcade drive, but I haven’t yet clearly understood what the sub VIs do or why. Has anyone out there successfully gotten the can bus to work with LabView?
I have. What specifically do you have questions about?
Where would one even get sample code for CAD in labview?
Thanks for fielding this.
For starters, what are the differences in the control modes for the open vi: Percent Vbus, Speed, Position, and current - and how do they relate to the status info that can be read back?
Also, can I use the jaguar as a connection point for an encoder without using the sensor to control that particular motor?
Finally, if a potentiometer or encoder is connected to the jaguar, what is displayed for the status->speed value? Counts per sec? degrees?
First, let me warn you that the current snapshot is not functional for the closed loop modes. If you check out the latest SVN code, then things should work for you. I fixed some bugs in the last few days so make sure you are up to date.
The Percent Vbus is the same open loop mode that you get with PWM… it’s just higher resolution than the PWM interface. Speed mode uses an encoder as a reference sensor to attempt to maintain a speed you set in spite of load or voltage changes. Position is the same, except that instead of a fixed speed, it uses a fixed position and can use a single- or multi-turn potentiometer or an encoder as a reference. Current mode attempts to drive the motor as a fixed current (which is related to torque) in spite of variable load. They are pretty much independent of the status data.
You could, but I wouldn’t recommend it since it is slower to read from the Jag than directly from the cRIO’s 9403. If you do this, you won’t have any feedback for the motor you are actually controlling so you would need to be in open-loop Percent Vbus mode.
The output is in RPM assuming you configured the number of lines in your encoder. The potentiometer is not a valid speed reference.
If you read the position status, then it is based on the position reference that you select (encoder or pot) and the output is the number of rotations.
Thank you, thank you, and thank you Joe! That helped a lot. Our can bus works now. The only thing that we haven’t yet done is write the set/get refnum functions for a single Jaguar. Any idea how to do that? (that is to say, do we try to modify the can library, or write our own from scratch?)
I did that for our team, and it’s a bit messy, but not too bad. First of all, the next update of the CANJaguar library will have a RefNum VI set in it, and is accessible on SVN (you’ll have to ask Joe how to access that). Second, it might just be easier to bundle all of the RefNum output clusters into one big cluster and run it between Begin and Teleop/Autonomous, where it is then unbundled.
If you look in the “CANJaguar for LabView” folder from First Forge under “CAN Jaguar - MotorControl”, there is a SubVIs folder. One of the files in this folder is called “CAN Jaguar Ref.ctl”, and is not a VI, it’s a cluster. If you right-click on the front panel, go to “Select a VI…” and double-click this file, it will put a cluster on the front panel. You can then copy this to create an in and an out.
If you look at all of the Get and Set RefNum VI’s, they’re all pretty much exactly the same, except the input clusters are different. You can do the same here. You will need to copy 3 files; “xxxx RefNum Get Set.vi”, “xxxx RefNum Registry Set.vi”, and “xxxx RefNum Registry Get.vi”, where “xxxx” is the new name of your favorite RefNum VI (I used the PWM motor control one). In all of these new VI’s, “simply” replace all of the old refnum clusters with the CANJaguar cluster. Remember you will probably have to rewire the terminals on the connector for the VI, and you should also redo the icon a bit so you know what’s what.
Once you’ve modified the VI’s you copied into your project folder (and not replaced them, never modify VI’s that are still IN the standard LabView libraries, you get lots of errors that way), make sure they’re added into the project in LabView, under Team Code. You should be able to wire them in normally as RefNums now, but let me know if you have any problems.
Again, it might just be easier to bundle the RefNum clusters together (make sure to name them descriptively so you can see what’s what when you unbundle) and wire them through. And, also again, there will be a refnum VI set in the next CANJaguar release.
In case you didn’t already notice, I posted snapshots of all the latest CANJaguar code under file releases on FIRST Forge. The new shapshot includes the get ref and set ref VIs for CAN Jaguar. It also includes a number of bug fixes, so everyone should definitely upgrade.