Shop OBEX P1 Docs P2 Docs Learn Events
Using a Laser Mouse as Position Sensor — Parallax Forums

Using a Laser Mouse as Position Sensor

Kirk FraserKirk Fraser Posts: 364
edited 2012-03-12 20:00 in Propeller 1
Where can I get details on how to use a Laser Mouse as a position sensor? I see a laser mouse is supposed to be able to track 2000 DPI which should provide more accuracy than a 10K pot such as those sold by DigiKey for position sensors. How do I decode the laser mouse signal in a Propeller? Is there open source laser mouse driver software?

Also, what does one do if one wants to sense motion in the opposite direction? Can a laser mouse sense the change?

Thank you.
«1

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2012-03-07 18:26
    Parallax sells a mouse sensor kit (http://www.parallax.com/Store/Accessories/HumanInterfaceDevices/tabid/822/ProductID/677/List/1/Default.aspx?SortField=ProductName,ProductName) which I have and like. It has essentially the same innards as a computer mouse, but it has been made much easier to use from a microcontroller. Plus they have sample code available so soldering it is the most time consuming part.

    My project with it was to use it for odometery which sort of worked and I've been meaning to write up my findings. But I haven't had the chance.
  • TubularTubular Posts: 4,706
    edited 2012-03-07 18:45
    I second that - buy the Parallax mouse kit, you just use the standard mouse object that is in the obex to read the values out. It has X and Y axis values available separately, and yes it goes backwards if that is what you mean.

    The mouse sensors are not designed for perfect repeatable precision - ie if you are repeating a motion back and forth the absolute value might slip a little depending on the surface roughess etc. This doesn't matter for normal mouse operation as the human compensates based on the position on the pointer, but for your application it may matter.

    For absolute accuracy there are other options - you're using a 10k pot so I guess its rotary position you're trying to sense? Or are you using a linear pot? For rotary encoders are a better option, and for linear there are things like LVDT etc. You need to give us more info
  • ercoerco Posts: 20,259
    edited 2012-03-07 18:46
    I kinda wanna hack an old optical mouse to see how well a BS2 can read 2 quad encoders. Move the mouse, drive the robot. Something like that.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-07 19:04
    I'm trying to sense rotary angle position for a robot. All pot devices I've tried have accuracy problems - sometimes jumping from say 1000 to 8000 in the next fractional movement. I'm hoping for a laser mouse instead of an optical mouse based on http://reviews.cnet.com/4520-10166_7-6419059-1.html which indicates greater precision. I may have to continue using a pot to give me position repeat-ability by tossing the bad pot data when it doesn't conform with the mouse data but accepting it when the mouse might have slid a few notches. The biggest overall problem is size - for a robot finger you can't use a huge rotary encoder. I can use the 10K pot size but I can't deal with the inaccuracy. However, the Parallax optical mouse kit looks like an easier place to start, thanks.
  • TubularTubular Posts: 4,706
    edited 2012-03-07 19:10
    Have a look also at rotary encoders, these are about the same size as a pot but give you much better, digital results. Up to 20,000 counts per revolution apparently, but commonly a few hundred counts per rev.
    http://www.mouser.com/Electromechanical/Encoders/_/N-39xfc?Keyword=rotary+encoder&FS=True

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-07 19:17
    What about a rotory encoder? I think they make much better knobs than pots. Parallax sells one. SparkFun has several versions. They all include a push button. I've used this one a bunch of times. They also sell some clear encoders. Including ones with RGB LEDs.

    Don't forget to buy a knob to go with the encoder.

    Edit: Tubular beat me to it. SparkFun also sells a 200 pulse/rev unit.
  • ercoerco Posts: 20,259
    edited 2012-03-07 19:24
    The Prop demo board has a mouse and keyboard sockets onboard: http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/340/Default.aspx?txtSearch=prop+demo

    I've heard that Arduinos can read a standard mouse pretty easily.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-07 19:33
    A rotary encoder only has a few hits per rotation unless you go way up in price. What about an LVDT which is a coil around a movable wire, where the whole thing is bent into a curve? I don't need full 360 degree response but 180 to 270 would be nice. The fingers may need just over 100 degrees. Is there information on getting LVDT data into a Propeller?
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-07 21:02
    I can construct what appears to be a simple LVDT wrapping copper magnet wire around steel construction wire, with a thin temporary spacer like paper or tape. Do I need to magnetize the steel wire? If I do then I should have a device which can measure induction based on the length of the wire inserted into the coil. Which axis needs to be magnetized? What circuit would appropriately amplify the coil output for a Propeller to measure? If a Propeller can detect the voltage directly or with a small circuit, this could be very reliable. Then bending it around a dime or something a little off-axis like a helix might then produce a good sensor as long as it was protected to prevent crushing the coil. A tip on interfacing a small coil to a Propeller would be helpful. Thanks.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-08 06:28
    I can construct what appears to be a simple LVDT wrapping copper magnet wire around steel construction wire, with a thin temporary spacer like paper or tape. Do I need to magnetize the steel wire? If I do then I should have a device which can measure induction based on the length of the wire inserted into the coil. Which axis needs to be magnetized? What circuit would appropriately amplify the coil output for a Propeller to measure? If a Propeller can detect the voltage directly or with a small circuit, this could be very reliable. Then bending it around a dime or something a little off-axis like a helix might then produce a good sensor as long as it was protected to prevent crushing the coil. A tip on interfacing a small coil to a Propeller would be helpful. Thanks.

    I know there's a metal detector object but when I looked at it was really complicated. A LVDT needs two coils and then you'd need to generate an AC voltage and then monitor the second coil's AC voltage. IMO, this is not a trivial task.

    I'd think you'd just want to spend a couple of dollars on a higher quality pot and use a high resolution ADC.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-03-08 06:48
    Optical mice use optical flow and estimation, they may give around 2000dpi but they are not repeatable.

    Rotary LVDT do exist.

    Magnetic encoder chips are quite cheap and can have crazy resolution.

    What is the application? You may find that the methods used in scanning mirror galvos are suitable, they use simple optical or capacitive sensors, quite a bit on the web to be find showing how.

    Graham
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-08 07:22
    Rotary LVDT do exist.
    I don't think Kirk was thinking of making a rotary LVDT. It sounded like he was thinking of making a linear one.
    measure induction based on the length of the wire inserted into the coil



    What do mean by a "magnetic encoder chip"? I use the rotary encoders I linked to earlier, but I'd also like to find a higher resolution solution that wasn't expensive.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-03-08 07:37
    post #9 suggests he wants rotary.

    Magnetic encoders are available from several suppliers in many forms, assembled like a pot and also as a smt chip and a magnet or as chips mounted on little boards:

    http://www.austriamicrosystems.com/Products/Magnetic-Encoders/Rotary-Encoders

    http://www.renishaw.com/en/magnetic-rotary-encoders--9801

    http://www.avagotech.com/pages/en/motion_control_encoder_products/magnetic_encoders/

    The chips alone are the cheapest option but considering the resolution, even the kits (mounted chip and magnet) are an OK price. The housed renishaw units will probably blow the bank though.

    They are absolute too which can be a bonus for many applications.

    Graham
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-08 07:49
    post #9 suggests he wants rotary.

    Right you are.

    Thanks for the magnetic encoder links. Those look very interesting.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-08 08:11
    Thanks to everyone! You've provided a lot of information to look up which is far more than I had before.

    One fellow suggested digital filtering to improve the potentiometer output but I don't yet know how to correctly do that. Averaging 10 measurements won't work as I've tried that and come up wrong. So it would have to be a filter that detects and rejects outlying results.

    If it was a big rotary table like they wrap marshmallow hay bales with, I could stick bar codes around it and use a bar code reader to tell where it was. But with a robot finger (the size of a human finger) there's not much room. I've been trying these two sensors
    http://search.digikey.com/us/en/products/SV01A103AEA01B00/490-2400-ND/588421
    http://search.digikey.com/us/en/products/EVW-AE4001B14/P12426CT-ND/637165

    I'll keep looking at the LVDT, digital filtering, and other options until I find something that works all the time.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-03-08 08:17
    I would not expect a lot from those devices. I'd seriously look at the magnetic options almost ideal as they are high resolution, digital and absolute and can be tiny!

    You say averaging is not working? You add up 10 measurements and then divide by 10? If that does not improve things you have some very serious outliers!

    Graham
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-08 08:28
    Graham, Yes, and yes. The magnetic devices you linked look good, I'll have to get one and try it, thanks. The adding 10 measurements and dividing by 10 does sometimes produce junk results with the potentiometer.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2012-03-08 08:31
    The adding 10 measurements and dividing by 10 does sometimes produces junk results with the potentiometer.

    That is either the potentiometer or a programming error. But the potentiometer would have to be really bad I would think one measurement would have to be really far off or all quite a long way off.

    Graham
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-08 08:32
    Kirk,

    Could you discribe your setup a bit more?

    What kind of resolution do you need? How are you measuring the pot's position?

    I just don't see why a decent pot wouldn't work. I've use pots for lots of things myself and they jump a little but not much. There are also other filtering tricks you could use besides just averaging. You could make sure a certain number of reading all agree within some predetermined threshold before acepting the reading as valid. (I could write a little demo code if you need it).

    Are you using an ADC chip or some sort of RC time function to read the pot?

    Are the pots you linked to the only ones you've tried?
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-08 09:27
    I've tried many kinds of pots, some have worse errors due to mounting nut tightness, shaft wiggle, and ground effects on a large piece of metal. The linked pots seem to avoid the shaft problems but something I've not identified puts them off occasionally.

    I'm using a 0.1 cap to get RC time and a MCP3208 to read it into a Propeller. I'm currently on a solderless prototype board with a small aluminum rod providing the shaft and knob function. When I turn it by hand, sometimes it jumps around too much, like 1000 ohms to 8000 in a degree or so turn. I'm hoping for 12 bit but will settle for 10 bit. That makes the Hall Effect devices with 13 bits look good.

    The new filtering trick would have to move the threshold along so no value enters that is more than say 10% different from the prior accepted value, unless the appropriate time has passed to make it possibly valid.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-08 09:58
    I'm using a 0.1 cap to get RC time and a MCP3208 to read it into a Propeller.

    I don't understand this. Usually one uses RC time with a cap OR a MCP3208. Not both.

    Here's a schematic I copied from one of the MCP3208 objects.
    *************************************************
        MCP3208 ADC Schematic
    *************************************************
          Vcc(+2.7V to +5.5V)        Vdd(+2.7V to +5.5V)
          │           MCP3208        │
          │                          │ 
      ┌───┫      ┌────────────────┐  │ 1µF             1µF capacitor is used to keep power clean
      │   ─────┤1 CH0    Vcc  16├──┻──────── Vss
      │   │      │2 CH1    Vref 15├──────────── Vref(+2.7V to +5.5V)
      │   │      │3 CH2    AGND 14├──────────── Vss
      │   │      │4 CH3    CLK  13├──────────── P1
      ──┼──────┤5 CH4    Dout 12├─────┐          
      │   │      │6 CH5    Din  11├───────┻──── P2    
      │   │      │7 CH6    !cs  10├──────────── P0   
      │   │      │8 CH7    DGND  9├──┳───────── Vss    
      │   │      └────────────────┘  │                1LSB     = Vcc/4096 
      └───╋──────────────────────────┘
          │                                            Pots are 10K and resisters are 3.3K
          Vss                                          if using more than 3.3V.
    
    

    The schematic shows two different pots being used. The wiper from the pot is connected to one of the ADC channel pins.

    How does your setup differ?
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-08 10:11
    Duane Degn wrote: »
    How does your setup differ?

    The line between wiper and chip is connected to ground through a 0.1 capacitor.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-08 10:16
    The line between wiper and chip is connected to ground through a 0.1 capacitor.

    I'm not sure, but this might be the source of most of your trouble. This might interfere with the way the MCP3208 measures the voltage. Again, I'm not sure about this but I haven't seen schematics that use a cap this way.

    Hopefully someone more knowledgable will jump in to clear it up. Until then, I'd suggest not using the cap (or using it on the Vdd pin if it doesn't already have a cap there).
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-08 10:28
    Taking the 0.1 cap out seems to give it more instability. With it in, I think I'm observing the angle of the shaft can change in my hands which can affect the reading. So I'm guessing that if I mount the pot in its eventual robot location where the shaft angle won't change during a reading, it may produce better results.

    However, the Hall Effect devices still look worth exploring. Some are even smaller plus another few bits more accurate.

    Thanks.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-08 10:58
    Are you using a cap on the Vdd pin of the MCP3208? I've found they can make a big difference on how the chip behaves.

    Do you get stable readings from the pot if it just sits there without being moved? If not, it might not be the pots fault.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-08 11:28
    Duane Degn wrote: »
    Are you using a cap on the Vdd pin of the MCP3208?
    Yes, but I'm not using a separate Vref supply.
    Duane Degn wrote: »
    Do you get stable readings from the pot if it just sits there without being moved? If not, it might not be the pots fault.

    The unmoved pot readings are stable in the largest two digits for example varies between 8434 to 8454. That's only about 8 bits of accuracy. So the Hall Effect devices are looking better!
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-08 11:33
    Yes, but I'm not using a separate Vref supply.



    The unmoved pot readings are stable in the largest two digits for example varies between 8434 to 8454. That's only about 8 bits of accuracy.

    I never use a separate Vref myself. Those numbers just don't seem right. It seems like there's some noise causing the touble and not just bad pots.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2012-03-08 11:44
    I had thought about trying an optical mouse to track a xy table but I have seen nothing but bad comments and warnings about it. So I am now goung to try letting in the rotary wheels from a ball mouse into the ends of the screw feeds.

    I will have to experiment on the pulse losses when there is a start, stop or reverse but hopefully they shouldn't be too numerous or random. I will send it back and forth loads of times and check on its return accuracy.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-08 11:50
    Duane Degn wrote: »
    Those numbers just don't seem right. It seems like there's some noise causing the touble and not just bad pots.

    It's possible my math is off. 843 to 845 might be less than 8 bits accuracy. These low accuracy figures have been fairly consistent with any of my pots including brand new pots over several years using Stamps as well as Propellers on different computers. I suppose that's accurate enough for an Abio dog leg but for a human type finger I'd like to see human style accuracy, which I've read can be 1/32K.
  • Kirk FraserKirk Fraser Posts: 364
    edited 2012-03-11 05:00
    Graham,

    I looked at your links for a Hall effect sensor and ordered three from Digi-Key to test. The package arrived sealed with a desiccation package and moisture indicator. This is unusual for electronics I've ordered so I'm concerned what that means. Will I be able to use it in a rainy environment? Or any environment that isn't hermetically sealed and moisture free?

    The item ordered was RS5055 which is a good size for small spaces available. However unless you can guide me to confidence in the moisture situation, I'm thinking LVDT is the only way to potentially get more than 8 bits position precision in an outdoor environment.

    Thanks,
    Kirk
Sign In or Register to comment.