Spark Max Smart Motion with absolute encoder?

Our climber consists of two single stage ThriftyBot elevators, each with their own encoder, to reach up for the rung and a pair of rotating arms, each with their own encoder, with a hook to latch onto the bar. If we get far enough, we will use a combination of rotating the arms and extending the elevators to get to the next rung.
We plan to use Smart Motion to limit The max velocity and max acceleration. The elevator winches will rotate through several rotations as the elevator extends to max height so we’re using a relative encoder for that. This matches the Rev example so we feel good about that. The arms rotate less than a full revolution and we want to make sure we know where they are at all times so we are thinking of using a Rev Through-Bore encoder as an absolute encoder for that. We still want to use Smart Motion to limit its velocity and acceleration.
Two questions:
1 - Can I use an absolute encoder as the feedback sensor when using Smart Motion?
2 - the absolute output from the Rev Through-Bore encoder is typically read from the single PWM-style (Red, White, Black) connector plunged into a DIO port. How do I set this as the Alternate Encoder for the Spark Max?

This thread is a couple years old, but matches what I’m seeing in the docs (and describes it more concisely so it’s easier to link to). Using Absolute Encoders (including with REV products) - #15 by dyanoshak

In short, the SparkMax doesn’t (yet) have any way to accept an absolute encoder (analog or PWM) signal, so you would either have to use quadrature or absolute but on the Rio, meaning it can’t do the SmartMotion control on-board the controller

There is a workaround used by the SDS vendor dep, I forget exactly how to use it, but it the rev encoder is “resettable” so you use the dio encoder to reset the sparkmax encoder to whatever the dio encoder reads. I’ll get back to you with some real code.

1 Like

I hope this configuration works, because this is exactly what our team is planning on. Using two NEOs to control an arm with a through bore encoder attached to the SPARK MAX with smart motion. Code is mostly done, but we don’t have an arm on our robot yet. (what week is it again?)

Here’s is example code from Rev, to use a through bore encoder with a Spark MAX:

If you are using brushless motors like the NEO, you will need one of these to attach the encoder to the sparkmax Alternate Encoder Adapter - 2 Pack - REV Robotics
because you will need to attach the NEO to the JST PH 6-pin connector on the Spark Max needs to connect to your NEO.

hoping that @dyanoshak will correct me if I’m wrong.

We have a 150::1 gear reduction from the Neo to the arm. So 6300 Neo ticks equates to 360 degrees of rotation. We will have a physical stop against which we will align the arm at startup and reset the Neo relative encoder to zero. We also plan to use the through-bore in absolute mode connected to the DIO in the RoboRIO as a check.

The remaining question is How do you tune a velocity PID loop on a system that can’t run continuously? We really need to tune it under load too. I’m not anxious to hang the robot and then “see what happens when I do this”

Set the current limit very very low. Start with kF very very low as well, like 0.0001. if it doesn’t move, multiply kF by 10. Increase kF slowly until it gets pretty close to your target. If it’s being weird, you have too much kF.

Set a wider than usual acceptable error at the start as well. Tune it later.

You may need to increase the current limit to get it to move, if it’s a climber for example. Just start really strict on everything and only increase to what you feel comfortable with.

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