REV Encoder Position Flickering

I have 2 Neo Motors + Spark Max that flicker between 0 and some constant number.

It happens in code and in REV Hardware Client.

CSV data from REV Hardware Client:

1689119540555,0
1689119540673,0
1689119540790,0
1689119540917,0
1689119541044,0
1689119541167,0
1689119541281,0
1689119541409,-0.02380952425301075
1689119541524,-0.0476190485060215
1689119541634,-0.0476190485060215
1689119541757,-0.02380952425301075
1689119541884,-0.0476190485060215
1689119541999,-0.0476190485060215
1689119542122,-0.0476190485060215
1689119542243,-0.0476190485060215
1689119542370,-0.0476190485060215
1689119542484,-0.0476190485060215
1689119542597,-0.0476190485060215
1689119542717,0
1689119542833,-0.0476190485060215
1689119542946,-0.02380952425301075
1689119543064,0
1689119543178,0
1689119543293,0
1689119543405,-0.0476190485060215
1689119543520,0
1689119543631,-0.0476190485060215
1689119543760,-0.02380952425301075
1689119543884,-0.0476190485060215
1689119543993,-0.0476190485060215
1689119544108,-0.02380952425301075
1689119544226,0
1689119544343,-0.0476190485060215
1689119544462,0
1689119544583,0
1689119544712,-0.02380952425301075
1689119544836,0
1689119544953,0
1689119545074,0
1689119545201,0
1689119545312,-0.0476190485060215
1689119545435,-0.02380952425301075
1689119545548,0
1689119545675,-0.02380952425301075
1689119545801,0
1689119545928,-0.0476190485060215
1689119546055,-0.0476190485060215
1689119546169,-0.0476190485060215
1689119546292,-0.0476190485060215
1689119546418,-0.02380952425301075
1689119546544,-0.02380952425301075
1689119546671,0
1689119546798,0
1689119546920,-0.02380952425301075
1689119547048,-0.0476190485060215
1689119547164,-0.0476190485060215
1689119547278,-0.0476190485060215
1689119547404,-0.0476190485060215
1689119547521,-0.0476190485060215
1689119547646,-0.0476190485060215
1689119547774,-0.0476190485060215
1689119547901,-0.0476190485060215
1689119548017,-0.0476190485060215
1689119548129,-0.0476190485060215
1689119548243,-0.0476190485060215
1689119548361,-0.0476190485060215
1689119548475,-0.0476190485060215
1689119548609,-0.0476190485060215
1689119548724,-0.02380952425301075
1689119548845,0
1689119548969,-0.0476190485060215
1689119549096,0
1689119549208,0
1689119549332,0
1689119549455,0
1689119549581,-0.02380952425301075
1689119549707,-0.0476190485060215
1689119549833,-0.0476190485060215
1689119549957,-0.02380952425301075
1689119550086,-0.0476190485060215
1689119550214,-0.02380952425301075
1689119550334,-0.02380952425301075
1689119550451,-0.02380952425301075
1689119550576,-0.02380952425301075
1689119550700,-0.02380952425301075
1689119550828,0
1689119550949,-0.02380952425301075
1689119551065,0
1689119551181,0
1689119551298,-0.0476190485060215
1689119551427,-0.0476190485060215
1689119551554,-0.0476190485060215
1689119551678,-0.0476190485060215
1689119551804,-0.02380952425301075
1689119551930,-0.02380952425301075
1689119552057,-0.0476190485060215
1689119552175,-0.02380952425301075
1689119552290,-0.02380952425301075
1689119552402,0
1689119552532,0
1689119552659,-0.02380952425301075
1689119552786,-0.0476190485060215
1689119552910,-0.0476190485060215
1689119553041,-0.0476190485060215
1689119553167,-0.0476190485060215
1689119553278,-0.02380952425301075
1689119553403,-0.02380952425301075
1689119553518,-0.02380952425301075
1689119553633,-0.02380952425301075
1689119553759,-0.02380952425301075
1689119553875,0
1689119554002,-0.02380952425301075
1689119554116,-0.0476190485060215
1689119554243,-0.0476190485060215
1689119554362,-0.0476190485060215
1689119554474,0
1689119554588,-0.02380952425301075
1689119554712,-0.02380952425301075
1689119554839,-0.02380952425301075
1689119554952,0
1689119555077,-0.0476190485060215
1689119555190,-0.0476190485060215
1689119555302,-0.0476190485060215
1689119555422,-0.0476190485060215
1689119555551,0
1689119555679,-0.0476190485060215
1689119555799,-0.02380952425301075
1689119555912,-0.02380952425301075
1689119556039,-0.02380952425301075

Note: I am spinning the motor in on direction

Edit: I am using the built in encoder of the neo

Which encoder are you using? How is it connected? A picture might help…

1 Like

Thanks, I updated the post

The NEO’s built-in encoder is not absolute, so you are looking at values for a device that is not there. See Using Encoders - SPARK MAX.

3 Likes

In my code I am using private RelativeEncoder encoder = motor.getEncoder(); witch I assume is the default encoder (The built in one). The spark max has been factory reset too.

Yes, getEncoder() with no arguments should be using the built-in encoder. If you do getPosition() on the returned object, you should get a position reading in turns – rotations of the motor shaft. Since this is a relative encoder, the position will be relative to wherever the motor shaft happened to be when things powered up, unless you zero the position somehow.

There are many things that can cause problems, so using the REV Hardware Client is a good starting point. See here: https://docs.revrobotics.com/sparkmax/rev-hardware-client/telemetry-tab#telemetry-settings. You want to look at the position data (only) to start off. Beyond this, it’s good to put you code up on github so you can share a link. Or, you can paste it here, inside formatting markdowns:

// Java code will be formatted when you prefix it by a line with just ```java
// and follow it with a line with just ```
private RelativeEncoder encoder = motor.getEncoder();
print(encoder.getPosition());

I am using something similar but to outputing to smartdashboard. Both the data from REV Hardware Client and my code output the same thing. As I mentioned it still happens after a complete factory reset. In my program I do not edit any configuration. Unless there is some setting that a factory reset deos not reset I do not think it is a configuration issue

Just a simple program I am using to test

public class Robot extends TimedRobot
{
    private static final String DEFAULT_AUTO = "Default";
    private static final String CUSTOM_AUTO = "My Auto";
    private String autoSelected;
    private final SendableChooser<String> chooser = new SendableChooser<>();
    private CANSparkMax motor2 = new CANSparkMax(2, CANSparkMax.MotorType.kBrushless);
    private CANSparkMax motor3 = new CANSparkMax(3, CANSparkMax.MotorType.kBrushless);
    private CANSparkMax motor4 = new CANSparkMax(4, CANSparkMax.MotorType.kBrushless);
    private CANSparkMax motor5 = new CANSparkMax(5, CANSparkMax.MotorType.kBrushless);
    private CANSparkMax motor6 = new CANSparkMax(6, CANSparkMax.MotorType.kBrushless);
    private CANSparkMax motor7 = new CANSparkMax(7, CANSparkMax.MotorType.kBrushless);
    private CANSparkMax motor8 = new CANSparkMax(8, CANSparkMax.MotorType.kBrushless);
    private CANSparkMax motor9 = new CANSparkMax(9, CANSparkMax.MotorType.kBrushless);

    private RelativeEncoder encoder2 = motor2.getEncoder();
    private RelativeEncoder encoder3 = motor3.getEncoder();
    private RelativeEncoder encoder4 = motor4.getEncoder();
    private RelativeEncoder encoder5 = motor5.getEncoder();
    private RelativeEncoder encoder6 = motor6.getEncoder();
    private RelativeEncoder encoder7 = motor7.getEncoder();
    private RelativeEncoder encoder8 = motor8.getEncoder();
    private RelativeEncoder encoder9 = motor9.getEncoder();

    @Override
    public void teleopPeriodic() {

        SmartDashboard.putNumber("Motor 2", encoder2.getPosition());
        SmartDashboard.putNumber("Motor 3", encoder3.getPosition());
        SmartDashboard.putNumber("Motor 4", encoder4.getPosition());
        SmartDashboard.putNumber("Motor 5", encoder5.getPosition());
        SmartDashboard.putNumber("Motor 6", encoder6.getPosition());
        SmartDashboard.putNumber("Motor 7", encoder7.getPosition());
        SmartDashboard.putNumber("Motor 8", encoder8.getPosition());
        SmartDashboard.putNumber("Motor 9", encoder9.getPosition());


    }
}

5 and 7 are the problematic ones

OK, just to confirm, you have 8 NEOs/SPARK MAXes and 6 of these work as you expect but 2 do not? The part about having 6 working with the same setup wasn’t clear before…

Do all 8 motors run the same – all run OK? Check the connectors with the small signal wires, and the wires themselves to be sure everything looks good. Also, check that you don’t have anything that has fallen into the 10-pin data port on 5 and/or 7. If it is easy to do, you could try swapping one of the 5 or 7 motors so it is attached to one of the good SPARK MAXes, to see if the problem follows the motor or the controller.

All of them are running fine. Everything looks fine too. When I do a swap they still don’t work

After the swap, is it the 5 and 7 (these CAN IDs are tied to the SPARK MAXes) readings that do not work, or did the “not working” move to the SPARK MAX that now has one of the motors that had been on 5 or 7? This will tell you if the problem is with a motor (or the attached cable) or, if it is with a SPARK MAX.

I have emailed Rev and it is a software issue on there end

What do you mean?

Can you elaborate?

1 Like

There is a thread on the FRC discord server with a ton of info.

Solution: For now just replace the spark max.

Can you link to the specific conversation? I have no idea what to look for here.

1 Like
1 Like

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