Optical Encoder hacked from a mouse, output issues!

Discussion in 'General Electronics Chat' started by Frakk, Dec 13, 2009.

  1. Frakk

    Thread Starter Active Member

    Jul 6, 2009
    40
    0
    I found an old mouse with a ball and x/y optical encoders that I decided to sacrifice in the name of science.

    I used this guide and the circuit around the IR LED and Transistors:
    http://users.on.net/~merrifield/opto/index.html

    In the mouse they have the 2 LEDs in series with a 85ohm resistor on 5V, the LEDs Vf is about 1.25V. Calculaced the current through them to about 30mA, so I used 220ohm with 1 LED for about 17mA current. LED/Resistor + Opto Transistor with a 4 pin connector is soldered on a piece of perfboard, the wheel is held in place with the plastic stands from the mouse.

    This is where I start to get problems. I can't seem to have a stable output from the transistor pair only if I use a 74hc14 inverting schmitt trigger as a buffer, and take the output from the IC. I have tried different value pulldowns, series resistors, 2N3904 NPN, bs170 N-FET transistors, but my output with them is unreliable and triggers erratically.

    Anyone worked with this type of encoder hardware? I would appreciate your experiences and suggestions!
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Ambient light will really goof you up. The IR receiver won't be able to tell the difference between ambient light and the IR illumination.

    One way to get around that is to simply enclose the IR emitter and receiver in a light-proof material.
     
  3. Frakk

    Thread Starter Active Member

    Jul 6, 2009
    40
    0
    I will try to cover it up with a paper box, but I don't think ambient light can have such a great inpact on the operation as it is not changing at all. It works perfectly with the buffer IC, but not with the uC's schmitt triggered inputs.

    I checked the datasheets, the 74ahct14 has a logic low threshold of 0.5V and logic high at 2V. I use an Atmega48 to process the signal and it's inputs have Max Input Low of 1.5V(0.3Vcc) and Min Input High of 3V(0.6Vcc). I suspect the problem is right here.

    I am measuring between 0.6V and 2.8V at the input of the Hex Inverter but it is probably oscillating, and as soon as I connect the DMM it goes nuts again. I need to somehow condition the signal coming from the Opto Transistors but I don't know how.
     
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Since speed is probably not that critical for your application you may be able to put a 0.01 ufd capacitors and a 100 ohm resistor in series and then take this and put it in parallel with the 10K resistors that are in the collector loads of the two transistors. This will form a low pass filter and cut down on some of the noise.

    hgmjr
     
  5. Frakk

    Thread Starter Active Member

    Jul 6, 2009
    40
    0
    Speed can be critical, I haven't made any calculations for the frequency and max rpm yet, just want to get it working for now. I want to use as few components as I can. I will try to lower the wheel so the slots move perpendicular to the opto transistor, right now the center of rotation is slightly above the sensors. Maybe that will make it a bit more stable.

    Thanks for your inputs!
     
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Do you have the unused inputs to the 74AHCT14 IC connected to ground or Vcc, either directly or via a resistor? They will likely cause big problems if they are left unconnected.

    Do you have a small cap (0.1uF) across the power/ground pins of the 74AHCT14 IC? That's pretty much mandatory.

    It would also help to have a cap across your receiver resistor/transistor combination.

    If your connecting wires are long, you could be picking up electrical noise.

    Increase the current through your IR emitter. You said that originally the current was 30mA, and you're at about 1/2 that amount now. Decreasing the IR emitter current will have a big impact on how much current the output transistor can source or sink, however you have it configured.

    Also, if you are using the original IR emitter and detector that were in the mouse, keep in mind that they are much more than just emitters/detectors. There is a somewhat lengthy encoded stream of pulses that is output when a mouse is moved, that reports the relative and absolute positions.
     
    Last edited: Dec 13, 2009
  7. Frakk

    Thread Starter Active Member

    Jul 6, 2009
    40
    0
    I desoldered the IR emitters and the detector Transistors just like in the tutorial link I have in the first post. I am processing the grey code with the uC, so the mouse circuitry I only use for reference.

    I don't have the inputs of the 74ahct14 grounded, but I have a 0.1uF cap across its supply. As I said, the encoder works perfectly like this, without transistors and only with the 4.7K pulldown / 1K series resistors on the two channels.

    I will rebuild the circuit tomorrow with a lowered center of rotation and an increased IR emitter current. Hopefully that will clear it up and I can connect it right to the uC.
     
  8. Frakk

    Thread Starter Active Member

    Jul 6, 2009
    40
    0
    I have rebuilt my second encoder with only the transistor and the IR led on it. I have tried numerous components and values on the breadboard and I couldn't make it any better. 0.1uF caps didn't help, increasing the LED current either.

    What really puzzles me is that the original mouse circuit didn't use any of these components. The two IR Leds are connected in series with a resistor, the two transistors' collector connected to Vcc, the 2x2 emitters connected to the ALH100JUP mouse controller IC. I would love to get a datasheet on this component but it is not public. If this this chip can do it, a microcontroller can do it! :D
     
Loading...