Shop OBEX P1 Docs P2 Docs Learn Events
Prop as mouse — Parallax Forums

Prop as mouse

janbjanb Posts: 74
edited 2007-08-05 21:14 in Propeller 1
Hi,
I'd like to interface my 'custom made mouse'· to· a regular PC using the USB port.

The· 'custom made mouse' is another Propeller project I'm working on now (not finished), the details are irrelevant here.
What is important there will be 5 variables on the HUB : dx, dy,but1,but2,but3· holding intended change in X,Y directions, and bool values of the 3 buttons.
Those variables will be updated at ~20 Hz by one of the cogs.

I'd like to pass this 5 variables to a PC pretending it is some generic mouse and have a simple USB plug from the propeller to PC.
What would be the best solution?

I have read a bit about the USB interface and do not want to take the challenged of building full blown USB interface· from scratch.
Rather I'm considering a $5 solution:
- buy the simplest possible non-optical USB mouse (mechanical, with a ball rolling on the surface)
- connect· via 100 Ohm resistors 3 buttons to 3 Propeller pins to pass variables: but1,...but3
- mouse has a pair of photo-resistors· to· detect· the ball rotation in each direction.· I could· connect 2 LED (per direction) to the Propeller and sent 'dx'· pairs pulses to imitate movement of the mouse.
- change of relative phase between 2 LEDs· will be interpreted as direction (+ or -) of mouse movement

This is very clumsy, needs 7 pins, but should work w/ any PC w/o bothering to write a custom driver. And the total cost should be very low.·

What do you think?
Jan

