# Problem on an old optical encoder

#### brianon99

Joined Jun 20, 2022
9
Hi all, this is my first post. I am complete beginner in electronics, and have a problem in an old HOA902-11 optical encoder.

The datasheet can be found in attachment which I found in google.

This encoder is a part disassembled from a broken computerized telescope mount. I would like to reuse it. It is fixed on a motor, and an encoder wheel will pass through the encoder. As far as I understand from the datasheet, the encoder cosists of an IR LED (2pins for 1.5V max supply) and an IR sensor (which gives pulse signal when the wheel pass through, and another pin output direction). There are another 2pins for 5V and GND. I connected the encoder to raspberry pi as following:

The HOA902-11 encoder is located at the lower right under the motor.

The 4 pins for power supply are straight forward connection, except I added a 1k ohm resistor between the LED anode and raspberry pi 3.3V pin, and the cathode to rpi GND. The purple wire is connected between rpi pin 21 and the encoder direction or speed pulse output.

The following code is used for testing:

Python:
import RPi.GPIO as GPIO

BUTTON_GPIO = 21

GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

counter = 0

while True:
GPIO.wait_for_edge(BUTTON_GPIO, GPIO.FALLING)
counter += 1
print("Button pressed!", counter)
However, when I rotate the wheel by hand, the above test code gives no output, no matter if the encoder "direction" or "speed" pin connected to pin21.

Interestingly, if I use a TV IR remote to shine the encoder in certain angle, the code above will give output (about 100 signals per second), so I think the sensor is working. For the LED, I checked it with a voltmeter. There is 1.06V between the anode and cathode (which I don't know if it is normal or not).

#### Attachments

• 50.1 KB Views: 4

#### MrChips

Joined Oct 2, 2009
26,504
Welcome to AAC!

This would make the trouble shooting proceed a lot faster.

If there is no oscilloscope available then we will have to be resourceful and find other methods of testing this.
It is going to be difficult to test code if you don't know what the hardware does.

#### sagor

Joined Mar 10, 2019
704
Many older IR LEDs get weak over time and can no longer trigger the detector. Is there a change to change the IR/detector module. Are they separate components or one module? If separate components, you may try to replace the IR LED with a similar one.
Seems the HOA902-11 is a module, try to replace it if possible, I see a few online on places like Ebay.

#### brianon99

Joined Jun 20, 2022
9
Welcome to AAC!

This would make the trouble shooting proceed a lot faster.

If there is no oscilloscope available then we will have to be resourceful and find other methods of testing this.
It is going to be difficult to test code if you don't know what the hardware does.

Sorry I don't have an oscilloscope. All I have which may be useful are: a raspberry pi, a digital multimeter, and an Arduino nano.

Actually there are 2 set of HOA902-11, but I cannot make any of them work.

#### brianon99

Joined Jun 20, 2022
9
Many older IR LEDs get weak over time and can no longer trigger the detector. Is there a change to change the IR/detector module. Are they separate components or one module? If separate components, you may try to replace the IR LED with a similar one.
Seems the HOA902-11 is a module, try to replace it if possible, I see a few online on places like Ebay.
Thanks, Sagor. The IR LED and sensor is one component, and it is hard to replace only the LED with my limited skill. Buying one HOA902-11 is expensive in my country. Is there any other way of testing?

#### MrChips

Joined Oct 2, 2009
26,504
What is the make and model of your DMM?
Does it have a frequency measurement option?

#### brianon99

Joined Jun 20, 2022
9
What is the make and model of your DMM?
Does it have a frequency measurement option?
The DMM (MAS830L) is a basic one and I think it cannot measure frequency.

#### brianon99

Joined Jun 20, 2022
9
I have finally got it working. Thank you for all your help.

The breaking point is that I found another datasheet on the internet, which shows that 1.06V between the LED cannot trigger the pulse. (lower right graph below, the 25C curve, for 1.06V the current is way too small). Then I connected the LED pins directly to an 1.4V alkaline AA battery and every thing works.

However, I have another problem now. I learned from the arduino tutorial that connecting LED directly between pins may burn the circuit. However as I originally put a 1K resistor next to the LED and raspberry pi 3.3V, the voltage droped to 1.06V which is not enough. How should I configure the circuit now? (I don't want to keep the AA battery in my setup ) Thank you.

Last edited:

Joined Jul 18, 2013
25,469
You need ~ 220ohm resistor in series with the LED at 3.3v.

#### brianon99

Joined Jun 20, 2022
9
You need ~ 220ohm resistor in series with the LED at 3.3v.
Thanks for the advice. May I know how to do the calculation?

Joined Jul 18, 2013
25,469
Look at the specs for the max LED current, IIRC for this device it is max 50ma.
If you include the voltage drop of the LED, you should be able to go much lower in value.

#### brianon99

Joined Jun 20, 2022
9
Thanks. I get it. I will try it out.

#### panic mode

Joined Oct 10, 2011
2,170
the 50mA is the absolute maximum. this is on the edge of destroying product and should never be used.
datasheet tells test condition used 20mA for IR emitter. at this current forward voltage is about 1.2V.
So you get

(3.3V -1.2V)/20mA = 105 Ohm
so choose nearest value and that would be 100 Ohm (alternatively 120 Ohm).

#### brianon99

Joined Jun 20, 2022
9
the 50mA is the absolute maximum. this is on the edge of destroying product and should never be used.
datasheet tells test condition used 20mA for IR emitter. at this current forward voltage is about 1.2V.
So you get

(3.3V -1.2V)/20mA = 105 Ohm
so choose nearest value and that would be 100 Ohm (alternatively 120 Ohm).
Thanks. I have ordered some 100ohm resistor and will try it later.