Spark Max Alternate Encoder Mode Not Working

I am trying to use an SRX Mag encoder connected to a Spark Max in Alternate encoder mode, but it doesn’t seem to be registering. I have been attempting to troubleshoot these problems for a few days and this is my last resort. We have a mag encoder in a hex bore housing that vex sells, broken out with the srx mag encoder breakout board, soldered to a Rev Data Port Breakout Board Rev A in the manner specified by REV on their website.
My code is here:

The error I get when I run that code is: "ERROR  4  [CAN SPARK MAX] WPILib or External HAL Error: CAN: Message not found, CAN: Message not found"

I have tried running the encoder plugged straight into the data port on a spark max in brushed mode and it works perfectly, so i have determined that the encoder works and is set up properly.
However, as soon as I set the Spark Max to be in Alternate Encoder Mode and try to read the Encoder position, I get the error I wrote above. If anyone has any ideas, please help. Thanks in advance.

When you say the encoder plugged straight into the data port was working perfectly, was that using the combination of soldered breakout boards connected to the top data port? More importantly, was the only difference in setups the fact that you were calling getAlternateEncoder() and not getEncoder()? Based on the code provided, it looks like getEncoder() was being used, which will use what’s connected to the front facing 6-pin JST port and not the top data port.

Can you also verify that the Spark Max is running the the latest firmware (v1.5.1)? Alternate encoder support is only supported on v1.5.0 and later.

Lastly, I recommend also reaching out to and sending them some pictures of the electrical setup you have for the encoder and Spark Max to see if they can offer additional advice as to why you’re having trouble.

1 Like

When I was running the encoder in Brushed mode, I plugged the ribbon cable into the port on the Spark Max without using the breakout board. Then I used .getEncoder() to ensure that the encoder actually worked. I can also verify that the speed controllers are running v1.5.1. I am planning to compose an email to REV support later today.

1 Like

Sounds to me like the encoder works fine but there’s an issue in the connection to the top data port. Without seeing the setup itself it’s hard for me to tell where the issue is but I would confirm with REV Support that your wiring on the breakout boards is correct.

1 Like

When you say you “soldered to a Rev Data Port Breakout Board Rev A in the manner specified by REV on their website”, can you specify what you mean? Is this the method they say where you wire the encoder pins to the limit switch pins on the breakout board? If not, and you soldered to the encoder pins on that breakout board, it could be that the motor controller doesn’t like that you’ve put an encoder on the same pins as the motor’s internal encoder.

Regardless, I would suspect that an error like this (showing up as a CAN receive error, essentially) is a wiring error rather than a software error if the motor controller works fine without the breakout board plugged into it.

I soldered them in the manner specified on REV’s website under the “Connecting an alternate encoder” section, where the pins are reconfigured. Here are some pictures:
(For context: Red = 5V, Black = Ground, Green = A, and White = B)

When you seat the Data Port Breakout Board on the Spark Max, can you double check that it is aligned correctly? There is enough space to offset the board by a row of pins in either direction if you’re not careful.

Can you also confirm in the Spark Max Client under Advanced Tab -> AlternateEncoder that kDataPortConfig is 1 for the Spark Max to which the breakout board and encoder are connected?

Yeah, I double checked before I left today and it was seated properly and the tab for kDataPortConfig was set to “alternate encoder” (I believe that’s what it sets to in the 2.1.1 version of the client)

I would also test with a second Spark Max, making sure to follow the Alternate Encoder Bring-Up procedures REV has documented here. Do this configuration on the Spark Max before connecting the encoder board for the first time. Check the positioning of the board before powering on the Spark Max as well. The code you posted seems fine, assuming you’re running the currently commented out alternate encoder calls. If you’re still having issues I would definitely email REV support.

1 Like

Yeah, that was the documentation I followed for setup. I’ll send an email to rev support quick like for sure. I just wanted to post here first to see if it might have just been me doing something obviously wrong. Thanks for the help.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.