PDA

View Full Version : 10bit ADC thorugh EASY HID (pic 18f2550)



jsags1
- 1st December 2014, 00:25
ive made many joysticks by now with up to 8 axis and 64 buttons, but ive always used 8 bits of resolution for my axis (ADC) so here is my question.


how can i send the 10 bits of resolution for my axis to the PC via USB, should i specify this on the Descriptor file, or where exactly? i find myself lost and thanks in advance.

Demon
- 1st December 2014, 00:54
USB descriptor doesn't care about bits, it deals in bytes.

10 bits will take 2 bytes from PBP (word). You can move high and low bytes individually from word into 2 bytes in descriptor.

Look how big your descriptor area is in your current USB examples. You have to make sure you have enough pairs of bytes (8 axis needs 16 bytes).

Once on the PC, I can't say how to convert the 2 bytes to a value.

Robert

jsags1
- 2nd December 2014, 04:10
DISCRIPTOR code----------------------------------------------------------------
ReportDescriptor1
RETLW 0x05
RETLW 0x01 ; USAGE_PAGE (Generic Desktop)
RETLW 0x09
RETLW 0x04 ; USAGE (Joystick)
RETLW 0xa1
RETLW 0x01 ; COLLECTION (Application)
RETLW 0x05
RETLW 0x01 ; USAGE_PAGE (Generic Desktop)
RETLW 0x09
RETLW 0x04 ; USAGE (Joystick)
RETLW 0xa1
RETLW 0x00 ; COLLECTION (Physical)
RETLW 0x09
RETLW 0x30 ; USAGE (X)
RETLW 0x09
RETLW 0x31 ; USAGE (Y)
RETLW 0x09
RETLW 0x32 ; USAGE (Z)
RETLW 0x09
RETLW 0x33 ; USAGE (Rx)
RETLW 0x75
RETLW 0x08 ; REPORT_SIZE (8)
RETLW 0x95
RETLW 0x04 ; REPORT_COUNT (4)
RETLW 0x35
RETLW 0x00 ; PHYSICAL_MINIMUM (0)
RETLW 0x46
RETLW 0xff
RETLW 0x00 ; PHYSICAL_MAXIMUM (255)
RETLW 0x15
RETLW 0x00 ; LOGICAL_MINIMUM (0)
RETLW 0x26
RETLW 0xff
RETLW 0x00 ; LOGICAL_MAXIMUM (255)
RETLW 0x81
RETLW 0x02 ; INPUT (DataVarAbs)
RETLW 0xc0 ; END_COLLECTION




take a look at the report size.....

maybe i need to change the report size to 16 and the physical maximum to 1023??

that is as much as i think it could work..


how could i send the entire value??


like this?.....

e.g:

ADCIN 0, USBBuffer[0]


(that is what i use for sending 8 bit resolution axis values, and dont know if it would work with 10 bit :( )

Demon
- 2nd December 2014, 14:20
I would start by doubling REPORT SIZE only.

I would use a word for ADCIN, then move high and low nibble into 2 array elements individually (ie: high nibble to USBBuffer[0] and low nibble to USBBuffer[1]).

Once on PC I'd define the buffer IN as 8 word variables (not sure what type, LONG possibly).

Then I'd leave the USB routines untouched except possibly to loop 16 times instead of 8 where required.

Robert