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

All I want is to be a USB HID slave device

2»

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2015-02-07 08:24
    Corrected Link: http://www.mcselec.com/
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-02-07 09:37
    Why worry about VID yet?, get a bit bang UDB HID working at 100% USB1.1 (1.5 Mbps) compliance on the Prop first.

    And after you donate that code to obex, I'm pretty sure we can pool the money to raise the $5K. with Parallax paying first half :)
    So Parallax gets their own VID and can hand out PIDs at requests for us.


    Going for Low-speed HID only, will make it possible:
    Low speed devices have 2 additional endpoints on top of the default pipe. (4 endpoints max)
    Maximum data payload size for low-speed devices is 8 bytes.
    http://www.beyondlogic.org/usbnutshell/usb3.shtml

    HID only supports interrupt pipes which do not use the ZLP.
    It's not needed because the host/device always sends the exact number of bytes specified in the HID report descriptors
    Also, with interrupt unlike bulk you get a maximum of 1 transfer per frame so the ZLP is not needed to end the transfer.

    first thing you should try, emulate a mouse
    http://www.usbmadesimple.co.uk/ums_5.htm

    Prop need to run at 96Mhz (6mhz crystal) as to get exact time base.
    A (normal) cog instruction will take 41.7nS
    and it can fit 16 of them between each toggle of d+d- pins.
  • Skywise711Skywise711 Posts: 37
    edited 2015-02-07 14:57
    -RANT ON-

    First, to all of you who keep saying I'm worrying about the VID/PID too soon. I don't even have $5000. I have maybe.... MAYBE $1000 I can throw at this. Period. For everything. And that's if I can prove it will sell. So yes, worrying about the cost of EVERYTHING in advance is important. What good does it do me to make the best damned product in the world if I won't have the money to buy the VID to legally sell the product? Hmmmm????

    Next, let me clarify my goal. TO MAKE MONEY. I'm researching this as an idea to generate income because, unemployment sucks. Hence why I don't have a spare 5 grand just laying around.

    If I can't get to the level of fully functional final prototype within that budget, it's a no-go. At least then I might be able to make a go of it with a Kickstarter campaign. I've already researched several ideas and have had to shelve them for now due to lack of resources. And resources doesn't mean just money.

    And a final thought: if I were to somehow manage to make low speed USB work on the Propeller in software, and had to shell out 5 grand to get my VID so I could sell my product, why should I upload the code to the OBEX? Call me greedy and not community oriented, but that's an awful lot of work and money to give away, especially in light of my low income status and goal of trying to fix that by MAKING MONEY so I can have that 5 grand to spare (actually, more) someday. Sorry if it offends your sensibilities, but you're not in my shoes.

    (Tony's idea of people pooling with Parallax to buy a VID is a possible solution, but not guaranteed to work. From my point of view, I would have to know that it WILL happen before I invested in that avenue. But I would opine that Parallax should look into getting a VID and adding USB functionality to the P2. It would make a lot of Prop users happy.)

    -RANT OFF-

    Anyway, apparently I have not been clear and concise enough about what I am trying to accomplish. I had tried to reduce my query to the bare essentials in an attempt to get a direct answer, and that has caused people to give me answers which conflict with what I asked. I left things open for people to make too many assumptions.

    To clarify what I'm trying to do. Basically, nothing more than a custom USB joystick. Actually, just the electronics portion. The end user would supply the inputs (buttons, pots) to the board, which then sends it off via USB to the computer. So it MUST enumerate as a driverless HID gaming device. Beyond that, the gaming software takes care of the rest. The device just shows up as a joystick with some sliders and buttons, which the user of the software then assigns to the desired functions for use within the game.

    To give a concrete example. I use X-Plane flight simulation software. I have an old but trusty MS Sidewinder force feedback joystick. It has 4 analog axes (joystick, twist grip, throttle) and 12 buttons (4 on hat). I plug in the joystick. I'm not using the extra drivers. It just shows up in the OS because they all can handle a joystick with generic drivers already present in the OS. In the X-Plane software I have to go to a settings screen to assign all the analog axes and buttons to my desired functions. For example the physical joystick axes becomes elevator and rudder, the physical throttle axis becomes the throttle. An example of customization is the twist grip. Usually that gets set as rudder, but since I also have rudder pedals I've instead assigned the twist grip to left-right view. That way I can quickly look left and right by twisting the joystick. Buttons are assigned as desired, things such as landing gear, flaps, flight trim, etc.... Whatever you want. Although different aircraft have different needs - notably fixed wing vs helicopter.

    But, an airplane has LOTS and LOTS of buttons, with all those instruments, radios, autopilot, engine controls, etc.... A player has to use the mouse to click on the buttons to do anything. Which works, but that can create ease of use complications.

    Some people go all out and build flight sim cockpits. There are companies that build simulated flight instruments and controls for this purpose. But they cost. A lot. By the time one buys all the parts to replicate a Cessna 172 cockpit panel, you've spent enough money to buy flight lessons to get your private pilots certificate for a real plane.

    So, I'm looking at ways to accomplish this, or more specifically help others to accomplish this much cheaper. And the first step is being able to interface a butt-load of buttons via USB to the computer.

    So that's all I'm trying to do. Make a device which has a bunch of inputs, which plugs into the computer via USB, and appears as "just another joystick" but which offers more analog axes, and more buttons. Lots of buttons.

    To answer the question about "nearly 1600 buttons" - X-Plane, in it's advanced assignments menu, can assign that many buttons to whatever functions you desire. Just need more USB buttons. It looks like X-Plane is allowing configuration of the maximum number of buttons that USB allows.

    As to possible solutions:

    Propeller USB in software - due to the VID cost issues outline above, besides the likelihood of it not even being technically feasible, this is a no-go.

    Use another MCU - I could switch to an appropriate PIC, or the Cypress chip. But it would mean investing in a new MCU. It's not just the cost of the chip itself, but the associated investment in programming materials and learning the new device. I'm already comfortable with the Prop even if my skills aren't top notch.

    Propeller interfaces to USB chip - to me this would be the ideal solution. I can stick with the Prop I already know and have experience with in talking to other chips. But I haven't found a chip which fits the bill that isn't also an MCU in it's own right (unlkess I'm forgetting something mentioned). Ideally it would be something like the FTDI chips where you just talk to the chip and the chip handles all the low level stuff, enumeration, protocols, etc.... But one that can be configured to enumerate as a driverless HID joystick.

    In either of the last two cases, if the chip maker sub-licenses their VID and assigns a free PID to me, that's a workable solution. If my product were popular enough that I started selling lots of them, THEN I'd have the money to make buying my own VID worth it.

    Brian
  • jmgjmg Posts: 15,173
    edited 2015-02-07 17:38
    Skywise711 wrote: »
    So it MUST enumerate as a driverless HID gaming device. .... But I haven't found a chip which fits the bill that isn't also an MCU in it's own right (unlkess I'm forgetting something mentioned).

    HID devices that are not MCUs have already been referenced above.
  • AribaAriba Posts: 2,690
    edited 2015-02-07 18:18
    You can buy preprogrammed USB-PICs for a lot of USB classes. Search for IO-Warrior. There are many Jostick/Gamepad variants.
    For example this one: http://www.saelig.com/product/IC2032.htm

    Andy
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2015-02-07 18:19
    Brian,

    As a nearly decade long Propeller user myself I can certainly sympathize with your position, but in this case I suspect you will be better served by a solution that is ready to go and much more inexpensive to implement.
    Use the Propeller for things it is good at. Use other technologies the same way.

    Jeff
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-02-07 18:31
    here is a free to use gaming ( USB Joysticks)
    VID: 0x16c0 PID:0x27dc
    Courtesy of: Van Ooijen Technische Informatica

    But in 9years no one have created a 100% working usb slave on the Prop (preferable it should run in one cog)

    With some shortcuts like avoid bit stuffing as you can have max six 1s bits in a row, so do a 7-to-8 encoding where the single value that have all 7 bits with 1s is handled by setting bit7=1
    You later shift in place to create 32bit longs etc.
    Prop should be able to do NRZI in real-time.

    I spent today studying USB specs and it looks very feasible and I don't really get why it whas not implentemed as a boot for the Prop1 in the first place.
    Can you imagine the much broader appeal it would have if it had USB1.1 nine years ago, ftdi chips cost like $5 back then.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-02-07 20:02
    Low Speed HID is certainly doable on the prop. It just hasn't been done properly. There have been attempts at a slave and even FS (using multiple cogs) but nothing complete.

    As for VID/PID pairs, there are some which are usable, although not legal. Just search the internet. There were some that someone was selling until the USB Org threatened prosecution. From my understanding, as long as you do not advertise your product as USB compliant there is no control over using any numbers (which cannot be patented) for you VID/PID pairs, so as long as you don't use any that are likely used by other products, and your sales are to hobbyists, you should be fine.

    I have looked at doing slave HID and/or VCOM for the prop (and the P2), but nothing I have done is usable.
  • Skywise711Skywise711 Posts: 37
    edited 2015-02-07 20:33
    Ariba wrote: »
    You can buy preprogrammed USB-PICs for a lot of USB classes. Search for IO-Warrior. There are many Jostick/Gamepad variants.
    For example this one: http://www.saelig.com/product/IC2032.htm

    Andy

    Andy, this is AWESOME!!!!! These chips would work very well for where I want to go with my project ideas. I don't even need a Propeller, but I can already see uses for the two chips to work together.

    Thank you.

    Brian
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-02-07 22:47
    usb1.1 is a peace of cake, look at all those free cycles to get bytes from hub for buffer etc
                  mov t1, sync_nak
                  mov bitlen, #16
                  or outa, d_-_pin    'j-state
                  or dira, dpins
                             
    loop          shr t1, #1 wc             
         if_nc    xor outa, dpins     'Non-return-to-zero inverted
         if_nc    mov bitstuf, #6  
         if_c     sub bitstuff,#1 wz
      if_c_and_z  shl t1, #1         ' insert 0 bit
      if_c_and_z  add bitlen, #1     ' stuff bit need to be added to length
                  nop
                  nop
                  nop
                  nop                  'look at all this free time to do something
                  nop
                  nop
                  nop
                  nop
                  nop
                  djnz bitlen, #loop    
                  andn  outa, dpins   ' SE0
                  waitcnt 124 cycles   'look at all this free time to do something   
                  or outa, d_-_pin
                  andn dira, dpins
    sync_nak long %01011010_10000000
    
  • msrobotsmsrobots Posts: 3,709
    edited 2015-02-08 04:18
    Funny thread title.

    Honestly, I never wanted to be a USB HID slave device.

    Enjoy!

    Mike
  • MJBMJB Posts: 1,235
    edited 2015-02-10 13:35
    MJB wrote: »
    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.

    as promised:
    http://www.mcselec.com/index.php?page=shop.product_details&flypage=shop.flypage&product_id=92&category_id=20&option=com_phpshop&Itemid=1
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-02-10 13:48
    What where they thinking when only assigning a word for VID?
    After 65000 sold there is none left.
    Though that will result in a 260Million annual revenue, they worry about that then they sitting on the beach on their private island.

    As they don't allow to sub-lease a VID, when they run out of VIDs I guess USB.org sublease a few main VID they saved for themselves.
Sign In or Register to comment.