I’ve been trying to configure a SparkMAX for closed-loop current control, but without having found any examples or documentation I’m struggling with tuning. REV’s site mentions that this is a feature, but doesn’t go into any detail about how it works. Further, the tuning I’ve tried has yielded unexpected results.
What I’ve Tried:
Using the robot’s drive (MAXSwerve in a rotation diamond)
kP, kI, kD = 0, kF = 0.5, setpoint = 2A. This did seem to cause rapid acceleration as I would expect, but it was fast enough that I disabled the robot without having noted any useful information. I then stopped trying to tune kF based on how motors work- there won’t be a constant volts/amp requested. This test was perfomed with the robot able to drive on the floor.
kI, kD, kF = 0, kP = 0.001, setpoint = 0.001, 0.01, 0.1, 1, 10A: no motion.
kI, kD, kF = 0, kP = 0.01, 0.1, 1: All of these had similar results. At low setpoints (0.001, 0.01), no motion. Sometimes, for mid-range setpoints (0.1-0.4), and mid-range kP (0.1), the motor would rotate slowly, at a seemingly constant velocity. The measured current reported by getOutputCurrent()
seemed constant/oscillating around a constant, but above the setpoint. I assumed that was providing just enough force to balance static friction, so I tried increasing the setpoint. Result? Air-horn/falcon chirp noise and no motor rotation (i. e. motor is oscillating at audible frequencies). These tests were performed with the robot on the cart, modules free to move.
Does anyone know how to tune a SparkMAX current control loop, know where documentation/examples exist, or even just know what the current control mode does exactly?
Why I'm doing this
Choreo asks for the robot’s moment of inertia, and I want to measure that empirically. Moment of inertia is torque over angular acceleration, so I need to apply a constant torque to the robot, which can be done by applying constant drive force at the wheels. Constant wheel force = constant drive motor torque = constant drive motor current.