Hi, I am new here. I've got a problem with a project I am doing: I have a DC motore with an optical encoder, here the encoder datasheet:
I dont know how to wire the encoder :
1: Cathode ( is it output or input? what should i send/read? analog /digital??)
2: Anode ( same thing)
3: speed ( i presume this is a input, should I read a digital value or analogic?)
4: Gnd (Im ok on this one)
5:Vcc ( im ok on this one too, wire it on 5vdc, datasheet say 5.5v....but....)
6: Direction (analog or digital input?)
Can you help me on what these value should look like, I am a little lost..... Thank you very much arduino is fun.
The Anode (+) and Cathode (-) are the leads of the IR LED. Use a current limiting resistor as you would for a typical LED.
The 'speed' output pulses twice for each slot in your slotted disk.
The 'Direction' output will tell you which direction the motor was moving when the slot went by.
johnwasser:
The 'speed' output pulses twice for each slot in your slotted disk.
Read up on pulseIn() or the PinChangeInt library; you'll want to measure the time between the two pulses to determine the speed. It's not very clear how that would work programatically because, if the sensor is outputting high normally and blinks low at the beginning and end of an interrupted light beam, how do you tell if you're measuring the length of a blocked or unblocked beam?
Honeywell has the worst documentation for its stuff.
chezbob:
I mean anode to 5vdc and resistor, and cathode to the gnd?
Yes. They don't specify a forward voltage drop so I'm guessing roughly 1 V. That leaves 4 V across the resistor. At that voltage a 1000 Ohm (1k) resistor would pass 4 mA which is a bit low. To get the typical 20 mA you would use 1/5th the resistance or 200 Ohms. I think the closest common resistor is 220 Ohms (Red Red Brown).
I think I found a better datasheet for this sensor.
johnwasser was pretty spot on about the specs.
It looks like the recommended current to the IR LED 15mA. From the graphs, it looks like the forward voltage is pretty close to 1.2V (this varies with temperature and the current passing through the LED.
I bet a 220 ohm current limiting resistors would be fine but I calculate (5V - 1.2V) / 0.015A = 253 ohm which is closer to 270 ohm. As I said, I don't think 220 ohm would be a problem for the sensor but 270 is closer to the recommended value.
This is a really interesting sensor.
It appears to have most of the advantages of quadrature encoders but it should be a bit easier to read than quadrature encoders.
The low pulses are pretty much all the same duration. You could calculate speed but timing a full encoder period of two low pulses and two high pulses. The two low pulses of an encoder cycle should both have about the same duration. The two high pulses will likely have different durations.
The slots in your encoder disk should be at least 0.457mm wide with the total encoder cycle (slot plus non-slotted area) should be at least 0.914mm.
I couldn't find these on ebay. They cost more than $10 at Mouser in single units. I'd be curious to try these sensors but I don't think I'd want to spend more than $3 on one.
If any of you know of an inexpensive source for these sensors, I hope you let us know.
Interestingly you could wire its outputs to a stepper driver like the DRV8825 and have the stepper
follow the rotation of the encoder's shaft rather nicely!
A long time ago, shortly after the asteroid wiped out the dinosaurs, we used to have mice without optical sensors. They had a rubber ball that rotated two orthogonal shafts with interruptor disks running through exactly such a sensor. Who remembers periodically scratching the muck build-up off the shafts and hiding the balls or taping them as an office prank? Good times!...
Since the analog capable pins are also digital pins, yes - just use digitalRead() on their unique
names (A0, A1 etc). Using 0, 1 for analog pin numbers only works for analogRead(), note.