Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Teensy as USB hub (two ports)?

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    3

    Teensy as USB hub (two ports)?

    Hello!

    I would like some starting advice for a slightly fine-motor-skills-challenged electronics beginner, please.

    My aim is to build a chording-style split keyboard system, where the user presses a key with a finger of each hand to generate a single letter to the PC. (Modifier keys will be pressed by the thumbs.)

    To minimise the amount of hardware I have to build from scratch, I would like to prototype this with two plain-old off-the-shelf USB 16-key keypads connected to a teensy, which will read the USB output of each keypad and encode the result to the PC with the standard USB keyboard device interface.

    I have seen the USB host shield (http://www.pjrc.com/teensy/td_libs_USBHostShield.html) but it's not clear to me whether the teensy can be wired to two of these at once, and, if it can, whether the teensy can distinguish between a key pressed on the left- or right-hand keypad.

    Would a teensy be capable of acting as an intemediary between the PC and two keypads in this manner?

    Thanks,
    Philip

  2. #2
    Member
    Join Date
    Jan 2013
    Location
    Toronto
    Posts
    25
    Take a look at the "projects" section of this site and you will find similar devices. The good thing about the teensy is that it is recognized as an HID. I did a chord HID keyboard using EMG as an input. Search under EMG and you will find some of the challenges in timing when you try to get two keys to be read as "symultaneous".
    Search through the project guidance and you will find a lot of helpful tips.
    Sorry for just suggesting to "search" but you may come across ideas that you never would have thought about as well as having the benefit of reading how the obstacles were overcome. I spent a year reinventing the wheel until I sat down and read what others had done.

    Paul
    Last edited by PaulH; 11-10-2013 at 02:09 PM.

  3. #3
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,931
    Note, I would think it would easier to get non-USB keypads, rather than dealing with USB input and making a USB output. For example, you can find 16 key membrane keypads fairly easily, such as: http://www.ebay.com/itm/4-x-4-Matrix...item3a8640ee12

    Or this unit that has 4x4 tactile buttons: http://www.ebay.com/itm/4x4-Matrix-1...item27d7ac6c58
    Last edited by MichaelMeissner; 11-10-2013 at 02:53 PM.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,488
    The USB host shield library supports hubs.

    As I recall, there's an extra object that needs to be present in your code for the hub support. Refer to that library's documentation and/or code for details....

  5. #5
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thank you all for the hints and suggestions!

    I hadn't investigated other teensy chording keyboards because I thought my first obstacle would be to combine input from two separate "keyboard" devices (as opposed to reading multiple keys from a single device), I had not considered non-USB keypads at all (I don't know why!), and obviously I don't know enough about the USB protocol to know whether or not a USB hub could tell from which device a keyboard signal came from... I have a LOT of reading to do.

    And it just occurred to me that I can probably prototype the software chording side on a single normal keyboard, using the numberpad for the right hand and some of the normal keys for the left.

    Thanks again: you have all given me much food for thought.

    Cheers,
    Philip

  6. #6
    Member
    Join Date
    Jan 2013
    Location
    Toronto
    Posts
    25
    Take a look at the code that I used for my EMG keyboard. It may help you with the code when you have to hit multiple buttons at a time to get different outputs.
    http://forum.pjrc.com/threads/22024-...rtual-keyboard
    Paul

  7. #7
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    I'm really crossing my fingers (ha!) that I will have an easier problem to solve than a true chording keyboard does, in that I plan to have the right hand be the "value" hand, and the left hand be the "layer" hand. Keypresses are only registered when a (single) key on the right keypad is pressed and released, and it is "the" key on the left keypad that determines the "layer" that is applicable for that right-handed keystroke. I'm not really planning on having true multi-key chords.

    Effectively it would be a 9 to 11 key right-hand keyboard with 9 to 11 or so different "shift" keys for the left hand. Plus, of course, I will have to assign some of the keypad keys of each hand to act as the usual modifiers keys, but these will also behave like the layer-selector keys: they don't do anything until one of the "value" keys are pressed, and whichever modifier keys were held down at the time will determine the result sent to the PC.

    I'm sure it will end up being trickier than that - I will probably have to send through things like the user pressing and releasing the "Alt" key by itself, for instance, but that's the general idea. I would also have to figure out what to do about repeat keys, I guess. AND how to interpret multiple simultaneous right-hand keypresses.

    If I was going to have true multi-key chords... wow, I could theoretically get away with only three or four keys on each hand, plus modifiers. But I'm terrible at playing the piano, which is why I settled on trying out this one-key-per-hand approach. :-)

    Cheers,
    Philip

Posting Permissions

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