Comments

  • RinksCustomsRinksCustoms Posts: 531
    edited 2007-07-29 16:11
    This seems very feasable indeed, from an EE point of view. If you have access to an osilliscope it will be a huge headache saver. As i understand it, most of the mechanical types use a 2 bit grey encoder so emulation by the propeller should be fairly easy to accomplish. Be sure you do not need a level shifter ie- the propellers 3.3V logic level to a 5V logic level. You didn't specify if resolution/speed was an important factor. If these are desired you'll need an osilliscope to determine the frequency at which the mouses interface scans the sensors, you will need some way to sync the two. Syncronizing the props emulation output to the mouse interface will give your project maximum interface speed and increase acuracy. There are many different methods you can use for syncing the prop with the mouses interface.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-07-29 18:14
    Should work with no problems, you might as well wire straight to where the phototransistors (probably not LDRs) go to the mouse interface, you just need to work out the circuit should be very simple.

    No need for a scope to work out pulse frequencies you can get those from the ball/roller diameters and the number of slots in the wheels, not that you need to worry anyway as they will handle any pulse rates likely to be seen in mouse use, if your system is higher resolution you can add a divide ratio if you wish.

    Graham
  • janbjanb Posts: 74
    edited 2007-07-30 00:33
    Hi,
    thanks for all advices.
    this was simpler then expected.

    Found some old mechanical PS2 mouse in·my basement and hookup 6 x100 Ohm resistors to
    - L & R buttons
    - 2x2 optical sensors output for X & Y wheels
    To save Prop pins I used shift-out register SN54HC595, so only Prop 3 pins were needed. Pulses are injected in parallel to optical sensors outputs, at 1KHz.
    The whole assemble is on the photo.
    Attached movie demonstrates Prop calculating log(105) using calculator window. At first it clears old calculation,· enters the formula, at the end it kills the window.
    Of course I have positioned the cursor at the '=' button by hand

    Movie on YouTube :
    <object width="425" height="350"> <param name="movie" value="http://www.youtube.com/v/I-jaSlxkdz4"> </param> <embed src="http://www.youtube.com/v/I-jaSlxkdz4" type="application/x-shockwave-flash" width="425" height="350"> </embed> </object>
    Jan
    2832 x 2128 - 1M
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-07-30 00:41
    spooky

    Well done.

    Graham
  • RinksCustomsRinksCustoms Posts: 531
    edited 2007-07-30 05:32
    Graham Stabler said...
    Should work with no problems, you might as well wire straight to where the phototransistors (probably not LDRs) go to the mouse interface, you just need to work out the circuit should be very simple.

    No need for a scope to work out pulse frequencies you can get those from the ball/roller diameters and the number of slots in the wheels, not that you need to worry anyway as they will handle any pulse rates likely to be seen in mouse use, if your system is higher resolution you can add a divide ratio if you wish.

    Graham
    What i was trying to get at was using an oscilliscope on a sensor pin, like button one, and measure the frequency that the interface probes it, you can adjust the propellers code for maximum speed. Using button·three for sync on the prop (grey code) maximum syncronous communication can be achieved easily, if one needs absolute bandwitdh with this kind of interface.

    OK, i'll byte... How do you achieve the polling frequency with ball/roller diameters? Does this formula require magic smoke? lolconfused.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-07-30 08:43
    There is no need to find the maximum speed it polls it because as he is interfacing with a special homemade mouse the signals to the PC via the scrapped mouse do not need to be any higher frequency than they would be for the scrapped mouse.

    You don't need to adjust the propeller's code for maximum speed because the speed of the pulses should be goverened by the speed the custom made mouse is moved by the user.

    If you did care about getting maximum speed you could always just keep cranking up the speed until it didn't work, that is no less scientific than using a scope to find out when it has stopped working.

    Graham
  • rjo_rjo_ Posts: 1,825
    edited 2007-07-30 22:53
    JanB...

    Let me get this straight... you are emulating a mouse... with a propeller... hooked up to a mouse... to control a generic application on a PC?

    This is better than "QuicKeys" www.quickkeys.com

    Pure genius only comes in one form. Is this a project or a product?


    Rich
  • hinvhinv Posts: 1,253
    edited 2007-07-31 02:44
    This is a great idea!

    Care to share the schemat and code?
  • RinksCustomsRinksCustoms Posts: 531
    edited 2007-07-31 06:56
    Graham, USB mice are capable of very high speeds and such if you wanted to make a macro function and have it execute that macro ie- add, cut, extrude, subtract, & recenter which are common commands in CAD you would want the highest speed possible, this would hold true to programs that didn't have keyboard shortcut keys. As an EE (even if i am a novice or just higher) IMHO the "poke-n-hope" approach doesn't fly by my standards or teachings.

    If speed isn't a factor, as would be the case for handicap accessibility, then i'm sure this setup will work fine. This hack has potential though, in a syncronous config, you could interface the prop to a sensor like a gyro/accelerometer and with the addition of a few buttons you could use the interface as a controler for a game or two gyros for an FPS controller.

    Hey, you know what Graham, whatever! I can see this turning into a peeing contest before long, you win. You wanna shoot down my ideas, go ahead.. but my mill is bigger!turn.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-07-31 09:20
    Look he asked about a custom made mouse not a macro generator even if that was his little example to show it works.

    Not knowing if he was a beginner or an expert I thought it was a good idea to let him know he could get his project working without a scope and without worrying about these details. It was about him not you.

    I'm really not getting what this synchronous thing you are talking about is, there is the coms between the mouse and PC but that is most likely driven by the mouse movements rather than polled isn't it?

    I don't know what shooting down someones ideas is, either something is correct or incorrect or I agree or I disagree, sometimes those two things don't tally (I get it wrong) but that's easy to fix through communication. If you think everything you write is sacred and should not be challenged then I suggest you write a blog and leave the forums to those with smaller but more capable mills [noparse]:)[/noparse]

    Graham
  • inakiinaki Posts: 262
    edited 2007-07-31 09:29
    Sorry, I don't understand the use of this device :-(
    Which is the goal of such a device ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • StefanL38StefanL38 Posts: 2,292
    edited 2007-07-31 10:38
    hello,

    just googled a little bit about the PS/2 mouse protocol / mouse scancodes


    that's what i found quickly

    http://www.win.tue.nl/~aeb/linux/kbd/scancodes-13.html

    http://www.computer-engineering.org/ps2mouse/

    http://www.computer-engineering.org/ps2protocol/

    greetings

    Stefan
  • janbjanb Posts: 74
    edited 2007-07-31 12:50
    Hi Guys,
    I'll share code & schematics in 1-2 days,
    first come duties, fun is next - this is my toy
    sorry
    Jan
  • janbjanb Posts: 74
    edited 2007-08-01 02:50
    Hi,
    I got the code cleande up a bit. Below is schematics
              to propeller
               &#9474;  &#9474;  &#9474;  &#9474;
               &#61628;  &#9474;  &#61628;  &#61628;
         &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9532;&#9472;&#9472;&#9532;&#9472;&#9472;&#9532;&#9472;&#9472;&#9523;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
      Vcc&#9474;    SER &#9474;  CS &#9474;  &#61628;20k&#937;   &#9474;
         &#9474;  A  &#61602; GND &#61602; CLK &#9474; free  &#9474;
        &#9484;&#9524;&#9472;&#9472;&#9524;&#9472;&#9472;&#9524;&#9472;&#9472;&#9524;&#9472;&#9472;&#9524;&#9472;&#9472;&#9524;&#9472;&#9472;&#9524;&#9472;&#9472;&#9524;&#9488;   &#9474;
        &#9474;16 15 14 13 12 11 10 9&#9474;   &#9474;
         ]      SN54HC595      &#9474;   &#9474;
        &#9474;1  2  3  4  5  6  7  8&#9474;   &#9474;
        &#9492;&#9516;&#9472;&#9472;&#9516;&#9472;&#9472;&#9516;&#9472;&#9472;&#9516;&#9472;&#9472;&#9516;&#9472;&#9472;&#9516;&#9472;&#9472;&#9516;&#9472;&#9472;&#9516;&#9496;   &#9474;
         B  C  D  E  F  G  H  GND&#9488; &#9474;
         &#9474;  &#9474;  &#9474;  &#9474;  &#9474;  &#9474;  &#9474;     &#9474; &#9474;
    510&#937; &#61628; &#61628;   &#61628;  &#61628;  &#61628;  &#61628;  &#61628;     &#9474; &#9474;
         &#9474;  &#9474;  &#9474;  &#9474;  &#9474;  &#9474;  &#9474;     &#9474; &#9474;
         M  L  R  &#9474;  &#9474;  &#9474;  &#9492;&#9472;&#9472;&#9472;&#9488; &#9474; &#9474;
         buttons  &#9474;  &#9474;  &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;&#9474; &#9474; &#9474;
                  &#9474;  &#9474;        &#9474;&#9474; &#9474; &#9474;
             &#9484;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;&#9474;&#9474; &#9474; &#9474;
             &#9474;    &#9531;  &#9531;       &#9474;&#9474;&#9474; &#9474; &#9474;
             &#9474;   x1 x2   y1&#9507;&#9472;&#9532;&#9496;&#9474; &#9474; &#9474;
     PS2/USB &#9474; rotation      &#9474; &#9474; &#9474; &#9474;
    mechancl &#9474; sensors   y2&#9507;&#9472;&#9532;&#9472;&#9496; &#9474; &#9474;
     mouse   &#9474;               &#9474;   &#9474; &#9474;
             &#9474;       USB gnd &#9507;&#9472;&#9472;&#9472;&#9496; &#9474;
             &#9474;           +5V &#9507;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;
             &#9474;    buttons    &#9474;
             &#9474;   L   M   R   &#9474; 
             &#9474;   &#9523;   &#9523;   &#9523;   &#9474;
             &#9492;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9524;&#9472;&#9472;&#9472;&#9496;
    

    The code: main and shift register 54HC595 object are attached as well as fiew photos.
    Let me know if more details are needed.
    The move showing demo in action is posted at youTube :
    "http://www.youtube.com/v/Xiu2T4Z_ld8"
    Jan
    2832 x 2128 - 1M
    2128 x 2832 - 804K
    2832 x 2128 - 1021K
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-08-01 10:09
    inaki said...
    Sorry, I don't understand the use of this device :-(
    Which is the goal of such a device ?

    line one post one: "I'd like to interface my 'custom made mouse' to a regular PC using the USB port."

    Propeller interfaces between a USB mouse and the custom made mouse.
  • hinvhinv Posts: 1,253
    edited 2007-08-03 02:43
    Can you explain how that shift register works? I am not familiar with them.

    Could you do without one and just use 7 lines instead of 4, or do you need it to get the outputs up to 5v?

    Thanks,
    Doug
  • janbjanb Posts: 74
    edited 2007-08-04 00:20
    <!--StartFragment -->Hi Doug,
    of course.· I was only trying to save Prop pins. In fact I have tested the whole device using
    7 pins and once it worked, I added the shift register.
    It converts serial·· sequence· of 8 bits in to· 1 8-bit word· in its output parallel register.
    So it ~10 x slower, but for human interface it is fine.

    To test e.g. dx movement· you need just to pins connected (via 100 Ohm) resistor to 2 photo elements for the X-axis. Sent 00,01,11,10,00 and mouse will move by 1 or 2 pixels (for me it was always 2) - so do it on a loop, e.g. 20 times. You need to experiment with the speed, I'd start at 10 Hz --> 1kHz.
    At a higher frequency cursor moves more pixels per cycle, reproducibility degrades, Y & X axis diverge.
    For button pins it is simple hold 1 for push and 0· for release. For· some mouses the logic is reversed - I measured· logic first with the voltmeter.
    And 3.3V from the Prop is fine - no need for 3.3 --> 5 V converter.
    Good luck
    Jan·
  • deSilvadeSilva Posts: 2,967
    edited 2007-08-04 10:54
    hinv said...
    Can you explain how that shift register works? I am not familiar with them.
    The 74HC595 is a more popular variant. www.datasheetcatalog.com/datasheets_pdf/7/4/H/C/74HC595.shtml
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-08-04 13:03
    I wish a couple of the small footprint 74hc595's had made it onto the propeller proto board. (hint, hint)
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-04 14:02
    I wish that someone would start a Prop parts store and care every part mentioned by one of the regulars.

    Sign me up.
  • rjo_rjo_ Posts: 1,825
    edited 2007-08-05 15:57
    that should read "carry every part."

    can't post edit yet[noparse]:)[/noparse]
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-08-05 21:14
    rjo_ said...
    I wish that someone would start a Prop parts store and carry every part mentioned by one of the regulars.

    Sign me up.
    Parallax plug (freely offered by me): try their·integrated circuit·accessory page: http://www.parallax.com/html_pages/products/componentshop/integrated_circuits.asp


    TABLE WAS SUPPOSED TO GO HERE



    Post Edited (Fred Hawkins) : 8/5/2007 9:23:40 PM GMT
Sign In or Register to comment.