USB HID Device Emulation Guidance Request

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

I want to make an AtMega or AtXMega device which will connect to a PC via a USB port and look like it is a keyboard (i.e. emulate a USB keyboard). This device will send a 5 digit number (in the form of five numeral keystrokes) into the PC USB port. The 5 digit number will then be treated just as though it were typed on the keyboard and be entered into an open WordPad document which is currently being edited in the normal way. I will also have a standard USB keypad simultaneously connected to the PC. Therefore, I can type on the keypad OR use my special device to enter numeric data into the document. But not both simultaneously.

As an example, if I were to type the five numeral keys 1,2,3,4,5 on the standard USB keyboard, they would appear in the WordPad document at the current cursor location. With this new device, when I prompt it in a certain way, it will send the same five numeral "keys" (1,2,3,4,5) and they will be entered into the WordPad document at the current cursor position exactly as if the standard keypad was sending them.

In other words, I want to emulate a certain functional subset of a standard USB keypad.

The advice and guidance I need is: What is the most time efficient way for me to approach this project?

A. Which AtMega or AtXMega chip provides the simplest hardware/software path to a solution?

B. What reference design or development board should I purchase to get me started?

C. Will I need to use Dean's LUFA "stack" to develop the required software? ( What is a "stack" in this context, anyway? )

D. Is there an existing USB Keyboard emulation project I can use as a starting point? I have searched this forum and other internet resources, but don't seem to be able to find a concise example.

Thank you in advance for any help you can provide!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A. One with USB

B. I like the XMEGA-A3BU XPlained board. Has the USB jack and everything needed. Even a screen if you want.

C. I am happily using ASF for my USB code instead of LUFA

D. ASF has a USB HID Keyboard example that is made for the A3BU Xplained

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Chuck,

There are plenty of variants of USB keyboard emulator projects at the V-USB page, specifically the projects page, including a page specifically for HID devices (keyboards, mice, and joysticks).

V-USB main page wrote:
Runs on any AVR microcontroller with at least 2 kB of Flash memory, 128 bytes RAM and a clock rate of at least 12 MHz.
No need to use LUFA at all since you won't need a USB-capable AVR MCU for such a simple project.

Regards,
Bill

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The ATTiny45 is probably the simplest
http://www.obdev.at/products/vus...
It was popular as a supposedly humorous hidden dongle to randomly send the caps lock key. Search "attiny stealth USB"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks to you all for such accurate and concise guidance!

auxren: I have ordered a XMEGA-A3BU board. This will likely be the basis of my design because my project includes many other functions I did not mention in my post. I'll need the power of an XMega to implement these other functions.

meteor: Although the V-USB examples appear to be admirably minimalist implementations of basic USB functions, I may not be able to incorporate such an approach in my complete design. However, I intend to implement his HID keyboard project as part of my USB education to help me ascend the USB learning curve. (Also, see my remark to dak664 below for a possible "multi-processor" approach.)

dak664: The "easylogger" is so close to my required functionality, I am considering using it as a "USB peripheral" for a larger AtMega-whatever which will perform the remainder of the system's functions (lights, serial ports, switches, LCD display, etc.) My only hesitation is that my application must be "USB 2.0 Compatible" and I'm not yet knowlegeable enough to answer that question. Perhaps you can lend some insight?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A quick update.

I received the XMEGA-A3BU demo board, loaded it with the Studio-6 ASF HID-device Keyboard example ("Solution") and it worked right off the bat.

I even modified the example code to perform a slightly different demonstration key sequence a little closer to what I ultimately need. That worked fine too.

My problem now is how do I extract the essential routines and structures from the massive example source code to port into my final application which involves lots of other functions?

The ASF HID Keyboard example is very thinly commented and offers little in the way of overall structure or execution order. What I call a "Wiz-Bang" - a very impressive demo, but where do you go from there with it? ( Similar to a lot of so-called "Reference Design" boards I have worked with. Besides proving that the illustrated IC works, what utility can it serve you if the reference design has no test points or the support components are all 0201 size? )

So, in addition to working with the ASF HID-Keyboard Example, I am now looking into Dean's LUFA to see what benefits it offers.