I’ve got a few questions relative to the CANJaguar class in the WPI Library.
Does the CANJaguar included in the WPI Library run on its own interrupt routine? In other words, if we run custom PID code, and we perform functions with Jaguars using CAN, are we going to be 100% sure that our IRQ rate specified in our program (for TeleopPeriodic) will be the actual IRQ rate for the Jags? I need the wisdom of someone experienced with the WPI Library.
The PID algorithm that runs on the Jaguar uses the timer interrupt on the controller internally (every 1ms). It does not depend on an interrupt in the cRIO. That’s one of the nice things about using CANJaguar’s PID instead of running the PID algorithm on the cRIO. Each control loop has a dedicated microcontroller to run it.
Correct me if I’m wrong, but what I’m getting from your response is that the easiest way to get the Jaguar to run proper PID code is to use the WPI Library’s functions from the CANJaguar class, which were written to cooperate with the built-in 1ms interrupt? If that is what you are saying, then is there any way for us to implement our own PID code directly within the microcontroller of the Jaguar itself, to get it running on the 1ms interrupt, instead of us running our code within the cRIO (TeleopPeriodic)?
To clarify: last year, we actually did not use the PIDController class or the CANJaguar class; instead, we wrote our own PID algorithm and used the SetSpeed function from the normal Jaguar class (if I can recall the name of that function correctly) to carry out the ramped speed commands. (We did not use CAN, either.)
What I’m now wondering is this: Last year, were we in fact trying to run our custom PID code, while at the same time the Jaguar was running its own little PID code in its own world, potentially interfering with our PID code? (i.e., did we just get lucky that we didn’t have any problems with these two algorithms running in parallel?) And if so, is it possible to perhaps replace the PID algorithm that the Jaguar uses by default with our own PID code, so that we can be sure that our interrupt routine is the only interrupt routine that is running in this system?
I am sorry if parts of this don’t make sense, or if I am confounding any fundamental components of the Jaguar’s internal operation, as I am somewhat inexperienced in this area. But I can further clarify my questions if necessary.
If you weren’t using CAN last year, then you weren’t using the Jaguar’s PID. That is the only interface to enable the internal controller.
If you want to run the PID controller on the cRIO, that’s fine. I’m surprised you wrote your own given the very capable implementations provided for you.
There is no way for you to replace the PID algorithm in the Jaguar. You may either use it as is via CAN, or you may ignore it and run any other PID implementation on the cRIO.