Go Down

Topic: AVRUSB running on Arduino hardware with minishield (Read 10 times) previous topic - next topic

follower

Hi all...

Just a quick update on getting AVR-USB to run with the Arduino.

I've just managed to put together a "mini" expansion shield with a USB "B" socket and the 2 diodes and 3 resistors needed to create a USB connection to the Arduino hardware. (Have plans to upload schematic/diagram/photos eventually.)

After some code modifications (to fit using ATmega168 etc) I got Linux and OS X recognising the demo devices. I'm currently trying to get HID keyboard data to be recognised.

So, while it's not yet integrated with the Arduino libraries it's at least progress to have a shield working and the code running on the Arduino hardware.

You can follow AVRUSB on Arduino progress here.

--Phil.


nrolland

Nice
Where did you get the USB receptacle and how much did you pay for ?

Nicolas

xSmurf

digikey, sparkfun, futurlec all carry them and they are usually around $1.
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

follower

I've now got the PowerSwitch USB echo demo working from an Arduino sketch as I'm flashing an LED every second.

This test sends a character from the host (a Linux box in this case) and the USB device responds with the same character.

I haven't made any changes to the core Arduino code which will probably result in an issue if an interrupt happens at the wrong time.

But it's something, and it's currently flashing away happily. :-)

Here's the exciting screenshot:

Code: [Select]
sudo ./powerSwitch test
test succeeded


(Imagine LED still flashing here.)

--Phil.

neurascenic

Oh man!  This is awesome, I will most definitely be following your progress.

Chris

follower

Just a quick update that last night I managed to get the Arduino to function as a USB HID keyboard (with one button!) when connected to a Mac OS X 10.4 machine. I had previously had some success connected to an Ubuntu box.

I managed to send standard characters, modified keystrokes (e.g. Command-B), arrow keys and function keys--the latter of which I used to bring the Dashboard up on screen whenever I pushed the button attached to the Arduino. :-)

So, the short answer does seem to be that at least at some level AVRUSB and Arduino can be compatible--I'm not sure if there is a point at which one or other of them will break as I haven't tried anything very sophisticated.

I'm hoping that my web server will be back on line soon so I can upload more details.

--Phil.


wyatt

That's sweet!  Please post a reply when you get this up on your website - I am very interested in doing something similar to this, and a simple howto / tutorial would go a long way!

Cheers

spatialguru

Quote

I'm hoping that my web server will be back on line soon so I can upload more details.


Great learning about this with you on IRC, thanks a lot.  Now we all know you really really want to upload some kicad files for us ;D

Best wishes...

follower

#10
Jul 08, 2008, 07:07 pm Last Edit: Jul 08, 2008, 07:28 pm by follower Reason: 1
Okay, okay...

I have just uploaded photos of the USB mini-shield for Arduino on my 9 July 2008 project log entry which I think should be enough for you to recreate it on strip- or vero-board. (Real board layout not...er, "complete". :-) )

For those that care, the current implementation isn't 100% ideal because it would be nice if the "device present" resistor could be controlled by the microcontroller to be "more polite" in conjunction with the bootloader  but that's not a huge deal. (But at the cost of an extra microcontroller pin it might have some benefits at a later date.)

Let me guess, now you'll be asking for some code & compilation instructions? :P

--Phil.

Edit: I've now added a link to a schematic exported from KiCad in SVG format to the page.

follower

Hi all,

Just a quick note to say I've uploaded the arduinousb library and an example sketch--both tailored to create a USB HID keyboard device.

Here's the guts of an example:
Code: [Select]
#include "UsbKeyboard.h"

# ...[snip]...

void loop() {
 
 UsbKeyboard.update();

 if (digitalRead(BUTTON_PIN) == 0) {
   //UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);
   
   UsbKeyboard.sendKeyStroke(KEY_H);
   UsbKeyboard.sendKeyStroke(KEY_E);
   UsbKeyboard.sendKeyStroke(KEY_L);
   UsbKeyboard.sendKeyStroke(KEY_L);
   UsbKeyboard.sendKeyStroke(KEY_O);

   //UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);
   UsbKeyboard.sendKeyStroke(KEY_ENTER);

   delay(200);
  }
}


--Phil.

follower

Another quick update, I've added links to the project page of user-submitted code contributions implementing USB mouse and keyboard functionality.

Thanks Michel!

--Phil.

mattburr

#13
Sep 29, 2008, 10:40 pm Last Edit: Sep 29, 2008, 11:25 pm by mattburr Reason: 1
I'm having a bit of trouble getting this to work:
Code: [Select]
hardware\libraries\UsbKeyboard/UsbKeyboard.h:139: error: 'byte' has not been declared

hardware\libraries\UsbKeyboard/UsbKeyboard.h:143: error: 'byte' has not been declared

hardware\libraries\UsbKeyboard/UsbKeyboard.h:143: error: 'byte' has not been declared

hardware\libraries\UsbKeyboard/UsbKeyboard.h: In constructor 'UsbKeyboardDevice::UsbKeyboardDevice()':

hardware\libraries\UsbKeyboard/UsbKeyboard.h:127: error: 'sei' was not declared in this scope

hardware\libraries\UsbKeyboard/UsbKeyboard.h:131: error: 'memset' was not declared in this scope

hardware\libraries\UsbKeyboard/UsbKeyboard.h: In member function 'void UsbKeyboardDevice::sendKeyStroke(int, int)':

hardware\libraries\UsbKeyboard/UsbKeyboard.h:151: error: 'memset' was not declared in this scope


Any suggestions would be much appreciated!

follower

Quote
Any suggestions would be much appreciated!

My first suggestion would be to try with IDE 0011 rather than 0012 if at all possible. The issue is caused by a change from the 0011 environment in the 0012 environment.

My second suggestion if you need to use 0012 is to try to apply this patch to UsbKeyboard.h (but be warned it was hacked up late one night as I was trying to meet a deadline--and the final result doesn't work as reliably as previous attempts but at present I am unsure if that is hardware or software related):
Code: [Select]
--- UsbKeyboard.h~      2008-09-24 22:45:15.000000000 +1200
+++ UsbKeyboard.h      2008-09-24 23:46:34.000000000 +1200
@@ -10,6 +10,15 @@

#include "usbdrv.h"

+#include <avr/interrupt.h>
+
+#include <string.h>
+
+// #include "WConstants.h"
+typedef uint8_t byte; // avoid int() issue
+
+#include <util/delay.h>
+
#define BUFFER_SIZE 4 // Minimum of 2: 1 for modifiers + 1 for keystroke


@@ -124,7 +133,8 @@

    // Control pull-up resistor
    usbDeviceDisconnect();
-    delay(500);
+    //delay(500);
+    _delay_ms(500);
    usbDeviceConnect();

    usbInit();


(If you don't know how to interpret the patch formatting I can try resupplying it in a different form.)

Please let me know if this helps you or not.

--Phil.

P.S. As always, I'm keen to learn what people are using the code for. :-)

Go Up