Using NEO Vortex Integrated Encoder

I was trying to access the NEO Vortex’s integrated encoder(with the spark flex), and got an error when trying to access it with

rev::SparkRelativeEncoder m_encoder = 
      m_motor.GetEncoder(rev::SparkRelativeEncoder::Type::kHallSensor, 7168);

And when running I got errors about 7168 not being valid. Is there a different way to access it? I had assumed 7168 would be correct as per the spec.

From what I’m seeing, it would seem you’re correct.

Can you share the rest of your code (ideally as a github link) and the actual error message(s) you’re seeing?

Unfortunately, I do not have access to the motors for a little bit to get the exact error message.

I just opened a timed robot base and just added the two lines below, nothing else. The goal was to simply test an intake prototype and get some encoder reading, unfortunately this wasn’t possible due to the aforementioned error.

  rev::CANSparkFlex m_intake{1, rev::CANSparkFlex::MotorType::kBrushless};
  rev::SparkRelativeEncoder m_intakeEncoder = 
        m_intake.GetEncoder(rev::SparkRelativeEncoder::Type::kHallSensor, 7168);

As far as I know, the Spark Flex is updated to the latest version. We flashed it just before using it with the latest version.

The sensor in the Flex is not a hall sensor. Just do this:

  rev::CANSparkFlex m_intake{1, rev::CANSparkFlex::MotorType::kBrushless};
  rev::SparkRelativeEncoder m_intakeEncoder = m_intake.GetEncoder();

Thanks.

So I tried to do this, and found that you get a compile error if you try to do this. GetEncoder requires arguements defining the encoder type and counts per rev.

Interesting, that looks like an unintentional error in the REVLib code. This may sound weird after the last comment I made, but try it like this:

 rev::CANSparkFlex m_intake{1, rev::CANSparkFlex::MotorType::kBrushless};
 rev::SparkRelativeEncoder m_intakeEncoder = m_intake.GetEncoder(rev::SparkRelativeEncoder::Type::kHallSensor);

I’ll be able to test tomorrow. Thanks again for the help.

Can the measurement period for a Vortex be set to 1ms?

The Javadoc says:

Set the position measurement period used to calculate the velocity of a quadrature or hall sensor encoder. For a quadrature encoder, this number may be between 1 and 100 (default). For a hall sensor, this number may be between 8 and 64. The default for a hall sensor is 32ms.

And when I try to set it to 1 on a Vortex, it complains about the lowest possible value being 8, because its a “hall sensor” when it shouldn’t be.