PWM SparkMax Encoder

Does anyone know how to get the encoder value of Spark MAX’s connected to the PWM network? When looking at the documentation provided by REV Robotics I can only find a class for the CAN encoders, and currently to just run the motors I’m using the PWM SparkMAX class I just can’t seem to find a way to get the encoder count of it.

I also would like to mention with the use of the 6-pin Encoder port.

It is not possible to read encoder values or use closed-loop control on a SPARK MAX over PWM. Connect via CAN if you want to do that.

Not even through the integrated encoder or even an external encoder if need be?

If you want to read the NEO’s sensor values without using CAN, you’d have to connect the sensor pins to both the SPARK MAX and the roboRIO simultaneously (which I’m not sure would even work), and then somehow decode the hall effect sensor signals (which would not be straightforward).

Ah unfortunate, thank you for the help though. I’ll look more into it as being hopeful towards trying to make it work, but if I can’t I’ll try and switch to CAN.

I asked the folks at REV a couple of weeks ago about this for an arduino project. It has never been tested in this mode (getting the encoder values from the 10 pin connector on the MAX while the MAX is using it for commutation) but he thought it would probably work. If you do this, connect the encoder PWM to a DIO pin, not a PWM pin on the RIO. The PWM pins are configures as outputs - DIOs can be inputs. There is a sensor type in WPIlib that can be used to read PWM pulse lengths - I don’t recall the name OTOH, but IIRC it is used in the time-of-flight sensor example.

Added: Also, if you do decide to use the Hall Effect encoder pins, there are three of them. Each is 7 cycles per rotation, 120 degrees out of phase. You can use any two of these as a quadrature encoder input pair, though there will be extra jitter because they are 120 rather than 90 degrees out of phase.

1 Like

Are you saying that the SparkMax converts the Hall effect inputs on the encoder port to an absolute PWM output on the data port? I wouldn’t have expected that.

No, the encoder in the motor actually includes this PWM as an output, similar to the absolute encoder line on the SRX encoder (though I presume it has 42 rather than 4096 different states).

It does not.

What I had described in email to @GeeTwo was reading or “monitoring” the 3-phase hall signals by sensing them on the Data Port with an Arduino for a non FRC project.

I absolutely do not recommend doing this in FRC for the following reasons:

  • This configuration has not been tested
  • It is very easy to disrupt the hall signals and affect the motor commutation.
    • Motor and/or controller damage is possible
  • The hall signals are not Quadrature and I am not aware of any provided APIs that can decode this type of signal natively.

My recommendation for getting encoder feedback while controlling the SPARK MAX through PWM would be to use an external encoder wired directly to the roboRIO.

1 Like

The NEO sensor cable only outputs the 3 hall sensors and temperature. It does not output an absolute pulse.

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