How to create encoder from two Optical sensors?

Jeez guys, I can add two sensors in one lane as well. That still doesn't change my initial question which half avoided and decided to debate on holes.

The simple issue is that I need two sensors regardless of how they are placed, but I don't have enough pins on my Arduino Uno left to connect double the sensors. This is a design for an SMT feeder and if I want to add more feeders, that takes up pins.

I honestly don't see how an OR gate would work in this application? Isn't that just CODE? I need to physically somehow combine via ICs or whatnot so I only have to route it to one pin.

Another solution I had was to route both sensors in parallel with all the other feeder sensors so that in the end, only 2 pins would go into the Arduino no matter how many feeders I have. As a result, I would only power up one feeder at a time. The rest of the feeders, no matter how the sprockets are positioned, wouldn't pulse anything since they are off and therefore I get two signals without interference.

But, I prefer to not do it this way where I have to power each feeder on/off because that adds more MOSFETs.

So, back to the original question of this topic, how can I by adding a chip or something merge two lower resolution waveforms into a higher resolution waveform? Ideas??

shai:
So, back to the original question of this topic, how can I by adding a chip or something merge two lower resolution waveforms into a higher resolution waveform? Ideas??

Mount the sensors on a single lane of holes, 90° out of phase, and then exclusive or their outputs together.

You lose the direction information, but this will double the resolution.

Pieter

PieterP:
Mount the sensors on a single lane of holes, 90° out of phase, and then exclusive or their outputs together.

You lose the direction information, but this will double the resolution.

Pieter

Thank you PieterP. I don't care about direction as I have a motor driver to determine that. However, being an amateur electrician, can you please elaborate 90 degrees out of phase & exclusive of their outputs together? If you don't mind posting a sketch of the schematic, that would help me understand how to wire them. Thanks!

This is my current schematic (left most symbol is just a connector):

These are your quadrature signals:

A   ┌─┐ ┌─┐
    ┘ └─┘ └─
B    ┌─┐ ┌─┐
    ─┘ └─┘ └
A⊕B ┌┐┌┐┌┐┌┐
    ┘└┘└┘└┘└

If you count one period (rising edge to the next rising edge) as 360°, A is leading B by 90°.

This means that when A is on the edge of a hole, B is over the middle of a hole.

PieterP:
These are your quadrature signals:

A   ┌─┐ ┌─┐

┘ └─┘ └─
B    ┌─┐ ┌─┐
    ─┘ └─┘ └
A^B ┌┐┌┐┌┐┌┐
    ┘└┘└┘└┘└




If you count one period (rising edge to the next rising edge) as 360°, A is leading B by 90°.

This means that when A is on the edge of a hole, B is over the middle of a hole.

Ok understood! Thanks. However, do I still need to connect two pins to the Arduino? I'm trying to only have ONE signal output from two sensors like your A^B wave.

You connect A and B to the inputs of an XOR gate, and the single output of the XOR gate goes to the Arduino.

The problem with this approach is that the backlash of the gear will cause it to move back and forth quickly when accelerating or decelerating, causing your Arduino to lose track of the position, because it receives a lot of pulses, and it doesn't know what direction it's moving in.

PieterP:
The problem with this approach is that the backlash of the gear will cause it to move back and forth quickly when accelerating or decelerating, causing your Arduino to lose track of the position, because it receives a lot of pulses, and it doesn't know what direction it's moving in.

I am thinking of using a geared N20 motor, so there's not much backlash there I would think, but need to test. If I move the sprocket slowly, I shouldn't have any skipped holes/pulses. Of course, going slow on a feeder is not the point :wink: But this I can figure out after the XOR issue.

Would this XOR gate work? https://www.digikey.com/product-detail/en/diodes-incorporated/74AHCT1G86SE-7/74AHCT1G86SE-7DICT-ND/2712002

shai:
The simple issue is that I need two sensors regardless of how they are placed, but I don't have enough pins on my Arduino Uno left to connect double the sensors. This is a design for an SMT feeder and if I want to add more feeders, that takes up pins.

Then you could go to a bigger chip -or- use "pin multipliers", aka port expanders or shift registers. That is how an Uno can drive an 8x8 RGB led square (256x3 pins) at 30+ FPS using the SPI bus (4 pins to control literally 100's).

SPI bus length is not so long as I2C but SPI is a lot faster.

Another option is to add controller chips in a modular design.