• AVR Freaks

Hot!Need help with HID Device using PIC18F2550

Author
OscarTheGrouch
Super Member
  • Total Posts : 369
  • Reward points : 0
  • Joined: 2010/11/29 18:07:28
  • Location: 0
  • Status: offline
2020/10/31 17:40:20 (permalink)
4 (1)

Need help with HID Device using PIC18F2550

Hello All,
I'm doing a project where I'm sending data from a PC app I'm writing that is going to a device that selects Ethernet videos and displays them. The device (don't have the name of it handy) is presently controlled via key pad that one can enter channel numbers. This key pad connects via USB to the device and, I assume it sees it as a HID device. I want to send this device channel numbers from the PC application. I have a USB to Serial device but it does not recognize it, I assume because it is a CDC Device.
 
I think I need to make a PIC that will read the Serial data from the USB to Serial cable I have and be a HID device to the video controller. I have a PIC18F2550 on hand that I think should do the job. It just needs to read data from the ESUART and send it out the USB as a HID Device. I have seen examples of a CDC Devices, but could use some more information, maybe some code example for a HID.
 
Thanks in advance,
OtG
 
Edit: I should probably make this more clear .. I used a second Serial to USB device with cross connect to send data from the PC to the video controller. This second bridge was what presented the CDC Device to the video controller.
OtG
post edited by OscarTheGrouch - 2020/10/31 18:10:13
#1

