HID USB Multimedia Keypad


+ Reply to Thread
Results 1 to 32 of 32
  1. #1
    Join Date
    Feb 2011
    Posts
    14

    Default HID USB Multimedia Keypad

    Hi, I am trying to make a simple multimedia keypad (Next, Previous, Play, Stop, Eject, Volume Up, Volume Down) and can't seem to get it to work. I started with the example HID Keyboard and it worked fine so I modified the USB Descriptor for the Consumer Device which supports the correct buttons but can't get it to work. Either I am sending the data from the PIC to the PC incorrectly or something is wrong in the USB Descriptor.

    I have included my PBP code, hopefully someone out there might have a better understanding of how it would work.

    Any help would be greatly appreciated, Thanks.
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    Well looks like nobody had any luck figuring this out but thats ok. It was a simple problem in the HID Descriptor I missed but its fixed now.

    Only problem I am having now it the keys keep repeating but that should be an easy fix

  3. #3
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    Ok now that that is worked out its time to move on to next stage, adding a standard HID or CDC interface to access the PIC from a PC/Mac.

    Is it possible to combine a second interface to the same device?

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default Re: HID USB Multimedia Keypad

    I would say yes, but how to... hell I don't know.

    What I would suggest, is to develop a pure HID device, from there you develop a Driver. This driver (or standalone application) will take care of sending the keystrokes and perform other tasks.

    MIDI devices use 2 Generic Classes, MIDI Device and Audio Composite, but it is still considered as a single device...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    Sounds good but I need this to be universal meaning must work with Mac and Linux as well as PC. Standalone app with custom driver would not work in this case.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: HID USB Multimedia Keypad

    Standalone app with custom driver would not work in this case.
    Depends on what you write it in...
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    Would it be difficult to do the USB Service with an interrupt routine instead of in the main loop?

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: HID USB Multimedia Keypad

    ISR is the way to go. Here is a project using DT's Instants.
    http://www.picbasic.co.uk/forum/cont...USB-SD-LOGGING
    Darrel gave us another USB service routine also, but it seems to work best as a stand alone ISR. That is why I like using the Instant approach.
    But you can take a look at the other here.
    http://www.picbasic.co.uk/forum/show...8306#post78306
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    Thanks again for the help.

    I put the code you sugested in but I keep getting an error saying Syntax Error for

    UIE = $7F 'ENABLE USB INTERRUPTS

    I am using Picbasic Pro 2.47

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: HID USB Multimedia Keypad

    Can you give a little more info.. Are you trying the instant solution or the other?
    Go ahead and post your code and config setup.
    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    Ok I updated to PBP 2.60 (just found the CD) and it compiles ok now but if I enable the innterrupt routines it won't detect the device.
    Attached Files Attached Files

  12. #12
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    I am using a custom HID Bootloader (Modified the Microchip one since it won't compile using the free tools)

    I am also using an external 48MHz Oscilator since I have hundreds.
    Attached Files Attached Files
    Last edited by pmacleod; - 12th February 2011 at 16:45.

  13. #13
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    Ok I just had some of that code you gave me in wrong place, seems to be working fine now.

    I noticed they really changed the USB examples in the new PBP, is it hard to convert an exsisting project to the new format or is it even worth doing.

  14. #14
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: HID USB Multimedia Keypad

    Quote Originally Posted by pmacleod View Post
    Ok I just had some of that code you gave me in wrong place, seems to be working fine now.
    Great!!
    I noticed they really changed the USB examples in the new PBP, is it hard to convert an exsisting project to the new format or is it even worth doing.
    Your base code should not really change, just the supporting files. So what I do when upgrading an old project like this is start a new directory with the old base code and all of the new supporting files if I need the features from the new PBP. Otherwise I just leave things as they are and use the version of PBP that was originally used for the project. You can have more than one version of PBP installed, just pick the one you want at compile time.
    Dave
    Always wear safety glasses while programming.

  15. #15
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    Ok I am seeing some wierd things in the new USB Descriptor file for PBP 2.60. Is there a filesize limit for the descriptors now?

  16. #16
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: HID USB Multimedia Keypad

    I have not heard of any changes . Not sure why there would be.
    Which file are you looking at?
    Dave
    Always wear safety glasses while programming.

  17. #17
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    I converted my project to the new format and everything was ok so I went ahead and added the section for the Endpoint 1 In. Once I added it I started getting 'Block overflow for ENDASM'.

    I went over and over the ASM code in the descriptor and nothing was wrong. I removed an equal amount of comment lines and it compiled ok. I continued to do the same thing but ran out of comment lines I could remove, My full USB Descriptor file is quite big and I can't even finish getting all of the first endpoint code in before getting the error.

  18. #18
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: HID USB Multimedia Keypad

    I am afraid you are beyond me. I have not written my own descriptor file Sorry.
    Dave
    Always wear safety glasses while programming.

  19. #19
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    Wierd thing is it works fine if i use the old method but still compile for PBP 2.60, its just the new method of putting the descriptor in a BAS file as an include that does not work.... I guess I will just stick to the old method for now.

    Must but a problem with PBP itself, I hope they fix it.


    P.S.: Just wanted to let you know that the interrupt method you gave me (the instant one) works wonders, I moved the button press code to interrup also and works perfectly, thanks so much
    Last edited by pmacleod; - 13th February 2011 at 01:28.

  20. #20
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: HID USB Multimedia Keypad

    There is a limit to the number of characters in a single ASM block (includes comments and spaces/tabs).

    You can just start a new block when you reach the limit ...

    Code:
    ENDASM
    ASM
    Last edited by Darrel Taylor; - 13th February 2011 at 19:07.
    DT

  21. #21
    Join Date
    Feb 2011
    Posts
    14

    Default Re: HID USB Multimedia Keypad

    All I can say is WOW, thanks so much, you are an absolute genius

    I searched and search the new PBP 2.60 manual and did not see any mention of that and would have never guessed that was the cause.

    Again thanks. Oh and great job on your Interrupt routines, works wonders

  22. #22
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109

    Default Re: HID USB Multimedia Keypad

    Here is the finished code and schematics if anyone is interested, enjoy
    Attached Images Attached Images  
    Attached Files Attached Files

  23. #23
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109

    Default Re: HID USB Multimedia Keypad

    Oh I just wanted to say I did not include Darrels Interupt routine files, you need to download those for this project to work.

  24. #24
    Join Date
    Sep 2015
    Posts
    4

    Default Re: HID USB Multimedia Keypad

    hi guys i know this thread is a little bit old but im sure you can help me...
    when i try to compile the hid usb keypad it doesnt compile (too many errors) im using pbp 2.60 and microcode studio, but, i have used another device and string descriptor with peter's report descriptor and it compiles but when i put something on the buffer no mater if buffer is a byte variable array or not the pc show 4 key pressed at the same time, i think that the problem is that the descriptor sends the data but the endpoint or the hid descriptor is handling it in a different way not acording with the report descriptor...
    thanks a lot for your help!!!

  25. #25
    Join Date
    Sep 2015
    Posts
    4

    Default Re: HID USB Multimedia Keypad

    update: it compiles now. the pbp folder had some missing files...

    but when i plug in the device windows say "the device can't start"

    as far as i know it could be a descriptor problem right?

    thanks

  26. #26
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109

    Default Re: HID USB Multimedia Keypad

    Sorry I have been away working on other projects. Are you compiling the original source or your modified one?

  27. #27
    Join Date
    Sep 2015
    Posts
    4

    Default Re: HID USB Multimedia Keypad

    i have downloaded the las HID USB Multimedia Keypad.zip attachment and now it compiles. but still the pc doesnt recognizes the device...

    ive changed the original reportdescriptor1, to the \usb18 folder mouse in a circle example keeping all the keypad original code and the pc recognizes the hid mouse, of course it moves the mouse pointer weird because the main program code is made for another reportdescriptor.
    that makes me doubt about the original reportdescriptor.


    ReportDescriptor1
    retlw 0x05
    retlw 0x01 ;usage page (generic desktop)
    retlw 0x09
    retlw 0x02 ;usage (mouse)
    retlw 0xA1
    retlw 0x01 ;collection (application)
    retlw 0x09
    retlw 0x01 ;usage (pointer)
    retlw 0xA1
    retlw 0x00 ;collection (linked)
    retlw 0x05
    retlw 0x09 ;usage page (buttons)
    retlw 0x19
    retlw 0x01 ;usage minimum (1)
    retlw 0x29
    retlw 0x03 ;usage maximum (3)
    retlw 0x15
    retlw 0x00 ;logical minimum (0)
    retlw 0x25
    retlw 0x01 ;logical maximum (1)
    retlw 0x95
    retlw 0x03 ;report count (3)
    retlw 0x75
    retlw 0x01 ;report size (1)
    retlw 0x81
    retlw 0x02 ;input (3 button bits)
    retlw 0x95
    retlw 0x01 ;report count (1)
    retlw 0x75
    retlw 0x05 ;report size (5)
    retlw 0x81
    retlw 0x01 ;input (constant 5 bit padding)
    retlw 0x05
    retlw 0x01 ;usage page (generic desktop)
    retlw 0x09
    retlw 0x30 ;usage (X)
    retlw 0x09
    retlw 0x31 ;usage (Y)
    retlw 0x15
    retlw 0x81 ;logical minimum (-127)
    retlw 0x25
    retlw 0x7F ;logical maximum (127)
    retlw 0x75
    retlw 0x08 ;report size (8)
    retlw 0x95
    retlw 0x02 ;report count (2)
    retlw 0x81
    retlw 0x06 ;input (2 position bytes X & Y)
    retlw 0xC0 ;end collection
    retlw 0xC0 ;end collection
    EndReportDescriptor1

  28. #28
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109

    Default Re: HID USB Multimedia Keypad

    If you have doubts about it did you at least test the original code as is to verify?

  29. #29
    Join Date
    Sep 2015
    Posts
    4

    Default Re: HID USB Multimedia Keypad

    yes i did... i compiled the whole original project and tested it in a 18f2550 and didn't work...

    after testing many different configs and even not too logical things i found the problem...

    i managed to use a different report descriptor and the rest from the circle in a mouse descriptor example.
    now the pc recognizes the device but when i put in the buffer anything it sends many keys at the same time, that's because i had the endopint buffer size set to 1 byte so it only sends the first byte of data and discard the rest...

    #define USB_POLLING
    #define HID_INTF_ID 0x00
    #define HID_EP 1
    #define HID_INT_OUT_EP_SIZE 3 ; 1
    #define HID_INT_IN_EP_SIZE 3 ; 1
    #define HID_NUM_OF_DSC 1

    now that i have changed the HID_INT_IN_EP_SIZE from 1 to 3 it let me to put on the buffer a variable array and send for example

    variable[0]=%00000000
    variable[1]=%00000001

    the usb raw data will llok like this

    00 01

    thanks for your help!!!

  30. #30
    Join Date
    Feb 2013
    Posts
    730

    Default Re: HID USB Multimedia Keypad

    So will this work in PBP3?
    I want to have such a keypad, and ashamed to have to use Arduino Pro Micro

  31. #31
    Join Date
    Apr 2014
    Location
    Northeast
    Posts
    391

    Default Re: HID USB Multimedia Keypad

    Give it a try and report your results. I use HIDMaker for USB stuff. The last time I had to create a USB project (this time using XC8), nothing compiled. I got numerous errors. I tried generating the code for PBP, XC8, even ASM... Dr. Bob worked with me, and it appears the newer MPLABX versions generated curious errors. I had to use an older MPLABX v1.45 to get it working (MPLABX is currently at version 5.45). You may find issues that require you to link PBP to an older version of MPLABX.
    Last edited by mpgmike; - 18th April 2021 at 16:01. Reason: Added clarification

  32. #32
    Join Date
    Feb 2013
    Posts
    730

    Default Re: HID USB Multimedia Keypad

    Thanks, will try all this this weekend....

Posting Permissions

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