Com-10790 rotary encoder

I need help. I am exhausted and nothing seems to work for this encoder. How do I wire it including resistors etc?Can someone help with sample code? Nothing I have tried returned any results. I do not need directional travel. I will be calculating speed of a manufacturing line so this is what I thought I needed but I cannot get any output signals.

I don’t have one; this is based on the data sheets. It looks like the part number is E6A2-CS3E. That translates to a single output on “A” that is a “voltage” output (in other words, an open collector with a built-in pullup resistor). One of the comments suggests that you may need an external pullup, If so, I would try something in the 2k to 10k range. Based on this, you can ONLY get speed, not direction, from this encoder.

For wiring, connect blue to ground, brown to 5v, and you should get pulses out on black. The data sheet states that white and yellow are no-connections. I’d start by connecting it to power, and connecting a scope (preferably), voltmeter, or LED between white and blue. Slowly turn the shaft and see if there’s output. The description on the SparkFun product page states that it will provide 200 pulses per revolution, so it will be on for half of every pulse. You won’t be able to see that on a meter or LED, but it should be on for 50% of the times you stop turning, on average.

Once you get that far, connect it to your micro. You can either count edges (hopefully it has a debouncer inside) with an interrupt, with polling, or feed it into a counter that you check and clear once per second to get RPM. How fast do you expect the shaft to be turning? That would help decide whether you count edges per unit time or time between edges.

/mike

n1ist pretty much covered everything you need to know about this part. (Thanks Mike!)

Unfortunately we don’t have any example code on the website, but the code below should get you going.

/*
 * COM-10790 test code.
 * This sketch counts pulses from an encoder. The COM-10790 encoder only has one output so you can tell how far the 
 * encoder has rotated but you can't tell what direction the encoder has traveled. This encoder will pulse 200 times per
 * rotation so one full revolution in a single direction will should give you a value of 200 on the serial monitor. 
 * 
 * Setup: 
 * Blue = GND
 * Brown = +5V
 * Black = D2
 * 
 */

volatile int IRQcount;
    int pin = 2;
    int pin_irq = 0; //IRQ that matches to pin 2

    void setup() {
      // Put your setup code here, to run once:
      Serial.begin (9600);
      attachInterrupt(pin_irq, IRQcounter, FALLING);
    }

    void IRQcounter() {
      IRQcount++;
    }

    void loop() {
      detachInterrupt(pin);
      Serial.print(F("Counted = "));
      Serial.println(IRQcount);
      //delay(100);
    }

You shouldn’t need a resistor but if you’re having trouble reading pulses, try adding a 10K pullup between D2 and 5V and that should get you going. :slight_smile: