Teensy as a USB Keyboard - erratic behavior (using wheezy)


11 posts
by rayhaque » Wed Oct 24, 2012 5:51 pm
Hello all,

I am working on a project involving a very old keyboard (basically a matrix keypad). I have mapped all the keys using a Teensy 2.0 USB device and some sample code.

When connected to a PC running Windows, it works as expected. When connected to my Bohdi Linux laptop, it works as expected. But when plugged into my Pi, it goes nuts.

If I press a key three times in a row, sometimes it comes out only once - or it may act as if I am holding the key down and repeat until another key is pressed. If I plug in a standard USB keyboard along-side of it, I get normal keyboard functionality out of the standard keyboard.

Is there some strange incapability between the Pi and the Teensy? I am leaning toward a driver problem with whatever was supplied into this Wheezy build ... but it seems to use the same thing as by Bohdi Linux laptop and it runs fine there. Comparing the /var/log/message output between the two distro's reveal that they are using the same driver (for the Teensy itself anyway - not the USB bus).

I am using the "wheezy dev' build" available from this site.

Any clues or guidance is greatly appreciated.
User avatar
Posts: 12
Joined: Wed Oct 24, 2012 5:44 pm
by malakai » Wed Oct 24, 2012 5:57 pm
Most likely a power related issue test on powered USB hub.

Everything you have posted about it's behavior can be duplicated with Power Hungry keyboards. Including one of my multimedia keyboards.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)
User avatar
Posts: 1383
Joined: Sat Sep 15, 2012 10:35 am
by rayhaque » Wed Oct 24, 2012 6:03 pm
malakai wrote:Most likely a power related issue test on powered USB hub.


That's the same thing that I was thinking. However, I tried disconnecting my USB hub and plugging only the keyboard in, while powering from a 1A USB power supply and I got the same behavior. :?
User avatar
Posts: 12
Joined: Wed Oct 24, 2012 5:44 pm
by obcd » Wed Oct 24, 2012 6:43 pm
try to reduce the usb bus speed by adding the proper command to the end of /boot/cmdline.txt file.
see if it makes a difference.
Posts: 908
Joined: Sun Jul 29, 2012 9:06 pm
by rayhaque » Wed Oct 24, 2012 8:13 pm
obcd wrote:try to reduce the usb bus speed by adding the proper command to the end of /boot/cmdline.txt file.
see if it makes a difference.

How does one go about that? Can you point me to a reference? I am reading through notes about config.txt and I don't see any way to reduce the USB speed.

Also - I tried the Arch Raspberry Pi release, and the keyboard works flawlessly. It is definitely limited to something that the 'wheezy' distro does differently.
User avatar
Posts: 12
Joined: Wed Oct 24, 2012 5:44 pm
by obcd » Wed Oct 24, 2012 8:34 pm
add dwc_otg.speed=1 to the end of /boot/cmdline.txt file
Posts: 908
Joined: Sun Jul 29, 2012 9:06 pm
by daveca » Wed Oct 24, 2012 10:44 pm
"If I press a key three times in a row, sometimes it comes out only once - or it may act as if I am holding the key down and repeat until another key is pressed"

That is exactly the same thing as happened on my pi with a commercial wireless KBD and mouse.

Ifs RF interference. Youre playing with fire trying to patch together gadgets.

PS I just tested the keyboard too close to the Pi theory by starting the Pi,then moving keyboard nearby, the mouse pointer immediately fell to the Taskbar and remained there until the keyboard was removed and machine rebooted.

Youre experimenting with a complex electronic and RF device thats subject to all sorts of interference problems, thats stated in the Pi documentation.
Posts: 15
Joined: Wed Oct 24, 2012 9:19 pm
by rayhaque » Thu Oct 25, 2012 12:17 pm
obcd wrote:add dwc_otg.speed=1 to the end of /boot/cmdline.txt file

Thank you obcd, this seems to have resolved the problem!! :D
User avatar
Posts: 12
Joined: Wed Oct 24, 2012 5:44 pm
by thradtke » Thu Oct 25, 2012 1:09 pm
daveca wrote:Ifs RF interference.

I thought packets are resent when not acknowledged. Shouldn't that exclude missing a key-up or key-down report?
Rocket Scientist.
Posts: 491
Joined: Wed May 16, 2012 5:16 am
Location: Germany / EL
by rayhaque » Thu Oct 25, 2012 2:01 pm
I do not believe this to be a case of interference. The problem ONLY existed when using Debian Wheezy. All other distributions worked without any problems. For that matter, this same hardware worked fine with my Windows 7 PC.

Since lowering the USB bus speed using the trick that obcd suggested worked, I am going to assume it was a bus speed issue. I am also assuming that other distributions do that by default, or use a different USB driver altogether since none of them gave me this problem.
User avatar
Posts: 12
Joined: Wed Oct 24, 2012 5:44 pm
by rayhaque » Thu Oct 25, 2012 3:46 pm
I have noticed an undesirable side effect. When I use the option to lower the USB bus speed, it renders my USB hub worthless. If I plug in any device (even a USB number pad) it disables all USB devices, drops network connection and then resets the USB bus.

I may just end up working with the Arch distro. It seems to work flawlessly as-is.
User avatar
Posts: 12
Joined: Wed Oct 24, 2012 5:44 pm