3 Bit Slider

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
rdagger
Posts: 6
Joined: Tue Apr 01, 2008 6:13 pm
Contact:

3 Bit Slider

Post by rdagger » Sun Jul 04, 2010 2:29 am

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?

frank26080115
Rank 2
Rank 2
Posts: 43
Joined: Fri Jun 19, 2009 4:43 pm

Re: 3 Bit Slider

Post by frank26080115 » Sun Jul 04, 2010 7:20 am

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

rdagger
Posts: 6
Joined: Tue Apr 01, 2008 6:13 pm
Contact:

Re: 3 Bit Slider

Post by rdagger » Sun Jul 04, 2010 8:47 am

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.

frank26080115
Rank 2
Rank 2
Posts: 43
Joined: Fri Jun 19, 2009 4:43 pm

Re: 3 Bit Slider

Post by frank26080115 » Mon Jul 05, 2010 6:24 pm

What does the entire report descriptor look like?

rdagger
Posts: 6
Joined: Tue Apr 01, 2008 6:13 pm
Contact:

Re: 3 Bit Slider

Post by rdagger » Mon Jul 05, 2010 7:44 pm

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

frank26080115
Rank 2
Rank 2
Posts: 43
Joined: Fri Jun 19, 2009 4:43 pm

Re: 3 Bit Slider

Post by frank26080115 » Mon Jul 05, 2010 10:29 pm

Shouldn't the usage minimum for the button be "No Buttons Pressed"?

rdagger
Posts: 6
Joined: Tue Apr 01, 2008 6:13 pm
Contact:

Re: 3 Bit Slider

Post by rdagger » Tue Jul 06, 2010 1:43 am

frank26080115 wrote:Shouldn't the usage minimum for the button be "No Buttons Pressed"?

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

frank26080115
Rank 2
Rank 2
Posts: 43
Joined: Fri Jun 19, 2009 4:43 pm

Re: 3 Bit Slider

Post by frank26080115 » Wed Jul 07, 2010 6:30 pm

You are right I think, button 1 should be the usage minimum.

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

rdagger
Posts: 6
Joined: Tue Apr 01, 2008 6:13 pm
Contact:

Re: 3 Bit Slider

Post by rdagger » Thu Jul 08, 2010 2:36 am

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.

Post Reply