CAN, PID, Mecanums

My team is using mecanums and CAN, and I want to use the KOP encoders and the PID on the jags to make sure the wheels spin the right speed.

I believe to do this I need to open each motor individually in speed mode, set the PID values, and then plug them in to a four motor drive of “existing motors”

My questions are:
Do I need to change the holonomic drive VI to make it work with speed mode?

Do I need to use speed mode to do this, or is there a way to do it with Percent
VBus (which should work unmodified with the holonomic drive VI, right?)?

I need to “tune” my PID right? what is the recommended method for doing this? I know trial and error is common, do I need to test with the whole robot, or can I use BDC-COMM?

I can help with this…
Im my opinion although you could use the BDC-COMM it is best to do manual calibration because you can set it yourself and make sure you have a working PID.

Yes.

My questions are:
Do I need to change the holonomic drive VI to make it work with speed mode?

Yes, the Holonomic Drive VI is designed to work with a magnitude of -1 to 1. You can find a “max output speed” parameter in the RobotDrive ref, and multiply this as done in Arcade Drive.

Do I need to use speed mode to do this, or is there a way to do it with Percent
VBus (which should work unmodified with the holonomic drive VI, right?)?

I would highly recommend using speed mode. Percent vBus will work with the default VI, but it doesn’t provide good low-speed control or repeatability.

I need to “tune” my PID right? what is the recommended method for doing this? I know trial and error is common, do I need to test with the whole robot, or can I use BDC-COMM?

Trial and error is probably best, because it will give you an understanding of how the different parameters affect it. You can do this with the BDC-COMM, but be sure to write them down; these parameters are not retained when the Jaguar looses power.

i don’t understand why you have to use speed instead of the regular

The robot is currently not moving at all when the joysticks are moved.

I know it is either a problem with the encoders or with my code, but I can’t be sure which. The robot previously moved when being controlled by different code using percent vbus, so I know the other wiring is correct.

Here’s what i’m currently doing in my code:

in begin vi:
i open a can reference to each motor, specifying speed mode, device number, and whether or not it is inverted. then I “set speed ref” using “quad encoder” as the speed reference (correct for KOP encoders?). I “set PID” constants, and then I enable the motors. I currently have my PID constants set as P: 0.1 I: 0.004 D: 0. Are these reasonable for mecanums directly driven by toughboxes? If not, could someone give me an explanation oof the process of manual tuning so I can be sure I did it correctly? The motors are then wired into a 4 motor drive of “existing motors” and the “max output” is set. (this should be the top speed in rpm, right?)

in teleop vi:
x and y axis are wired to x and y of a holonomic drive, and x axis of another joystick is wired to rotation

The robot does not move at all and the colors on the jaguars do not change, even when the joysticks are pushed fully in any direction. I believe the problem is in one of 3 places: wiring of the encoders, logic of my code, or values of my pid constants.

Well, we know that the wiring of your encoders is not the issue right now. If that were the case, the Jaguars would go full-speed FWD when you pushed forward, and full-speed REV when you went reverse.

My first guess would be that you haven’t set the “max RPM” in the OpenExistingMotors VI, and that you haven’t set the number of lines on the encoder.
If you’re on tough boxes with CIMs, the max RPM should be about 4500 / 12.6, which is around 350 RPM. The default is 1.

It was in fact a failure to set the encoder lines in the open vi.

Now I have another mostly unrelated problem. The joysticks we are using no longer spring back perfectly to center, so the robot moves slightly even when the joysticks are not being touched. I looked up the jaguar calibration and found that it appeared to only apply to pwm. Is there a similar process for CAN or a way i can correct for it in the code?

Calibrating the jaguars isn’t what you want to do anyway. What you need to do is implement a dead band on your joystick inputs. Basically you take any values less than some value, say 0.02 or something, and set it to 0.00. That way even if the joystick doesn’t center itself completely, your robot won’t be moving.

I tried implementing a dead band, and it didn’t work as expected. The robot will not move at all with the dead band in place. I made a VI to handle the dead band so the teleop is cleaner and it can be reusable…

I have attached screen shots and the VI itself. If someone could help me debug it that would be great.

thanks




deadband.vi (8.59 KB)





deadband.vi (8.59 KB)