Is there currently any way to get encoder output from an encoder attached to the Spark MAX data port? I need to use a versa planetary encoder, but I don’t really like using Talon SRXs. Can I use the Spark MAXs instead?
Yes there is a standard encoder port on top of spark maxes. Same as the one on Talons
Is there any specific classes/API/methods that I need to use, or do I just use the normal CANEncoder class?
Im not sure. Check the Doc for them http://www.revrobotics.com/sparkmax-software/
Note that the encoder pins on the data port are shared with the sensor from the motor. So you can only use an external encoder if you are using a brushed motor (not a NEO). The support for the encoder is enabled in the firmware, but is not exposed in the API. It will be in the next API release, we are tracking this issue here.
I can attest to this. We accidentally ran the motor when we had a mag encoder plugged in and it made the noise you don’t want a motor to make. Thankfully, after a reboot our sparks were working fine.
Alright, I have found a very interesting bug. When I use the CANEncoder class to get values from the versa planetary encoder from the data port, it sometimes returns 0. The only way I have found to make it return actual values is to use the SPARK MAX client to change the sensor type. For some reason, it keeps resetting itself to “SensorType: None”. When I change it back to Encoder or Hall Effect, the encoder starts to return proper values.
I found a fix for this that doesn’t seem very intended.
I used the CANSparkMaxLowLevel class to manually set the sensor type from within code
Motor.setParameter(CANSparkMaxLowLevel.ConfigParameter.kSensorType, 1);
When I use the code from my previous reply, the motor controller forces itself into brushless mode. From what I can tell, you cannot currently use encoders and a brushed motor at the same time.