sdmeijer / ShrimpKey

Turn 9 everyday objects in to a touchpad
http://fromScratchEd.nl
4 stars 3 forks source link

Problem with USB initialisation logic? #1

Open cefn opened 11 years ago

cefn commented 11 years ago

I have been attempting to build a breadboard analog to the ShrimpKey but ran into a problem which seems to originate with the code in this repo or something I'm missing about the wiring selections.

Thought there must be something wrong with my wiring, or the components. Finally worked back to a test-build against the original rancidbacon repo and reference wiring example at... http://code.google.com/p/vusb-for-arduino/source/browse/#hg%2Flibraries%2FUsbKeyboard ...and found the UsbKeyboardDemo1 example actually worked, so there couldn't be a fundamental issue with the components or layout.

However, I've so far been unable to proceed from here to getting the ShrimpKey code working. The issue I face is that the USB initialisation doesn't establish an addressable USB keyboard - issues visible in dmesg on a Lubuntu-based laptop;

Specifically you see errors like this in dmesg... new low-speed USB device number 99 using ohci_hcd device descriptor read/64, error -110 unable to enumerate USB device on port 2

Switching to Rancidbacon's original, the identification works fine and keyboard events can be sent successfully. You see instead... new low-speed USB device number 99 using ohci_hcd generic-usb 0003:4242:E131.0009L input,hidraw0: USB HID v101 Keyboard [rancidbacon.com UsbKeyboard as /devices/pci0000:00/0000:00:13.0/usb2/2-2/2-2:1.0/input/input18

To get the system working I have D+ attached to PD2 through 68Ohm and to ground through reversed 3.6v 500mW zener, I have D- attached to PD4 through 68Ohm, to VCC through 2.2KOhm and to GND through reversed 3.6v 500mW zener, in addition to taking V5 power from the USB pins.

Of course there are different wiring defaults in your case, but switching the D- 68Ohm connection to your preferred PD3, and the 2.2kOhm to your preferred PD7 doesn't work, sadly.

I tried starting with ShrimpKey.ino and settings.h from your repo, combined with rancidbacon's UsbKeyboard. To get this to compile, I merged the changes from your UsbKeyboard.h back into the original, and fixed issues with const PROGMEM as per http://gnuski.blogspot.co.uk/2013/02/must-be-const-vusb-libraries-for.html I then verified the original rancidbacon demo still worked (which it does, though it generates spurious 'enter' Key events compared to the original, owing to some edit or another (does a ShrimpKey normally generate enter events as a heartbeat?). However, the ShrimpKey example cannot be made to work (my test circuit is set up with a conventional button and pull-up on PD9 to avoid issues around the conductivity).

However in all cases (using your code direct, using rancidbacon's UsbKeyboard library, or their library with your UsbKeyboard merges) I can't get the USB device to be recognised when running the ShrimpKey sketch.

Any suggestions what to try? Are there initialisation steps which you can see in UsbKeyboardDemo1 which need to be replicated?

It's feasible that the issue arises from the compiler environment somehow interacting with your code, so note that I'm using Arduino 1.0.5 for Linux 32-bit downloaded from arduino.cc (the version packaged with Ubuntu Saucy has an issue with assembler flags on any v-usb builds).

cefn commented 11 years ago

Here's a deep link to the reference code which works... http://code.google.com/p/vusb-for-arduino/source/browse/libraries/UsbKeyboard/examples/UsbKeyboardDemo1/UsbKeyboardDemo1.pde ... so if it's possible to give me a clue what steps I can take from here to verify the ShrimpKey code, that would be very useful.