Shop OBEX P1 Docs P2 Docs Learn Events
All I want is to be a USB HID slave device — Parallax Forums

All I want is to be a USB HID slave device

Skywise711Skywise711 Posts: 37
edited 2015-02-10 13:48 in Propeller 1
I've been turning my brain to mush pouring over the various threads from over the years (that I can find) regarding USB communication and the Propeller. And it's making my head spin (pardon the pun). In no small part because the solutions I find are way overkill. Everyone is trying to make a USB host.

All I want is low speed HID slave device communication. That's all my device will be.

I don't need all the fancy USB host capabilities, because I'm nothing but a slave device with a single minded purpose.

I don't need full or high speed, because I'm nothing but an HID device with little data to transfer, like a keyboard, or mouse, or joystick. Besides, I "think" that's all an HID device can be anyway, if I understand USB specs correctly?

The purpose is for more input to flight simulator software. The software can map upwards of 1600 buttons to whatever function. I just need a few more buttons than my joystick provides. I want to make such a box of buttons.

Eventually I want to be able to have more sliders/pots as well.

I've also looked at FTDI chips, but from what I read they all want to be hosts. I can not seem to confirm from documentation that I can use one as a slave HID device.

At 1.5mbits the Prop should surely be fast enough to do this "relatively" simple task. But everyone seems hell bent on being full blown full speed host controllers.

And, I have yet to wrap my head around the USB specifications enough to try something on my own.

Any pointers?

