10bit ADC thorugh EASY HID (pic 18f2550)


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2014
    Posts
    21

    Default 10bit ADC thorugh EASY HID (pic 18f2550)

    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.

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: 10bit ADC thorugh EASY HID (pic 18f2550)

    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
    Last edited by Demon; - 1st December 2014 at 01:56.

  3. #3
    Join Date
    Apr 2014
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: 10bit ADC thorugh EASY HID (pic 18f2550)

    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 )

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: 10bit ADC thorugh EASY HID (pic 18f2550)

    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

Similar Threads

  1. Where To Get Started With ADC (Pic 18f2550 / 4550)
    By jsags1 in forum FAQ - Frequently Asked Questions
    Replies: 6
    Last Post: - 17th October 2014, 05:26
  2. Multiple 10bit adc on pic 16f887?
    By Helgeland in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th March 2012, 17:33
  3. Easy HID Command -Response application
    By ptig185 in forum USB
    Replies: 25
    Last Post: - 22nd September 2010, 20:56
  4. i cant get 18f2550 work as HID
    By Ahmadabuomar in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 13th October 2009, 17:39
  5. 10bit ADC = 65536 ????
    By erpalma in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th January 2007, 18:57

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts