Shop OBEX P1 Docs P2 Docs Learn Events
Using the mouse.spin and Mouse Hardware for a Motor Encoder?? — Parallax Forums

Using the mouse.spin and Mouse Hardware for a Motor Encoder??

edited 2006-11-29 16:52 in Propeller 1
I was thinking about this idea...· I don't know if there is similar information posted in this discussion forum, but I thought that if you can remove the wheel encoders and the sensors·from the mouse, attach it to the back of the motor, then connect the sensors to the mouse's PCB and then hook up the mouse to the PChip,· you will have a speed/direction wheel encoder· for·up to three servo or dc motors (x-axis wheel + y-axis wheel + scroll wheel),· plus· three additional button sense ( right-click + left-click + scroll-wheel button)··all data pre-packaged by the Mouse's IC· and interfaced to the PChip· through just two pins (Data and Clock)··and··Mouse.Spin··· wohoo !!...· simple and efficient.....·· turn.gif

Comments

  • GavinGavin Posts: 134
    edited 2006-11-29 01:23
    Great idea, could you use optical 800DPI mouse as a DRO scale?
  • BTXBTX Posts: 674
    edited 2006-11-29 01:39
    Joe.
    You'll have two basic problems:
    1- The mechanical parts of the mouse "encoder" will not support the speed the motor·in a short time, and they will break.
    2- I you use an optical mouse, dissasembly it, and have the good luck to find the A signal and B signal in the mouse chip (like the industrial encoders signals). It will work fine as an example, but you'll have several errors in the positioning, since the opticals mouse sensor is not designed as an exactly optical encoder, in others words, not all times it will count for the same values, after one turn of the motor.

    But you could try this (2nd option), get the propeller code fine,·and then replace the encoder for a real one.yeah.gif
    Regards.
    Alberto.
  • edited 2006-11-29 03:32
    Thanks for the feeback!!

    BTX, thanks for the information... Actually, my idea behind it is to be able to tell the RPM and direction of a motor by constantly reading the delta_x or delta_y through the mouse.spin object.... I totally understand what you are saying about the quadrature encoder, but the idea was not to simulate the precision of a real Phase A Phase B encoder, but as a RPM counter and direction sense, it can easily suit the need for Low RPM counting for the final shaft of a gearhead motor or a Servo Motor..... tongue.gif

    Here is a simple example that I just tried, I actually opened the mouse and forced the wheel encoder to rotate continuously and ran this little code:

    CON

    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000


    OBJ

    term : "tv_terminal"
    mouse : "mouse"


    PUB start

    'start the tv terminal
    term.start(12)
    mouse.start(24, 25)

    repeat

    term.out($00)
    term.str(string("Reading mouse data"))
    term.out(13)
    term.out(13)
    term.str(string("Delta_X Delta_Y "))
    term.out(13)
    term.dec(mouse.delta_x)
    term.str(string(" "))
    term.dec(mouse.delta_y)
    waitcnt(9_000_000+cnt)


    The beauty of it is that the code already exists in the form of mouse.spin, it gives you not only the Delta Axis count that you can easily convert into RPM if necessary, since the delta_x and the other delta values have a sign, you can also sense the direction of rotation of the motor........ and the hardware exists in the form of old mice that we always find around, the real difficulty is to remove the sensors and then place then accurately facing each other in front of the encoder wheel. So my approach would be to obtain two identical old mice, and take one and with a plier or a dremel, carefully cut off the whole Infrared transmitter/receiver assembly from tne PCB, this way, no precise alignment of the receiver/transmitter will be necessary later, and then, carefully remove the receiver/transmitter from the remaining working mouse, and then interconnect the cut off receiver/transmitter assembly to the working mouse.. as a added bonus, this idea also allows us to sense up to five buttons in the mouse and it only uses two pins in the propeller!! I will try this idea next week and I will let you know... shocked.gif

    Post Edited (Joe "Bot" Red) : 12/1/2006 5:28:04 PM GMT
  • BTXBTX Posts: 674
    edited 2006-11-29 03:52
    OK Joe.
    Buy why don't you ese an optical mouse ?, all you need more, is to add a wheel in back of the motor (if has back axis) or in the fornt of it axis, and let the optical mouse near the wheel, you'll get the delta_x and delta_y without dissasemble it.

    Regards.
    Alberto.
  • Dennis FerronDennis Ferron Posts: 480
    edited 2006-11-29 07:20
    I wonder how hard it would be to add some lenses to an optical mouse to extend it's range out to 6 or 8 inches? Then you could tell a robot's speed from the ground underneath without any contact.
  • GavinGavin Posts: 134
    edited 2006-11-29 07:30
    Laser mice have higher resolution, is that just due to speckle?
    For longer distance telephoto type lens?
    opto mice are getting cheap enough to pull apart, less in them so less hacking fun?
    Better grab some ball mice before they become extinct.
  • edited 2006-11-29 16:52
    Hey Fellas, talking about optical mouse utilization, look at this approach:

    http://www.contrib.andrew.cmu.edu/~ttrutna/16-264/Vision_Project/


    BTX, talking about the A and B encoder, how about using two sets of the sensors from the mouse, position them at the typical 90 degrees, use a transparency sheet for printing the encoding wheel, then feed the sensors back to the mouse's PCB, and use mouse.spin for reading the values??.. since both A and B sensors will be read through the mouse's IC, the sensors data will be synchronized... Am I hallucinating?·· turn.gif

    Post Edited (Joe "Bot" Red) : 11/29/2006 5:41:29 PM GMT
Sign In or Register to comment.