Pages: [1]   Go Down
Author Topic: USB mouse basic question  (Read 613 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Corinth, TX
Offline Offline
Jr. Member
**
Karma: 1
Posts: 92
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 506
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1]   Go Up
Jump to: