Shop OBEX P1 Docs P2 Docs Learn Events
USB output as HID — Parallax Forums

USB output as HID

NurbitNurbit Posts: 53
edited 2012-04-25 08:31 in Propeller 1
Afternoon

Is it possible to make the prop output as USB to act as a HID peripheral?

I'm looking to connect old joysticks etc to the prop and have it connect to the PC to play emulators with.
I know it's been done for just about every other microcontroller, I just wondered if it'd been done for the prop yet.

Comments

  • RaymanRayman Posts: 14,838
    edited 2012-04-24 07:56
    I've seen a Prop act as a keyboard. There's a nice demo of this in this forum somewhere...
    I vaguely remember something about "California Dreaming" as the demo...

    Here it is:
    http://forums.parallax.com/showthread.php?97027

    Their may be a new version though...
  • NurbitNurbit Posts: 53
    edited 2012-04-24 08:03
    Thanks Rayman

    It seems I'm not nearly clever enough to do anything with it yet but it's nice to know for future reference.

    I notice a lot of people saying that the prop isn't fast enough to handle USB properly.

    This comes as quite a surprise as the prop is a multicore chip and other microcontrollers seem to handle it ok (Atmega, etc)
    Can anyone offer an "idiots explanation" as to why this is?

    Thanks
  • ericballericball Posts: 774
    edited 2012-04-24 08:22
    The Propeller is based around software controlled I/O (although the counters and the video generator can provide some level of hardware assistance). Other microcontrollers include specialized hardware to assist with I/O (in particular input). Thus to handle even serial input a cog in the Propeller will need to spend cycles polling the input line or waiting for the next edge, while this is handled in hardware on other microcontrollers. OTOH, this means the Propeller can be very flexible and can handle oddball requirements.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-24 09:16
    Some of the other microcontrollers that are marketed as handling USB also handle it in software without hardware assistance. These also run into the difficulty of handling USB completely in software and, like the Propeller code, they "cheat". Their implementation of USB works in practice, but doesn't quite behave according to the USB specs.
  • NurbitNurbit Posts: 53
    edited 2012-04-24 11:47
    Right, so for example, V-usb for the atmega chips is purely software and may not fully support the USB standard but does enough to get the job done.
    Unless a microcontroller has hardware features to support USB, all chips use a software method of USB?

    The propeller is capable of the same thing through software but doesn't seem to be adopted as much by the prop community.

    Does what I've written above sound about right?

    Just because it hasn't been done, doesn't mean it's not possible.

    I think for now, I'll clone one of the other devices made on the other chips and maybe one day, when I know what I'm doing with the prop I can maybe write my own USB output object.... if I ever get that good :)
  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-24 11:55
    Here's a program that acts as a USB host. It's not quite what you want, but is an example of what can be done. I'm not sure whether someone has written a program where the Propeller acts as a USB client, an HID client particularly. You'd have to browse through the Propeller Forum archives to see unless someone else has a link.
  • NurbitNurbit Posts: 53
    edited 2012-04-24 12:20
    Thanks for your answers so far Mike

    I'll change course slightly with my next question....

    I have a couple of CP2102 USB to TTL adapters.
    I'm assuming I could simplfy the whole thing quite a lot by using one of those.

    Correct me if I'm wrong but could I use the prop to read in from a 9 pin joystick and then output the data to serial, into the CP2102 and use that to interface to the PC?

    If this would work, I could use the pre-written objects for joystick, PS2 controller and Wii controller to make them work with emulators on a PC.

    Or am I talking out of my rectum?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-24 13:00
    Sure, you could use a CP2102 or one of the FTDI USB to TTL chips to provide a serial port to your PC. You could use existing objects to read the various controllers and then pack up the data to send over the serial port. The difficulty will be in setting up the interface on the PC between the serial port and whatever program(s) will use the data. If you have the source programs for the game emulators and feel competent to modify them, then you should be ok. If you don't, then you're not likely to succeed.
  • NurbitNurbit Posts: 53
    edited 2012-04-24 13:23
    Thanks for the clarification Mike.

    It's something I can revisit perhaps when I actually have a clue about what I'm doing :)
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2012-04-24 21:06
    I'd really like to see a prop based USB hid client too but Lack the skill to write one. That said sparkfun has a stamp like arduino that has a whole hid library with lots of hid functions. Given the low volumes I do, I plan to use that and interface a propeller to it to solve this problem .
  • ericballericball Posts: 774
    edited 2012-04-25 05:42
    Nurbit wrote: »
    If this would work, I could use the pre-written objects for joystick, PS2 controller and Wii controller to make them work with emulators on a PC.
    I know various controller to USB adapters already exist. Putting a Prop in there is probably overkill.
  • pik33pik33 Posts: 2,398
    edited 2012-04-25 06:08
    I found this object on OBEX: http://obex.parallax.com/objects/652/ It is USB/BT stack. Maybe it can be changed to attach some other usb devices to propeller.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2012-04-25 07:07
    Nurbit wrote: »

    I'm looking to connect old joysticks etc to the prop and have it connect to the PC to play emulators with.
    I know it's been done for just about every other microcontroller, I just wondered if it'd been done for the prop yet.

    I took a sideways approach to this which worked well..

    I used the Propeller as a serial joystick to the PC which worked well with several emulators.

    Here's the project: http://gadgetgangster.com/news/54-new-projects/518-funtendo.html

    Edit:
    While we don't have the Propeller Platform in stock currently, you could use the Quickstart combined with the QSTerminal board to accomplish the same project. There are just enough connections of the QSTerminal to support the original project.


    OBC
  • NurbitNurbit Posts: 53
    edited 2012-04-25 07:35
    Jeff

    You've hit the nail right on the head there.
    That's exactly what I had in mind

    Thank you very much :)
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2012-04-25 08:31
    If you get stuck on the conversion for the Wii controller, just let me know.

    I should probably do a revision of the article for the Quickstart/QSTerminal combination.
    It's actually pretty cool now that the price of the build is $40.00 instead of $60.00 with the other combination.

    OBC
Sign In or Register to comment.