I've got the optical sensor in the photos
It comes from an interactive R2D2 unit which I am modifying with Arduino Mega.
I did hours of web searching but I couldn't find anything.
I really need to understand the its wiring (5 wires) to use the Arduino Mega to control r2d2 Dome, which originally read the gear in the photo.
Please also at least a basic code to control optical sensor would be great
Can you provide a picture of the back of the circuit board - that's where the wiring is.
Its three opto sensors (2 for quadrature, 1 probably for an index mark (is one of the black teeth
on the plastic ring longer than the others?). The three IR emitters may be in series, so only one
power connection for them, one for ground and three for the photo sensors (probably phototransistors,
in the last photo there is the original r2d2 board.
where you read r6 is the 5 wire sensor connector, you can see going to vss of the pics, hope it helps.
2 more hope they help
it's not clear if they are in connected series
It appears to be a quadrature encoder (two photointerrupters) with an additional photointerrupter that is probably used to find an indexing hole to "zero out" R2's head and make sure it's facing forward when powered on. There's an extra hole somewhere in that slotted disc, right?
One wire will be power, another GND, and then three of the wires will report high voltage when something is blocking them and low when there's a slot. Those three signal wires appear to be the red and grey (for the encoder) and the blue (for the index hole). Purple appears to be the GND and that leaves the power wire as brown. The power wire branches into three through the resistors to one side of each of the IR emitters.
There are lots of tutorials on how to use phototransistors with an Arduino. Those tutorials will help you understand the wiring. Also, be very careful when supplying power; if you feed the infrared LEDs too much current you'll burn them out. 5V should be OK as the "122" resistors (1200 ohms) would limit the current to 4ma per LED. Remember that a digital camera will detect infrared light; look at it with your camera and you should be able to see when the IR leds are lit.
Thanks a lot you have been super helpful
Hi Chagrin, You were absolutely right on the wiring
only the power cable brown seems to be the ground!
BTW my camera doesn't show any infrared light on.(camera works, tested with TV remote control infrared light visible).
my problem is that the digital outputs from encoders level are just 0.5 V(0=0.6 V and 1= 1.1 V)
which it is not enough for digital arduino levels(1=5V)
I am measuring this values set it up on DC voltage with a Fluke professional tester.
Also if I apply 9V power the digital range still 0.5 V (0=2.6 V and 1= 3.1 V)
ok you were totally right on the wiring and now I can see also the infrared with my camera.
Is it possible that to read the outputs I have to set pins input high?
Let me try to explain better
outputs from encoder seem to go on negative side but the variation is just -5 mV to 0.(this is real reading)
analoRead on my arduino input pins is 303 on all 3 inputs.
digitalRead is always 0 on the arduino inputs.
so infrared led are ON and there is no digital status change on the optical sensor outputs(0 to 5v).
See When page is bookmarked, text here is referenced verbatim for the basic theory. You'll need a resistor on the collector side of the phototransistor. So try a 33K resistor from 5V to your input (or the meter's positive lead) and then connect the red, grey, or blue wire to that same input. Try various resistor values between 10K to 47K to see which works best.
i was in doubt to do that or put a transistor for each one.
When you say to connect the 3 wires to the same input do you mean to test it?
I would use 3 arduino pins to control the motor because one is the "zero" position.
Hi again Chagrin
after hours of searching I couldn’t find a right code .
You know the encoder I have
Motor Driver 1A Dual TB6612FNG
My goal is positioning
I need to know where the motor is constantly.(r2d2 dome)
I found a lot of codes to read rpm but nothing about positioning.
You know also my gear as that “ZERO DENT” .
Can you please give me suggestion? code? link?