View Single Post
  #1   Spotlight this post!  
Unread 18-02-2012, 18:01
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Analog Encoder Troubles

We're trying to use an analog encoder (http://www.usdigital.com/products/mae3) to measure rotations off of a motor shaft. I'm trying to use the Counter class for this, but the measurements are very erratic. It'll halt measuring at all for a few seconds, then the number will increment by 4 or 5, and then it will start regularly updating but by increments of 2 for a while, then normally by increments of 1, etc etc. The motor shaft is turning at a constant speed.

Right now in the subsystem that's executing the counter code I have
Code:
private static AnalogTrigger horRotEncoder = new AnalogTrigger(RobotMap.horRotEncoderPos);
private static Counter horRotCounter = new Counter(horRotEncoder, true, true);
to declare the Encoder and the Counter.

Then I have
Code:
protected void initDefaultCommand() {
    horRotCounter.setUpSource(horRotEncoder, AnalogTriggerOutput.Type.kRisingPulse);
    horRotCounter.setUpSourceEdge(true,false);
    horRotCounter.reset();
    horRotCounter.start();
}

public double getHorRotations(){
      
    return horRotCounter.get();
}
What I've tried to do with that is make it only count when it increments up, just for testing. And I'm printing the output of getHorRotations() to see what the values are.

We have an oscilloscope hooked up to the encoder, so we can see it's getting the right values, so I suspect the problem is in the Counter class.
Reply With Quote