Go Down

Topic: USB mouse basic question (Read 781 times) previous topic - next topic

spencoid

i am awaiting the delivery of my Due and trying to figure out as much as i can before getting it. i read the example mouse controller sketch and am trying to determine if it will work for my application. i am currently using a quadrature encoder connected to a chip that converts the quad to step and direction. the step pulse is connected to an interrupt pin so every time there is a pulse, the interrupt code is run.

it is my hope that the USB mouse controller can be used in a similar way, that i can detect any mouse motion and use this to send step pulses.  exactly how does the usb task interact with the main loop? how often is the (mouse.getXChange() updated? is there a document that explains this? i have not found one yet.


djjoshuad

unfortunately the USBhost library for the Due (1.5.1r2) is still in development.  Documentation is somewhat scarce, but the mouse examples should steer you in the right direction.

stimmer

I just tried profiling it, the report rate is 10mS. That's the normal report rate for a USB mouse.

It's possible to modify the USBHost library to get a 1mS report rate (find hidboot.h, search for 10 and replace with 1 in both places). I think that's the fastest you can get, it's a limit of the USB mouse standards.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

spencoid

thanks, i'll try to change that value. 1 ms polling will be MUCH better. it might even make the following question redundant but here it is anyway:

i want to have a servomotor directly follow mouse motion. my program currently does this beautifully while also writing the motion timing values to SD card (thanks to the SDfat library which works sooooo well on the DUE) i use a quadature encoder for the HID and a decoder chip to run the servomotor driver (Gecko, which is one great brush motor driver) this all works very well but i want to use a cheap optical mouse instead of having to build the HID myself. soooo, i really want the mouse to report every tick it moves instead of how far it moved in the polling period. if the polling period is 1 ms, this might just solve the problem because the motion will probably be either 0 or 1 and never more if my main loop is tight enough.

does this sound possible?

Go Up