Page 1 of 1

3 Bit Slider

Posted: Sun Jul 04, 2010 2:29 am
by rdagger
I'm trying to interface a slider with 8 positions. Everything works great except the slider does not report in linear increments. Windows reads the 8 positions as 0,8191,16383,24575,32767,32768,49151,65535. The first 5 positions are OK at 8191 intervals. Then 5 & 6 are 1 apart and positions 6,7,8 are at 16384 intervals. I've tried slider, wheel and dial and they all return the same results.
Here is my descriptor code:

Code: Select all

0x09 , 0x36   //     USAGE (Slider)
0x15 , 0x00   //     LOGICAL_MINIMUM (0)
0x25 , 0x07   //     LOGICAL_MAXIMUM (7)
0x35 , 0x00   //     PHYSICAL_MINIMUM (0)
0x45 , 0x07   //     PHYSICAL_MAXIMUM (7)
0x95 , 0x01   //     REPORT_COUNT (1)
0x75 , 0x03   //     REPORT_SIZE (3)
0x81 , 0x02   //     INPUT (Data,Var,Abs)


How can I get the device to report the 8 detents at equal 8191 intervals?

Re: 3 Bit Slider

Posted: Sun Jul 04, 2010 7:20 am
by frank26080115
I''m confused. What does this slider do? What software works with it? What are you using to get the readings?
Also, why increments of 8191? You seem to want 3 bit resolution, so 8 total positions, which sounds right, so you'd want increments of 1, right?

Also try to make sure everything is a whole byte, even if you need only 3 bits, add 5 more useless padding bits to make it 8, or your can try making the 3 bits more significant and have range between 0 and 255 but in increments of 32

Re: 3 Bit Slider

Posted: Sun Jul 04, 2010 8:47 am
by rdagger
It is a rotary switch with 8 positions and a 3 bit BCD output.
I'm using a freeware Joystick utility to test it (It shows a range of 0 to 65536 for all controls). I also tested it with the Windows Game Controller utility. I hope to use it for CNC.
The increments don't matter as long as they are uniform. I tried switching the logical range to -127 to 127 but I'm still getting non-linear results.

Re: 3 Bit Slider

Posted: Mon Jul 05, 2010 6:24 pm
by frank26080115
What does the entire report descriptor look like?

Re: 3 Bit Slider

Posted: Mon Jul 05, 2010 7:44 pm
by rdagger
I've tried many reports since my first post. Here is my latest version (I switched from slider to throttle).

Code: Select all

0x05 , 0x01    ' USAGE_PAGE (Generic Desktop)
0x09 , 0x05    ' USAGE (Gamepad)
0xA1 , 0x01    ' COLLECTION (Application)
0x05 , 0x02    '   USAGE_PAGE (Simulation Controls)
0x09 , 0xBB    '   USAGE (Throttle)
0x15 , 0x00    '     LOGICAL_MINIMUM (0)
0x25 , 0x07    '     LOGICAL_MAXIMUM (7)
0x35 , 0x00    '     PHYSICAL_MINIMUM (0)
0x45 , 0x07    '     PHYSICAL_MAXIMUM (7)
0x95 , 0x01    '     REPORT_COUNT (1)
0x75 , 0x03    '     REPORT_SIZE (3)
0x81 , 0x02    '     INPUT (Data,Var,Abs)
0x05 , 0x09    '   USAGE_PAGE (Button)
0x19 , 0x01    '   USAGE_MINIMUM (Button 1)
0x29 , 0x0D    '   USAGE_MAXIMUM (Button 13)
0x15 , 0x00    '   LOGICAL_MINIMUM (0)
0x25 , 0x01    '   LOGICAL_MAXIMUM (1)
0x95 , 0x0D    '   REPORT_COUNT (13)
0x75 , 0x01    '   REPORT_SIZE (1)
0x81 , 0x02    '   INPUT (Data,Var,Abs)
0xC0            ' END_COLLECTION

I've found that increasing the logical range makes the results more linear. Here's a chart showing 3,4 and 5 bit resolutions:
Image

Re: 3 Bit Slider

Posted: Mon Jul 05, 2010 10:29 pm
by frank26080115
Shouldn't the usage minimum for the button be "No Buttons Pressed"?

Re: 3 Bit Slider

Posted: Tue Jul 06, 2010 1:43 am
by rdagger
frank26080115 wrote:Shouldn't the usage minimum for the button be "No Buttons Pressed"?

It's not on the HID Descriptor Tool joystick example.

Re: 3 Bit Slider

Posted: Wed Jul 07, 2010 6:30 pm
by frank26080115
You are right I think, button 1 should be the usage minimum.

Now I have no idea what's wrong at all.

Re: 3 Bit Slider

Posted: Thu Jul 08, 2010 2:36 am
by rdagger
I think it is just a windows HID driver issue. They probably don't expect analog axis to use less than 8 bit resolution. I'm running it at 5 bit now (logical 0-30) and it is close enough for my application. Thanks.