we’re trying to use the amt10 quadrature encoder on our drivetrain in distance mode. specifically we attach it to the gear box. the problem i’m having is that when the gearbox starts to rotate, the distance jumps a large value and then seems to track correctly. for example, we have the dip switches set to 200 and the encoder type to kx1. when i turn the encoder just slightly to a positive distance, the distance out of the FPGA jumps to 90, then tracks. if i turn the encoder in the negative direction, the distance instantly jumps to positive ~60, then tracks down eventually going negative. i’ve tried 2 different encoders on two different roborio’s with nearly identical behavior. we’re programming in java. this happens in both the 2015 and 2016 libraries.
has anyone had this behavior? is there a fix?
obviously this makes the encoders useless for autonomous mode…
any help would be appreciated.
bill
here’s the code from RobotMap that instantiates the encoder:
driveTrainRightQuadrature = new Encoder(0, 1, false, EncodingType.k1X);
LiveWindow.addSensor(“DriveTrain”, “RightQuadrature”, driveTrainRightQuadrature);
driveTrainRightQuadrature.setDistancePerPulse(1.0);
driveTrainRightQuadrature.setPIDSourceParameter(PIDSourceParameter.kDistance);
driveTrainLeftQuadrature = new Encoder(2, 3, false, EncodingType.k1X);
also note that the behavior we are seeing is through the smartdashboard. we want to use this encoder via a PID controller and with the unusual output, we cannot get the PID controller to work properly.
has anyone been able to use the amt10 quadrature encoders to work with a PID controller using java as the language?
thanks…
figured out what’s going on.
first, there appears to be a bug (or feature depending upon how you view it) in the smartdashboard wrt the “zero distance” button on the encoder widget. in test mode, if you click on the “zero distance” button for the encoder, it sets the displayed value to zero. it DOES NOT set the the distance accumulator to zero. basically if the smartdashboard is showing 90 as the current distance from the encoder, clicking the zero distance button will set the displayed value to 0. but the value in the acculator is still 90. as soon as i moved the encoder, the displayed value will jump from zero to 90 and start tracking.
this is not the case for the reset method on the encoder class. that appears to function properly, setting the accumulated value to zero.
in addition (and this is our fault) the connectors we used to connect the encoder wire to the roborio port were not very secure and as such i believe were causing either spikes or missed edges which in turn made using the distance in a PID controller unstable. we have since purchased connectors from digikey that are much more secure and show a clean edge on an o-scope.
so, is there a way to log a bug against smartdashboard? or get the source code so i can propose a patch?