Go Down

Topic: Using Arduino Diecimila as a PC mouse (Read 2524 times) previous topic - next topic

martinroos1

I was just wondering if anyone knew a way to use the serial output from the Arduino to control the cursor in Windows (it would output an 8-bit number for example decided by an analogue input). I wasn't sure if serial enumeration (and making it identify itself as a Microsoft serial mouse for example) would work, due to the delay in running the program because of the bootloader. I would ideally like not to have to remove the bootloader as I intend on programming via USB!

Any thoughts / comments would be much appreciated!

wayoda

Hi martin,
I guess the tough part of the project, is to convince Windows that the arduino is a mouse.
If your idea is not too arduino centric, here is a link to a chip that acts like a mouse and should be recognized as one.
Goto http://www.codemercs.com the thing your are looking for is the MouseWarrior.
Maybe you can use the arduino to trigger the inputs for that thing.
Its available in DIP package too.

Eberhard

martinroos1

#2
Aug 30, 2007, 09:28 pm Last Edit: Aug 30, 2007, 09:40 pm by martinroos1 Reason: 1
Eberhard,

That is very useful - thanks! Obviously I'll have to look into this more, but it doesn't appear to be too costly so may suit me well. I just hope I can get it shipped to the UK as if I can't it does cause me a slight issue!

That being said, the info is much appreciated!

Martin

[Edit] Having looked more into this I'm afraid that it probably won't work with what I had in mind - I intend to use accelerometers to determine the mouse movement (tilting most likely). However if you know of a way that I can make this work please let me know!

wayoda

Hi martin
http://www.segor.de sells the Codemercs-Products in germany and also ships to the UK. (see http://www.segor.de/L1Versand/euprivate.shtml for shipment conditions.
Since their online catalog seems to be available in german only, I had a look and found out that the different types of MouseWarriors are something like 14 Euros each.
The easiest way for you would probably to give them a call or order by mail.

A rough idea about how a tilt-sensor, the arduino and the mouse-warrior could be connected could go like this:
The MouseWarriors inputsignal for the x- and y-axis uses the same format as the signal from a rotary encoder.

The tilt-sensor output is connected to the ardino.
If the tilt-sensors reading changes,
the arduino triggers a mouse-movement by switching 2 digital outputs that are connected to the Mousewarrior.

Did you get the idea? Otherwise just post again and I'll try to be a bit more explicit.
Eberhard




martinroos1

Eberhard,

I sort of understand what you are saying, but if it isn't too much of a problem could you explain a little further? I apologise for my lack of knowledge, but this is relatively new to me! Much appreciated for all your help!

Martin

John_Ryan

#5
Aug 31, 2007, 01:53 pm Last Edit: Aug 31, 2007, 02:11 pm by John_Ryan Reason: 1
I can't remember where I read it, but if you play with you XP accessibility settings for the mouse (http://www.microsoft.com/enable/training/windowsxp/mousekeys.aspx) mimicking the numeric keypad to control the mouse can be done using the Arduino - I'm sure it's buried around here somewhere, or maybe in one of the forums over at processing, or perhaps wiring, it's been done that way I'd have no other reason to read the XP accessibility settings page  :)  


martinroos1

I did consider that, but given that I want to use an accelerometer I figured there was very little point in simulating the number pad - no variation in the rate of movement - which is really why I chose to use an accelerometer! Thanks for the idea all the same!

wayoda

Ok, here is the idea:
You will need the "MouseWarrior 20 O", so have a look at the schematic for this chip in the codemercs datasheet .
The MouseWarrior will look like a real mouse to the OperatingSystem of your target machine.
The x-axis and y-axis inputs to the MouseWarrior are simply transistor that pull the Pins X1,X2 and Y1,Y2 to ground.
Lets concentrate only at the X-axis (since the Y-axis work just the same):
The Mouse will report a move to the right :
when the signal on Pin X1 goes from HIgh -> LOW and after a short delay the signal on Pin X2 also goes from HIgh -> LOW .
The Mouse will report a move to the left
when the input-pins are triggered the other way round (first Pin X2 goes goes from HIgh -> LOW then Pin X1)

The foto-transistors from the datasheet can be replaced by normal transistors, driven by ordinary arduino digitalOutputs.

What the arduino has to do:
It reads the input from the tilt sensor (which i assume is an analog value, is it 5 volts?). Since we have only 10 Bits for the AD-conversion a value of 512 (2.5 Volts) should place the mouse cursor into the center of the screen.
Now when the input from the tilt-sensor changes (lets say by 4), the arduino has to generate 4 pulses for the MouseWarrior :
Code: [Select]

