Exadler Technologies Inc

 

 

 

The Encoder 5132 product also works the the Arduino just as well as it does on our DMCC Mk.6 Motor Controller.  Just wire up +5 and GND on the Encoder 5132 to the +5 and GND pins on the Arduino, and then connect Channel A to pin 2 on the Arduino, and Channel B to pin 3 on the Arduino.  Use the following sketch and you now have a working quadrature encoder on the Arduino!

 

int pulses;
int deg = 0;
int encoderA = 2;
int encoderB = 3;

int pulsesChanged = 0;

void setup(){
  Serial.begin(115200);
  Serial.println("hello");
  pinMode(encoderA, INPUT);
  pinMode(encoderB, INPUT);  
  
  attachInterrupt(0, A_CHANGE, CHANGE);
  attachInterrupt(1, B_CHANGE, CHANGE);

}//setup

void loop(){
  if (pulsesChanged != 0) {
    pulsesChanged = 0;
    Serial.println(pulses);
  }
}

void A_CHANGE(){
  if( digitalRead(encoderB) == 0 ) {
    if ( digitalRead(encoderA) == 0 ) {
      // A fell, B is low
      pulses--; // moving reverse
    } else {
      // A rose, B is low
      pulses++; // moving forward
    }
 } else {
    if ( digitalRead(encoderA) == 0 ) {
      // A fell, B is high
      pulses++; // moving forward
    } else {
      // A rose, B is high
      pulses--; // moving reverse
    }
  }
  // Make sure the pulses are between 0 and 359
  if (pulses > 359) {
    pulses = pulses - 360;
  } else if (pulses < 0) {
    pulses = pulses + 360;
  }
 
  // tell the loop that the pulses have changed
  pulsesChanged = 1;
}

void B_CHANGE(){
  if ( digitalRead(encoderA) == 0 ) {
    if ( digitalRead(encoderB) == 0 ) {
      // B fell, A is low
      pulses++; // moving forward
    } else {
      // B rose, A is low
      pulses--; // moving reverse
    }
 } else {
    if ( digitalRead(encoderB) == 0 ) {
      // B fell, A is high
      pulses--; // moving reverse
    } else {
      // B rose, A is high
      pulses++; // moving forward
    }
  }
  // Make sure the pulses are between 0 and 359
  if (pulses > 359) {
    pulses = pulses - 360;
  } else if (pulses < 0) {
    pulses = pulses + 360;
  }

  // tell the loop that the pulses have changed
  pulsesChanged = 1;
}

        

BeagleBone Black's Out of Stock!!

Unfortunately, we've run out of our shipment of BeagleBone Blacks.  Our next expected shipment is in 10-16 weeks.  Sorry for the inconvenience and thanks for shopping at Exadler Technologies Inc....

Beagle Bone Black in Stock!

We just received a shipment of BeagleBone Black from Circuit Co. Order yours today!

Beaglebone Black controlling a Motor using Python and a DMCC

Controlling a Motor with a Beaglebone Black, DMCC, and Python