Using the optical sensor from a ball mouse


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2006
    Location
    Reading, UK
    Posts
    15

    Default Using the optical sensor from a ball mouse

    Hello,

    I'm trying to use the optical encoder from a ball mouse to make a cheap quadrature encoder for an electric motor.

    I've removed the part of the PCB with the LED and sensor, and wired them up the same way as the mouse. The sensor has three pins - +5V and two outputs. I've connected the outputs to ground via a 20K resistor and hooked up the 5V pin to my power supply. If I then measure the output from one of the sensor pins with a voltmeter I can see the voltage swing between about 1V and 4.5V as I block and unblock the sensor. But if then attach the output to an input on my PIC the PIC doesn't see any change, and the voltage on the pin only reaches a fraction of 1V.

    One of the websites I've seen on this topic uses a hex inverter, so I've tried this to see if it improves things. With this set up I get a very clean 0V or 5V when connected only to the voltmeter, but similar results as soon as I connect it to the PIC.

    I'm sure I'm doing something wrong that'll be obvious to more experienced readers. Any help is greatly appreciated.

    Thanks,

    Luke

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Check this thread out. http://www.picbasic.co.uk/forum/showthread.php?t=6826

    The current is very low from the photo diode in these parts.. Try pulling the PIC pin low through ( I use 10 meg ) or something close.

    The big thing will be ambient light. I use these for linear encoders for hydraulic rams and conveyor belts, how the covers are built is critical.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2006
    Location
    Reading, UK
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Ok,

    I've tried replacing the 20k resistor with 1M (largest I have to hand), and the results are much the same - a clear voltage swing when just connected to my voltmeter, but almost none when also connected to the pic.

    Have I understood your suggestion correctly? I've attached a (crude) diagram of my setup.

    Incidentally, I tried shielding the sensor from ambient light, but there was a negligible difference in readings.

    Thanks again!
    Attached Images Attached Images  

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Found the drawing of the two ways I have used these. The one on the left will take the PIC high, one on the right will take the PIC low.

    The part in the drawing is SHARP GP1S52VJ000F.
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1960&stc=1&d=118899175 9">
    Attached Images Attached Images  
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Luke

    I suspect that you've forgotten to make the PIC pins as inputs using the TRIS registers.

  6. #6
    Join Date
    Sep 2006
    Location
    Reading, UK
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Hi Jerson,

    You're absolutely right - that was the problem. What an incredibly stupid mistake! For anyone who's interested it now works fine with a 10k pull-down as in the diagram I posted earlier, or as in mackrackit's schematic.

    Thanks very much,

    Luke

Similar Threads

  1. 2 Beam Optical Pulse Generator
    By WOZZY-2010 in forum Schematics
    Replies: 8
    Last Post: - 6th April 2010, 04:03
  2. USB Optical mouse as motor encoder
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th August 2008, 15:09
  3. need help simulating PS/2 mouse
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th December 2007, 21:49
  4. ps/2 mouse
    By hamid in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd June 2007, 09:04
  5. My wish: AT Keyboard and Mouse commands
    By sayzer in forum PBP Wish List
    Replies: 0
    Last Post: - 4th February 2006, 08:23

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts