As a personal project/learning experience, I am trying to use an Arduino Uno in combination with a Victor SP to control a CIM motor. I have a basic understanding of C++ and wiring, but the problem is that I have no idea how to communicate with the Victor SP. Specifically, which of the PWM wires do I need to use, and how do they need to be controlled? Any and all advice would be appreciated.
White wire is signal, black wire is ground, red is unused. The signal needs to be a “hobby servo” style PWM signal. See https://www.arduino.cc/en/reference/servo for an Arduino library. The exact timing for the Victor SP can be found in the WPILib source code (https://github.com/wpilibsuite/allwpilib/blob/master/wpilibj/src/main/java/edu/wpi/first/wpilibj/VictorSP.java), but is “close enough” to the standard hobby servo PWM timing that you should just be able to use the library off-the-shelf with no modifications.
If you use the Servo library, you will need to convert your throttle to a servo angle to send to the library. For this reason, I usually use analogWrite() rather than Servo; there’s still a translation, but at least it’s to something that makes sense (a duty cycle) rather than an angle. OTOH, the Servo library probably has more basic sample code out there you can copy and get going right away. And the timings of the FRC PWM motor controllers (except the Jaguar) line up perfectly with standard servo timing.
Sometimes, I have also skipped the libraries altogether and controlled PWM directly through registers. It’s a deep rabbit hole; don’t do this unless you need to do something faster than the libraries will let you. Going to this level also means your code won’t run on processors which are different than the one you write it for.