Neo Motors internal encoder

When trying to determine if the Neo’s and Spark Max’s were a viable option, I kept getting odd spikes in PID outputs. I found that the internal encoder would randomly read zero. Sometimes in patterns, sometimes just occasionally. It would happen when its moving, when it was still, when I just enabled, and after being enabled for while. Doesn’t this happen to anyone else? Also, does anyone know what types of encoders you can plug in on the SparkMax motor controller?

Personally, at this early point in their life cycle, I would use a separate encoder that was attached directly to your mechanism.

We’re using the SRX Mag encoders from CTRE to go along with ours.

How are you using the CTRE Mag Encoder? The motor simply didn’t move when we plugged the mag encoder into the 10-pin port on the Spark MAX. Are you using a breakout board into RoboRio DIO?

You can’t use an external encoder with the Spark MAX when using a brushless motor. The brushless encoder pins are shared between the top port and the brushless encoder port. You can have Spark MAXes follow a TalonSRX with an encoder plugged in or run the encoders and control loop on the RoboRIO.

Yeah I figured as much, was confused by the wording of that comment.

To get the CTRE Mag Encoder output in the roboRIO, would a CTRE encoder breakout board suffice?

Which PID mode are you using? Do you have any data that you can share of the encoder velocity/position output? The most helpful would be a graph with a plot of the target, the encoder value, and the applied output.

Can you also look at the CAN utilization when this happens?

Yup, a breakout into the DIO. We haven’t used encoders directly into a speed controller before (we had a lot of victors, no talons), so it’s pretty much business as usual for our programming team to do it that way anyways.

Does anyone know how to input and get the output of the CANPIDController? Do I use the setReference function as an input and it automatically outputs to the motor?

I’ve just found the answer here if anyone else needs it.

You can also take a look at the examples we have put together here

These examples include closed loop velocity and position control.

I have an “issue” with following motors. It may be intentional but I don’t like it. The configuration for following a motor stays after a rebuild of code. Even if the rebuild doesn’t even include the second motor. Is there a way to reset this?

You can disable follower mode by setting the follower to ‘kFollowerDisabled’ using the follow method.,int)

1 Like

How can we get an analog feedback into the SparkMax motor controller for PID control? Can we? and if not, why cant we?

Support for analog input is not currently supported but is on our near term roadmap. We are tracking this particular feature on this trello card.

Small clarification question: If you call this using this set of parameters to sc1 (which was previously set to be a follower of sc0 on port 20) sc1.follow(ExternalFollower.kFollowerDisabled, 20) it does indeed stop following 20, but if I call sc1.isFollower() it still returns true. Shouldn’t it return false?

Yes this should return false, however this API updates at a specific rate depending on one of the periodic frames sent back to the roboRIO (default is 10ms). So make sure you wait at least that long, or read from it a few times to see isFollower() set to False.