Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optical Mouse as encoder

Recently I discovered the beauty of the optical mouse as an incremental position encoder.

An optical mouse usually contains one component in which a camera is linked to an image processor linked to an USB interface. The resolution depends on the camera resolution. On the internet it is easy to find back the datasheets of this type of components describing also how to read/write with them.

My problem I first need to solve is how to make sure that an encoder mouse is not seen by the laptop/pc as a pointing device without disabling the USB port to which it is connected. I need to use 2 encoders so that means that 3 usb ports need to be used on my PC (running Windows XP), one for the mouse as pointing device and two for a mouse as encoder.

A second question is how to read/write instructions/data from/to the encoder mouse over an USB port? Could someone send me a link to a tutorial/example in C++?

Thanks very much in advance,

Stefan

like image 598
noste99 Avatar asked May 03 '12 13:05

noste99


People also ask

Is an optical an encoder?

The optical encoder is a transducer commonly used for measuring rotational motion. It consists of a shaft connected to a circular disc, containing one or more tracks of alternating transparent and opaque areas. A light source and an optical sensor are mounted on opposite sides of each track.

What is a mouse encoder?

Mouse Encoder is a type of mechanical incremental rotary encoder with feedback data of rotary direction and rotary speed. It features standard Grove interface that will save your lots of work in wiring and programming. Also, it is well adapted to heavy duty and a harsh environment.

How does a mouse wheel encoder work?

Mechanical encoders are the most common type of encoder found in gaming mice. They detect the physical motion of the scroll wheel and convert it into electrical signals. Mechanical encoders cannot replace optical encoders. All of the encoders that we sell are mechanical encoders.


2 Answers

The USB mouse microcontroller is probably hardcoded to send USB frames identifying itself as a HID device. In that case there's little hope you can succeed in preventing Windows to use it as a mouse. After all this IS a mouse.

If you are in DIY, you could try to hack the mouse board by unsoldering component/wires and directly control the encoders with your arduino. This way, the Arduino could read the data from the encoder and send it to the PC using its own USB serial port.

See an example there:

http://www.martijnthe.nl/2009/07/interfacing-an-optical-mouse-sensor-to-your-arduino/

For more info on HID device: http://en.wikipedia.org/wiki/USB_human_interface_device_class Excerpt: "There are two levels of APIs related to USB HID: the USB level and the operating system level. At the USB level, there is a protocol for devices to announce their capabilities and the operating system to parse the data it gets. The operating system then offers a higher-level view to applications, which do not need to include support for individual devices but for classes of devices. This abstraction layer allows a game to work with any USB controller, for example, even ones created after the game."

like image 177
fjardon Avatar answered Oct 03 '22 10:10

fjardon


Take a look at the Raw Input API to see if you can pick up on the events that way and block Windows from acting on them.

like image 31
Deanna Avatar answered Oct 03 '22 09:10

Deanna