Rev Through Bore Encoder to Spark Max Issue

Having an issue with our Rev Through Bore Encoder, the encoder is giving noisy/gibberish data between approx 0.4 and 1.2 as our arm rotates.
Troubleshooting steps:

  • Ensured the Spark Max is set to Alternate Encoder mode (although we’ve tried with this both enabled and disabled)

  • Plugged the Alternate Encoder Adapter to the Spark Max, and then to the Through Bore Encoder

  • Set the Alternate Encoder Adapter switch to “ABS PWM” and Through Bore Encoder to “A”

  • Initialize the AbsoluteEncoder object to encoder.getAbsoluteEncoder(Type.kDutyCycle);

  • Attempt to view the absolute position with encoder.getPosition();

The values are changing when the shaft moves, but the values jump around between the ranges stated above when the shaft is moved in the same direction.
I’m actually suspecting the encoder itself is faulty, but do you have any ideas whether any of the config above is wrong?

1 Like

You might want to confirm that you have wired it up correctly and are using the right board on the SparkMax. In particular, if your SparkMax is driving a NEO or a Neo550, you need to plug the motor’s data cable into the port adjacent to the power wires. Then, you need to plug the wires from the encoder into this adapter board:

Note that this is easily confused with

But that latter one won’t work for this application. I suspect you are using the later one based on your reference to a switch on the board. The correct board (my first listed one) does not have a physical switch on it.

Once you’ve plugged the data cable from the encoder into the former of the two boards, you need to mount the board to the “top” of the SparkMax (i.e., the big face). I’d also recommend securing that board to the SparkMax with some electrical tape, as it is a bit of a loose connection.

Lastly, to access the encoder in Java code, you can write something like this:

SparkMaxAbsoluteEncoder myEncoder = mySparkMax.getAbsoluteEncoder( SparkMaxAbsoluteEncoder.Type.kDutyCycle);

This will return a number between 0 and 1 proportional to the angle of the encoder

I think the naming of things as “alternate encoder” and such is a little confusing and might be tripping some people up. I know that I was a little confused by it at first as well. But this page documents what you are supposed to use on what scenario: Using Encoders - SPARK MAX

Ugh, that’s it, the wrong adapter was ordered. This was indeed the “Alternate Encoder Adapter” and not the “Absolute Encoder Adapter”.

Can you confirm whether the Spark Max still needs to be set for Alternate Encoder Mode?

I’m actually not sure what “Can you confirm whether the Spark Max still needs to be set for Alternate Encoder Mode?” means in this context. There’s no physical mode switch on the Absolute Encoder Adapter, nor is the there a physical mode switch on the Spark Max itself. In software, you don’t really need to specify a mode like that, but you do need to specifically call the right method for an absolute encoder, like this:

SparkMaxAbsoluteEncoder myEncoder = mySparkMax.getAbsoluteEncoder( SparkMaxAbsoluteEncoder.Type.kDutyCycle);

I’m referring to the big, bold warning on Rev’s website:

This refers to the Spark Max software setting in firmware called “Alternate Encoder Mode” for the variable kDataPortConfig

just using this thread because its mentioning encoder useage. so with this encoder outputing a value between 0 and 1 according to angle I don’t really have a way to see what rotation it is on (say on a subsystem that needs to have the shaft spin more than once) but other than adding a manual rotation count I don’t know how I would do this. It doesn’t look like the encoder scale or whatever its actually is called does what I want so I’m somewhat stumped

Is the through bore encoder plugged into the data port or the encoder port? If it’s plugged into the encoder port you can just call it with the getEncoder() method. You only use getAlternateEncoder() if it’s plugged into the data port.

Plugged into the data port because we are running a brushless motor (NEO) through the encoder port, which I assume is necessary to operate the NEO

Are you using the NEO’s built in encoder? If not, there shouldn’t be a need to have it plugged in to the encoder port.

1 Like

I don’t think this is true. Brushless motors will not work without being plugged into the controllers, even in PercentOutput mode, because it uses that data for decommutation to run the motor itself
(Try it, the motor will not spin well if at all)

Also, does the standard data port support the PWM (absolute) input? AlternateEncoder is for the differential (quadrature) encoder we’ve established.

1 Like

Here’s what the absolute Through Bore encoder feedback looks like in the Rev Hardware Client.
No other special setup, it’s not an alternate encoder, just the proper Absolute Encoder Adapter into the data port.

Brushless motors must be plugged into the encoder port, even when using “PercentOutput” mode.

The NEO’s built-in encoder can tell you a couple of things:
-The speed that the motor is spinning at
-The number of rotations it has made since startup

Neither of these things will tell you the absolute position of a mechanism which is geared anything other than 1:1 with the motor.

Regarding the earlier question of “Can you confirm whether the Spark Max still needs to be set for Alternate Encoder Mode?”. I now see what you are referring to. Assuming that you are intending on using the Through Bore Encoder to read an absolute angle of something, then no, you should not put it in Alternate Encoder Mode.

To answer @SammyPants question above: If you need to measure the absolute angle of a mechanism that spins more than once, you can combine these things to get what you need. Read the absolute angle of the mechanism using the Through Bore Encoder while the robot is starting up. Then add any rotations from the motor’s built-in encoder, multiplied by whatever gear ratio you have between the motor and mechansim.

To use the absolute output of the through the bore encoder requires connecting the absolute output of the encoder (white wire on stock extension cable) to the data port of the spark max controller on the multi-function pin.
Through the bore pinout. You need to hook up GND, +V, ABS to spark max.
GND - gnd
+V to +5V
ABS to multi-function-pin

Spark Max data port on top
The multi-function-pin

Data Port Connector Information

Connector Pin Pin Type Pin Function
1 Power +3.3V
2 Power +5V
3 Analog Analog Input
4 Digital Forward Limit Switch Input
5 Digital Encoder B
6 Digital Multi-function Pin
7 Digital Encoder A
8 Digital Reverse Limit Switch Input
9 Digital Encoder C / Index
10 Ground Ground

Make sure spark-max has latest firmware as this is a newer feature.
This is the connectivity of the absolute encoder adapter board but can be done with soldering using the data port break out board.
This leaves limit switches and brushed / brushless options available.
When hooked up correctly you can see the encoder move in the rev client.

1 Like

ahh that’s a bit simpler than having a periodic function to count the rotations thanks for that

Since the wrong breakout board was ordered and I don’t have time to order another one for our first event, I will need to solder to the data port breakout board.
However, I searched thoroughly and found NO documentation on the pinout correlation between the board and the pin description you posted above.
Can you confirm that the “multi function pin” pin 6 is labeled as “P5” on this board? That’s the only one that has not been accounted for by process of elimination

You’re correct. Revision A boards like you have were incorrectly labeled per REV.

This post confirms that as well as the documentation on REV’s product page for this board.

U can also connect the 6 pin cable to the roborio dio ports using the premade adapter cable or make ur own.

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