Go Down

Topic: Arduino UNO as HID usb device: i need some help to understand (Read 1 time) previous topic - next topic

Dani88

Hi:)
I need some help with a project I'm developing: the realization of a HID controller a software I have on PC.
I bought the board Arduino UNO because with the reprogramming of ATmega8U2 is possible to recognize it as HID device.
I thought, to do it using the firmware found on LUFA:
http://www.fourwalledcubicle.com/LUFA.php

Pending the board arrives I'm trying to understand a bit how it all works. I'm going to describe briefly the project "features":

---- PC SIDE ----
The software uses an XML configuration file that specifies which bits, bytes, words, etc. ... will be assigned to a command which is then read by the program, for example:
Code: [Select]
<button bit="0x08" name="PLAY" />

By experiment with the Wiimote and the pad Play Station 2 (the only HID device I had at home, keyboard excluded) and using the program HID Trace get something like:


So in this case when bit 8 of the first line change from 0 to 1 (in the photo is already 1) the program will read the command "PLAY".
Of course for the buttons a bit is enough, if I have to read analog values ?i need 1 or 2 bytes containing the value read.
example:
Code: [Select]
<slider word="2" name="VOLUME" />


---- ARDUINO SIDE ----
At this point I have to send to the computer the "bit matrix" as the one you see in the picture, right?
From what I understand, in a HID device there are blocks of memory (size defined?) in which values ??are written.
Every time you change even one bit all memory block will be send to the PC
Quote

Your firmware writes in a small block of memory (usually located in the chipset HID) Corresponding bits and bytes to the state of your device (positions of sliders, state-of-buttons, etc.).
When something changes in this memory block, the HID chipset will signal the computer to read it.
Then, as soon as the software on the computer is ready, it will read the memory block and react to the changes found within.
(It Means That a slider can change Several times while the computer is busy, the computer will read only the current position When It has time to do so).

The whole memory block is Transmitted to the computer every times, even if only one bit changed.
But the memory blocks are small enough (usually 32 or 16 bytes), That the bandwidth used is not much more than sending MIDI message to 4 bytes.
In real-life situations, the extra 12 or 28 bytes per message are ridiculously small Compared to the bandwidth of USB 1.0.

These memory blocks are in ATmega8U2, right?
How i can write them with Arduino?

Examples:
- I press the A button, and I therefore set to 1 bit 0x07 so that the PC is aware of the pressure.
- Turn the trimmer, I then assign the new value readed (suppose to be 16 bit even though he is only 10) from bit 0x10 to bit 0x1F

How do you do all this? : (
I need some help step by step

Dani88


dhunt

#2
Jan 16, 2012, 10:40 am Last Edit: Jan 16, 2012, 10:44 am by dhunt Reason: 1
It might be best to start with the playground links that describe how to create HID firmware for the atmega8u2 on the UNO and how to load it.  The interface between the atmega8u2 and the atmega328 on the UNO is serial so all the communication is handled with the Serial library. You'll find example code and directions on the links.

Arduino Playground - Interfacing With Hardware - USB HID

Go Up