18 Replies Related Threads

    Murton Pike Systems
    Super Member
    • Total Posts : 247
    • Reward points : 0
    • Joined: 2020/09/10 02:13:01
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/10/31 18:39:52 (permalink)
    +1 (1)
    The 2550 is what I first used for HID device.
    I got my basic code for it from www.waitingforfriday.com
    There is a 2550 USB HID project on the website.
    He provides PIC and PC code.
     
    #2
    katela
    Super Member
    • Total Posts : 1966
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: online
    Re: Need help with HID Device using PIC18F2550 2020/11/01 03:55:17 (permalink)
    +1 (1)
    Microchip Libraries for Applications have sample projects that works out of the for different USB classes including HID. They even provide some sample PC applications for some projects that you can customize for your needs.
    This USB HID example shows how to send control data from a PC application to PIC : https://www.studentcompan...c-gui-through-usb-hid/

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #3
    OscarTheGrouch
    Super Member
    • Total Posts : 369
    • Reward points : 0
    • Joined: 2010/11/29 18:07:28
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/01 10:46:45 (permalink)
    0
    Thanks, both of you for the responses. I will check them out.
    I was looking at a MCP2221 as an alternative, the only issue I see with it (besides having to buy one) is that I would have to use the I2C to get it to be a HID Device. Is that correct Katela?
    Is there a MicroChip device like this that would do UART to USB as a HID?
    If I did use the MCP2221, I would need a small PIC to read it's RX and provide I2C to the MCP2221.
    In the mean time I'll check out code for the PIC18F2550.
    Once again, thanks for the replies.
    OtG
    #4
    OscarTheGrouch
    Super Member
    • Total Posts : 369
    • Reward points : 0
    • Joined: 2010/11/29 18:07:28
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/01 10:55:57 (permalink)
    0
    I found the project and it looks helpful. I don't have any experience using C18 though.
    Do you know if it's possible to convert it to use XC8?
    Thanks,
    OtG
     
    #5
    katela
    Super Member
    • Total Posts : 1966
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: online
    Re: Need help with HID Device using PIC18F2550 2020/11/01 11:00:19 (permalink)
    +1 (1)
    Why do you need the MCP2221 while you have the PIC18F2550 which is a USB device supporting CDC, HID, UART, I2C, etc?

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #6
    OscarTheGrouch
    Super Member
    • Total Posts : 369
    • Reward points : 0
    • Joined: 2010/11/29 18:07:28
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/01 11:08:52 (permalink)
    0
    katela
    Why do you need the MCP2221 while you have the PIC18F2550 which is a USB device supporting CDC, HID, UART, I2C, etc?

    Just as an alternative to using the 18F2550 and writing code for it. I was hoping for a device LIKE the MCP2221 that would do Serial to USB HID and not have to do any coding. I guess that doesn't exist though. ;)
    Mean time I'll look into the links you gave me.
    OtG
    #7
    Aussie Susan
    Super Member
    • Total Posts : 3859
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/01 19:04:41 (permalink)
    -1 (3)
    There are many devices that do the USB-Serial conversion that use UART, SPI and I2C to talk back to the MCU. If you need to buy something then do some research based on functionality, footprint, voltages etc..
    Also the PIC18F USB interfaces can take up quite a bit of code so it all depends how much of your FLASH you have available but having everything integrated can be very useful.
    Susan
    #8
    OscarTheGrouch
    Super Member
    • Total Posts : 369
    • Reward points : 0
    • Joined: 2010/11/29 18:07:28
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/05 22:54:50 (permalink)
    0
    Aussie Susan
    There are many devices that do the USB-Serial conversion that use UART, SPI and I2C to talk back to the MCU. If you need to buy something then do some research based on functionality, footprint, voltages etc..
    Also the PIC18F USB interfaces can take up quite a bit of code so it all depends how much of your FLASH you have available but having everything integrated can be very useful.
    Susan

    Thanks for the reply. I need something that is a HID to the Host. I've got UART to USB but it's a CDC to the Host and it's looking for a HID.
    OtG
    #9
    Aussie Susan
    Super Member
    • Total Posts : 3859
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/07 18:34:11 (permalink)
    #10
    Mysil
    Super Member
    • Total Posts : 4130
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/08 03:06:01 (permalink)
    0
    Hi,
    MCP2221(A)     is both a converter HID device to I2C master,  and HID device to UART asynchronous serial.
                          The UART endpoint comes up as a virtual COM port on a PC.
                          and may be used with a terminal emulator like TeraTerm  or PuTTY or ...
     
    MCP2210         is a similar converter  HID device to SPI master, and HID device to GPIO pins.
                          Those GPIO pins may be used as Chip Select signals, or independent.
     
    These devices seem to be a PIC microcontrolller that have been preprogrammed
    with code similar to MLA USB examples.
     
        Mysil
    post edited by Mysil - 2020/11/08 03:11:52
    #11
    OscarTheGrouch
    Super Member
    • Total Posts : 369
    • Reward points : 0
    • Joined: 2010/11/29 18:07:28
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/10 23:12:19 (permalink)
    0
    Mysil
    Hi,
    MCP2221(A)     is both a converter HID device to I2C master,  and HID device to UART asynchronous serial.
                          The UART endpoint comes up as a virtual COM port on a PC.
                          and may be used with a terminal emulator like TeraTerm  or PuTTY or ...
     
    MCP2210         is a similar converter  HID device to SPI master, and HID device to GPIO pins.
                          Those GPIO pins may be used as Chip Select signals, or independent.
     
    These devices seem to be a PIC microcontrolller that have been preprogrammed
    with code similar to MLA USB examples.
     
        Mysil


    I wasn't sure how you get the I2C into the device, thought you could set it up to use one of the GPIOs as an interrupt for the I2C mater to get data.  How to use it isn't too clear, IMO.
    I'm trying now to write code for a 18F2550 I already have. If that doesn't work, I'll look at this more.
    OtG
    #12
    oliverb
    Super Member
    • Total Posts : 441
    • Reward points : 0
    • Joined: 2009/02/16 13:12:38
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/11 06:26:24 (permalink)
    0
    FWIW I believe MikroC comes with tools and libraries to simplify USB HID implementation, and should still support the 18F2550.
    Also searching for "keyboard emulator" threw up some promising results.
     
    Also are you able to confirm that your "device" really is using USB and a proper HID-class keypad. Does it function the same with a generic PC keyboard connected?
     
     
    #13
    OscarTheGrouch
    Super Member
    • Total Posts : 369
    • Reward points : 0
    • Joined: 2010/11/29 18:07:28
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/11 09:16:43 (permalink)
    0
    oliverb
    FWIW I believe MikroC comes with tools and libraries to simplify USB HID implementation, and should still support the 18F2550.
    Also searching for "keyboard emulator" threw up some promising results.
     
    Also are you able to confirm that your "device" really is using USB and a proper HID-class keypad. Does it function the same with a generic PC keyboard connected?

    Thanks for the suggestions. I was getting part of the way through the enumeration process using a Keypad demo that was suggested to me. I think I was having issues with using current (or latest) MLA libraries with that code. It came with it's own MLA code. Having issue with HID In and Out Reports and Call Backs.
    I have been able to compile a keyboard HID Demo that came with the MLA version I have installed. There is a Demo for a 18F4550 which is in the same family as the 18F2550. The Demo only uses a few buttons but I think I can modify this one to work on my 18F2550 and use serial in for what I need it to do.
    Will keep this thread updated on progress.
    OtG
    #14
    OscarTheGrouch
    Super Member
    • Total Posts : 369
    • Reward points : 0
    • Joined: 2010/11/29 18:07:28
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/14 00:44:46 (permalink)
    +1 (1)
    Happy to report I have had success in modifying the Device HID Keyboard Demo Program that came with the MLA for my project.
    Was able to convert to a PIC 18F2550 using the "picdem_fs_usb" BSP.
    Modified the Input pins to PORT A.
    The thing that caused some grief was the MCLR pin. This device doesn't provide a weak pullup if using the MCLR function. Had to pull high to get 3.3v regulator to work and the PIC to Attach to the Host PC.
    Found it was better to make RE3 an input in the Device Configuration Words and it worked much better and provided a HIGH to MCLR.
    Any questions, would be happy to respond. Thanks Forum respondents (including katela) ..
    OtG
     
    #15
    oliverb
    Super Member
    • Total Posts : 441
    • Reward points : 0
    • Joined: 2009/02/16 13:12:38
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/14 06:55:37 (permalink)
    0
    I have a colleague with a bad habit of leaving MCLR floating. I wish the program/debug connector instructions were clearer on that point.
     
    #16
    OscarTheGrouch
    Super Member
    • Total Posts : 369
    • Reward points : 0
    • Joined: 2010/11/29 18:07:28
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2020/11/14 10:18:57 (permalink)
    -1 (1)
    oliverb
    I have a colleague with a bad habit of leaving MCLR floating. I wish the program/debug connector instructions were clearer on that point.

    I think most devices have a weak pullup, I've never had an issue with other PICs.
    It sure had me going for a while. ;)
    OtG
    #17
    quickshoe
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2020/10/21 21:54:16
    • Location: 0
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2021/01/09 13:21:44 (permalink)
    0
    Hello OscarTheGrouch, this is an interesting thread that seems applicable to what I'm working on.
     
    Can you explain in more detail how you use RE3 input to hold MCLR high? Does this not interfere with the ICSP?
     
    Much appreciated!
    #18
    Aussie Susan
    Super Member
    • Total Posts : 3859
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Need help with HID Device using PIC18F2550 2021/01/10 18:48:41 (permalink)
    0
    You don't say which programmer you user but assuming it is the PicKit3 or PicKit4 then look at Figure 2-4 of the PicKit3 (or PicKit4) User Guide.
    Susan
    #19
    Jump to:
    © 2021 APG vNext Commercial Version 4.5