//Send a single impluse to the MouseWarrior
//if the inputvalue is +1 move the Mouse to the right,
//if the inputvalue is negative move the Mouse to the left
void sendMousePulse(int direction) {
 if(direction==0)
   return;
 if(direction==1) {
   //move Right, first Pin X1 goes low
   digitalWrite(PIN_X1,LOW);
   //we need some delay
   delay(1);
   //move Right, now Pin X2 goes low too
   digitalWrite(PIN_X2,LOW);
 }  
 else {
   //move left, first Pin X2 goes low
   digitalWrite(PIN_X2,LOW);
   //we need some delay
   delay(1);
   //move Right, now Pin X1 goes low too
   digitalWrite(PIN_X1,LOW);
 }  
 //some more delay....
 delay(1);
 //... and bring the pins back to the default HIGH for next round
 digitalWrite(PIN_X1,HIGH);
 digitalWrite(PIN_X2,HIGH);
}

void loop() {
  int xTilt = readAnalogXFromTiltSensor();
  if(xTilt!= lastxTiltValueRead) {
    xTiltChange=xTilt-lastxTiltValueRead;
    if(xTiltChange > 0) {
      for(int i=0;i<xTiltChange;i++)
         sendMousePulse(1);
    }
    else {  
      for(int i=xTiltChange;i>0;i--)
         sendMousePulse(-1);
    }
  }
}


This is the idea. If you have any doubts or questions about the MouseWarrior, you can ask at the CodeMercs-Forum. The developers have always been very helpful with everything concering their products.

I hope this was somewhat clearer...

Eberhard

 

martinroos1

Ah thank you very much! I thought that was along the lines of what you meant (emulating the quadrature encoder in a way), but wasn't quite sure how to go about this. I appreciate all you have done to help me greatly - I hope I haven't caused you too much hassle! Now to order me a MouseWarrior!

Thanks again

Martin

wayoda

Oh, before you order this is from the MouseWarrior Datasheet (Page 8) but it is easily overlooked:
Quote

XOut, XIn (MouseWarrior20)
Connection for external oscillator. A 6MHz two
pin ceramic resonator may be connected here, no
additional components required.
Using a crystal will result in unstable operation as
the oscillator is optimized for use with ceramic
resonators. Using a three pin ceramic resonator
will also result in unstable operation.
An external 6MHz clock may be connected to XIn,
XOut has to be left floating in this case. Though
this may not be compliant with the USB suspend
mode current limits.

You have to take this note seriously : A crystal will not work here, and a ceramic resonater that has
3 pins instead of 2 pins as the datasheet recommends will also not work. If you order with Segor that have these resonators in stock.
While I haven't used the MouseWarrior I have some experience with the IOWarrior that also requires a 2 pin resonator. Lots of people reported unreliable operation of the chip caused by using the wrong component.

Eberhard

wayoda

... and this i should have mentioned earlier :
If your project is a one-shot thing, you can always disassemble an old mouse you happen to have in your house.
...but I suggest you stay away from the little furry ones, take one with a 5 foot tail :-)

You should have no trouble locating the light barrier that produces the signals (just like the transistors in the MouseWarrior Datasheet).
Might be the cheapest solution then..
Eberhard



martinroos1

Thanks for the details about the resonator - I was going to look further into that but thanks to you I no longer need to! I had considered taking apart an old mouse (I have more old mice then I care to count!) and use the controller from that - I guess it should work in the same way that the MouseWarrior works! At the end of the day, if it doesn't work then I haven't lost any money - it's not as though I have any other use for out of date mice!

I really do appreciate all the help!

Martin

kasperkamperman.com

I was wondering. Wouldn't it be possible to use Arduino with a serialmouse driver. I've found a serialdriver from a pen tablet.
http://www.aiptek.com/drivers.htm#hp6u

Couldn't Arduino output information in that protocol ?
And if its possible, how do you know what the protocol is ? Would it be possible to analyse the output with a serial monitor from such a device ?

Anyone has an idea how a serial mouse on RS232 worked ?
Or is using the MouseWarrior to let Arduino spit out HID/mouse data the only way ?

Cheater

Quote
If your project is a one-shot thing, you can always disassemble an old mouse you happen to have in your house.
...but I suggest you stay away from the little furry ones, take one with a 5 foot tail :-)

Sorry I need some clarification.

Would this mouse be ok? ;D








On Topic: I'd imagine you could emulate the PS/2 protocol without too many problems.

emacpher

Quote

Anyone has an idea how a serial mouse on RS232 worked ?


The serial protocol is described at:
http://local.wasp.uwa.edu.au/~pbourke/dataformats/serialmouse/

but I don't know how the serial mouse is recognized as a mouse at bootup.

Go Up