Brian
«1

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2015-02-05 18:18
    This might be a case of using the back end of a large screwdriver as a hammer, but have a look at this thread,,

    http://forums.parallax.com/showthread.php/97027-California-Dreamin

    Personally, I think USB HID doesn't seem to be a job that the Propeller is suited for. (and I love the Propeller) There are several non-prop, inexpensive solutions to this.

    Jeff
  • Skywise711Skywise711 Posts: 37
    edited 2015-02-06 01:30
    Thanks for the quick reply, Jeff.

    I had found that thread, and looked at Brad's code. It's pretty dang close to what I need. It just has two complications: it's copyrighted, and he admits it's not USB compliant. Those may cause problems for commercial possibilities.

    I'll concentrate on looking for an external chip of some kind, then.

    Brian
  • MJBMJB Posts: 1,235
    edited 2015-02-06 04:23
    Personally, I think USB HID doesn't seem to be a job that the Propeller is suited for. Jeff
    There is even a USB low speed HID implementation for the small AVR ATmegas (8-Bit/12MHz, not 100% USB compliant - but working)
    So clearly it is IMPOSSIBLE for the Propeller ;-) with 8*32Bit 80/100MHz

    EDIT: http://www.obdev.at/products/vusb/index-de.html
    http://www.obdev.at/articles/implementing-usb-1.1-in-firmware-de.html
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-02-06 05:06
    MJB wrote: »
    There is even a USB low speed HID implementation for the small AVR ATmegas (8-Bit/12MHz, not 100% USB compliant - but working)
    So clearly it is IMPOSSIBLE for the Propeller ;-) with 8*32Bit 80/100MHz

    EDIT: http://www.obdev.at/products/vusb/index-de.html

    Unfortunately the Prop is really running at 20MHz and not a multiple of the USB 12MHz rate either. However by running the Prop at 96Mhz we end up with a 24MHz CPU speed and a nice multiple of 12MHz. So I wouldn't consider it IMPOSSIBLE as we like to say hoping that someone will take the challenge and prove us wrong, but I would consider USB a hack and a huge waste of resources to accomplish little.....normally.

    I'm thinking that to be able to at least implement USB HID would be a useful addition to the Tachyon O/S, but to do this with minimal resources, as we do in Tachyon and now in V3 which I am working on I can save hub space by loading cogs from EEPROM or SD at runtime, and in this case it will be the low-level USB driver with minimal code space taken by high-level handlers. There is no reason though that this can't be incorporated in the current version either, but the cog image can only be reused for buffers (code needs to be backed up which would overwrite the source image in EEPROM), which is a bit of a waste.
  • MJBMJB Posts: 1,235
    edited 2015-02-06 06:14
    Unfortunately the Prop is really running at 20MHz and not a multiple of the USB 12MHz rate either. However by running the Prop at 96Mhz we end up with a 24MHz CPU speed and a nice multiple of 12MHz. So I wouldn't consider it IMPOSSIBLE as we like to say hoping that someone will take the challenge and prove us wrong, but I would consider USB a hack and a huge waste of resources to accomplish little.....normally.

    I'm thinking that to be able to at least implement USB HID would be a useful addition to the Tachyon O/S, but to do this with minimal resources, as we do in Tachyon and now in V3 which I am working on I can save hub space by loading cogs from EEPROM or SD at runtime, and in this case it will be the low-level USB driver with minimal code space taken by high-level handlers. There is no reason though that this can't be incorporated in the current version either, but the cog image can only be reused for buffers (code needs to be backed up which would overwrite the source image in EEPROM), which is a bit of a waste.
    Hi Peter,
    forgot the 4 clocks / instruction for a second :-( ...
    But 24MIns/sec is still double the AVR.
    so a COG should be able to handle it.
    Not that I would need it atm ...

    But sure, a Tachyon COGlet feeding a USB buffer in HUB ... might be (IM)possible.
  • MJBMJB Posts: 1,235
    edited 2015-02-06 06:35
    Skywise711 wrote: »
    Eventually I want to be able to have more sliders/pots as well.
    Brian
    you could even run an autopilot ;-) on the Prop ....
    no - this would need input from the plane model ...
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-02-06 07:07
    > I've also looked at FTDI chips, but from what I read they all want to be hosts
    They have plenty of usb slave devices but I guess they are not HID.

    Silabs CP2110 and CP2112 are HID devices and don't need drivers, but they can NOT be set to emulate a keyboard.
    But if you can program in C# I'm pretty sure you could create a windows program to send fake keyboard presses to OS.
    http://www.silabs.com/products/interface/usbtouart/Pages/usb-to-uart-bridge.aspx

    Prop should be able to do this, it's just that the USB protocol with endpoints etc makes your head spin.
    Probably will take 2months of fulltime programming to do this, anyone with those skills is unfortunately pretty busy with a day job.
  • abecedarianabecedarian Posts: 312
    edited 2015-02-06 11:04
    TI has more than a few MSP430 and ARM chips that can do USB HID, CDC and MSC
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-02-06 12:40
    TI has more than a few MSP430 and ARM chips that can do USB HID, CDC and MSC

    Based on this thread, it looks like TI wrote a ready-to-go example of using the TM4C family of microcontrollers for USB HID comms. I'd strongly encourage you to pick up one of those cheap dev boards and play around with it. I've use the LM4F120 with StellarisWare (the predecessor to TM4C and TivaWare) and they're very powerful, simply, cheap boards with great software libraries. Stellaris/TivaWare is actually where I got the inspiration for PropWare.

    This is their cheapest dev board I think http://www.ti.com/tool/ek-tm4c123gxl. The equivalent to my LM4F120. The only question is whether or not you can get that example project running on this dev board - the one it's written for (the 232) is a couple hundred dollars I think.
  • T ChapT Chap Posts: 4,223
    edited 2015-02-06 12:53
    I use the CP2110 Silabs part, and also use an app I built in XOJO that can read the data from the CP2110 Uart(Propeller) and convert input to key codes, mouse moves, whatever you want.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-02-06 13:03
    The CP2110 looks awesome! I can't seem to find any "plug 'n' play" breakout boards - like those found on adafruit or sparkfun. Anyone seen such a thing?
  • David BetzDavid Betz Posts: 14,516
    edited 2015-02-06 13:05
    and now in V3 which I am working on I can save hub space by loading cogs from EEPROM or SD at runtime
    That support has been in PropGCC for ages. However, I don't think anyone has ever used it. :-(
  • altosackaltosack Posts: 132
    edited 2015-02-06 13:59
    David Betz wrote: »
    That support has been in PropGCC for ages. However, I don't think anyone has ever used it. :-(

    ?!?? I use it !

    In my Makefile, anything I put on the line COGSRC= gets put in hubram, any file on ECOGSRC= gets compiled, objcopied, and linked as an ECOG.

    It could potentially save up to 14K of hubram; the most it's ever saved me is 7K, which is enough that I think many would be interested. I don't use SimpleIDE; is it a clickable option there ? I also think someone could do this in Spin without too much trouble.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2015-02-06 14:10
    I know of a recent product with almost identical requirements that was accomplished with a Cypress microcontroller and Adafruit's Bluefruit HID module. The microcontroller used is irrelevant since the Bluefruit module is the key to the solution. A propeller would be just as easy. I can't give more details due to an NDA, but check out the module:https://www.adafruit.com/products/1535
    Unfortunately out of stock right now......
  • David BetzDavid Betz Posts: 14,516
    edited 2015-02-06 14:16
    altosack wrote: »
    ?!?? I use it !

    In my Makefile, anything I put on the line COGSRC= gets put in hubram, any file on ECOGSRC= gets compiled, objcopied, and linked as an ECOG.

    It could potentially save up to 14K of hubram; the most it's ever saved me is 7K, which is enough that I think many would be interested. I don't use SimpleIDE; is it a clickable option there ? I also think someone could do this in Spin without too much trouble.
    Nice! I'm glad someone found it useful :-)
  • Skywise711Skywise711 Posts: 37
    edited 2015-02-06 16:34
    Just wanted to thank everyone for their suggestions. I have been learning more about how USB works and have learned something VERY important.

    Implementing USB in software in the Propeller is a DEAD END if you intend a commercial product. Not due to technical limitations, but due to the Vendor ID.

    Anyone intending to make a USB device is *REQUIRED* to purchase a unique Vendor ID from the USB Implementers Forum, and that will cost you $5000 US Dollars.

    There is no such thing as a general purpose VID that us small fry can use. If you just "pick one", you'll be stepping on someone else's VID that they paid for.

    The only choice is to purchase someone else's product which implements the USB device functions you require. That company will already have their VID, and you'll just be using their device. An example are the FTDI chips.

    Upon discovering this, I found various websites discussing this very problem.

    It should be called "FUSB" for F U Small Business.

    Oh well, another idea bites the dust.

    Brian
  • T ChapT Chap Posts: 4,223
    edited 2015-02-06 17:42
    Why are you hung up on a vendor ID?
  • Skywise711Skywise711 Posts: 37
    edited 2015-02-06 17:54
    T Chap wrote: »
    Why are you hung up on a vendor ID?

    Because I was looking into the possibility of this becoming a commercial product.

    Brian
  • T ChapT Chap Posts: 4,223
    edited 2015-02-06 17:57
    Tons of commercial products use Silabs, FTDI.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2015-02-06 18:37
    At least 75% of the commercial products that I build at work utilize FTDI or Silabs devices for USB. There is no reason for you to care about the vendor ID in regards to viability of your product.

    I believe Cypress also has a low cost mcu that enumerates as a driverless USB HID device. It should support SPI or I2C communication to be paired with the Propeller for button reading/mapping.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2015-02-06 18:45
    In regards to the Cypress device, start here:http://www.cypress.com/?rID=39404
  • Skywise711Skywise711 Posts: 37
    edited 2015-02-06 19:30
    In regards to the Cypress device, start here:http://www.cypress.com/?rID=39404

    Thank you. I'll look into it.

    Brian
  • Skywise711Skywise711 Posts: 37
    edited 2015-02-06 20:34
    In regards to the Cypress device, start here:http://www.cypress.com/?rID=39404

    So much for that....

    http://www.cypress.com/?id=4&rID=33410

    I would have to purchase a VID for commercial use.

    Nice chip, though.

    Brian
  • T ChapT Chap Posts: 4,223
    edited 2015-02-06 21:12
    VID and PID are the absolute last things that should be on the mind of someone wanting to launch a product. 5k is a speck of dust compared to the time effort money and energy to successfully get a venture off the ground. You are putting the cart before the horse. Forget all this Smile and focus on the product.
  • Skywise711Skywise711 Posts: 37
    edited 2015-02-06 21:39
    T Chap wrote: »
    VID and PID are the absolute last things that should be on the mind of someone wanting to launch a product. 5k is a speck of dust compared to the time effort money and energy to successfully get a venture off the ground. Your are putting the cart before the horse. Forget all this Smile.

    Must be nice for you to have five grand just laying around, eh? Maybe you can buy my VID for me?

    5 grand is an effing lot of money for someone like me. I couldn't even scrape that up to buy parts for production. I'm on a seriously low budget. If I had 5 grand just laying around for something like that, I wouldn't be looking for ways of developing some small device to try to sell and EARN some money.

    I'm beginning to regret even coming here asking for help. I keep getting answers to the questions I'm not asking.

    Brian
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2015-02-06 22:33
    The Cypress Appnote you linked to is older and more directed to USB Controllers. Since then, USB HID devices have changed some perspectives on VID/PID from Cypress, but not everything is front and center on their website. To get more specifics regarding a Cypress HID solution, contact them directly and talk with an FAE (Field Applications Engineer).

    On the other hand, Microchip has a fairly standard policy regarding handing out PIDs under their VID without charge. I am only vaguely familiar with their hardware, but you should be able to find products of theirs to complete you product.
    http://www.microchip.com/usblicensing/Default.aspx
  • Skywise711Skywise711 Posts: 37
    edited 2015-02-06 23:52
    The Cypress Appnote you linked to is older and more directed to USB Controllers. Since then, USB HID devices have changed some perspectives on VID/PID from Cypress, but not everything is front and center on their website. To get more specifics regarding a Cypress HID solution, contact them directly and talk with an FAE (Field Applications Engineer).

    On the other hand, Microchip has a fairly standard policy regarding handing out PIDs under their VID without charge. I am only vaguely familiar with their hardware, but you should be able to find products of theirs to complete you product.
    http://www.microchip.com/usblicensing/Default.aspx

    Thank you again, Andrew.

    I've seen the Microchip form. It's a possible solution. It would mean investing in a new MCU, and learning it. But that's a much smaller investment than buying a VID.

    FTDI also offers a PID service, but it doesn't look like any of their chips will do the job.

    If Cypress offers a PID solution, then it just becomes a peripheral chip to the Prop I already know.

    It sure would be nice if the P2 ends up with USB somehow, and if Parallax can offer a PID service. After all I've been reading about USB, it's my opinion that it would be a significant selling point. I can see why folks were clamoring for it.

    Brian
  • jmgjmg Posts: 15,173
    edited 2015-02-07 00:46
    Skywise711 wrote: »
    The purpose is for more input to flight simulator software. The software can map upwards of 1600 buttons to whatever function. I just need a few more buttons than my joystick provides. I want to make such a box of buttons.

    Eventually I want to be able to have more sliders/pots as well.
    Is this your own Sw, or closed, 3rd party ?
    How exactly does it convert HID USB traffic into 1600 buttons ?

    Skywise711 wrote: »
    I've also looked at FTDI chips, but from what I read they all want to be hosts. I can not seem to confirm from documentation that I can use one as a slave HID device.

    Err, most FTDI parts are USB slaves, not Hosts ?

    Why is HID so important ? Is that the only interface choice your target SW offers ?

    SiLabs have CP2110 HID supported devices. and they also have CP2112 for SMBus/I2C Bridge

    and Exar have XR21B1421 as HID device
    http://www.exar.com/connectivity/uart-and-bridging-solutions/usb-uarts/xr21b1421/

    There are Eval boards for CP211x and XR21B1421, get a couple and try them.
  • T ChapT Chap Posts: 4,223
    edited 2015-02-07 04:35
    While customization of the USB configuration data is optional, customizing the VID/PID combination is strongly recommended. A unique VID/PID will prevent the device from being recognized by any other manufacturer’s software application. A vendor ID can be obtained from www.usb.org or SiliconLabs can provide a free PID for the OEM product that can be used with the Silicon Labs VID.

    Build a product that somebody else wants to buy, then worry about this minutia.
  • MJBMJB Posts: 1,235
    edited 2015-02-07 06:32
    BASCOM provides a USB library for the AVR-USB chips, including HID examples etc.
    see http://www.mcselec.com
    but I do not now yet how they handle the VID.
    since it is a good question I asked Marc the creator of BASCOM and will post the answer here.
    And with BASCOM very easy to program.
Sign In or Register to comment.