Page 1 of 1

Descriptors

Posted: Sat Jan 29, 2011 1:27 pm
by Quizzarex
Hi all.

Im having trouble setting up my descriptor for my ATmega88, as it seems that windows wont regonize the software i flash onto my chip.

Background:

Me and a mate have been fooling around with the ATmega88 for a while, and we are pretty much into registers, interrupts, adc etc. on this chip. It have been quite fun to play with it and then we decided to make a temperature gauge which we want to hook up with a PC and collect the data. The thing is that we have designed at circuit which will give an output to the PC0 connector on the chip, which will be converted in ADC and put in ADC data register (10-bit resolution), the plan is that we wanna send these raw data to the pc and let it do the work.

The Problem:

The problem is writing a descriptor that will be regonized by windows (probably other OS'es aswell). I have read USB in a Nutshell, been looking in HID Usage Table, read USnoobie's tourial on this matter, which btw was the most given compared to the Nutshell document. But it still seems i cant crasp the concept, i have been using a few days on this matter, looked in this forum and other sites on the internet. And now im like, I'll have to ask someone with expirience in this matter.

The data structure is quite simple as we wanna send the raw data from the ADC data register to the PC, so im thinking it would look like this:

Code: Select all

typedef struct
{
    uchar adc_upper;     // 8-bit data
    uchar adc_lower;     // 8-bit data
} report_data;


Furthermore i found that the device we wanna make is PID (Physical Interface Device) and the INPUT is Data, Variable, Absolute. Im not sure if i have to use logical min/max, but i would like to as its simple 0 - 255. I have tried using the HID Descriptor Tool, but this a jungle to make my own descriptors, I'm feeling kinda lost with this and I/we would appreciate some help if its possible to help with this matter.

Greetings
- Kent

Re: Descriptors

Posted: Sun Jan 30, 2011 1:03 am
by Quizzarex
Hi again.

Don't know if my question is way too noobish or just not clear enough.

But the problem explained in a more straight-forward way.

Why can't i get Windows to recognize my USB device?

I was wondering if it was my USB Report Descriptor which was failing, but I'm just not sure if it's the case.

My USB Report Descriptor:

Code: Select all

PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { /* USB report descriptor */
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x36,                    // USAGE (Slider)
    0xa1, 0x00,                    // COLLECTION (Physical)
    0x05, 0x02,                    //   USAGE_PAGE (Simulation Controls)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x02,                    //   REPORT_COUNT (2)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    0xc0                           // END_COLLECTION
};


To sum up the functionality of the device. It's going to measure temperature.

To test the USB device we are applying a pot-meter on the ADC input-pin (PC0) to measure a voltage difference between PC0 and AREF (0 - 5V). The reason why we replace our temperature circuit with the pot-meter is just to keep the application simple while we work on the firmware and host software to retrieve the data from the ADC data register. But it seems that the firmware won't be recognized by Windows which, makes it impossible to even see the device in Device Manager in windows, and therefore we really can't get started on programming the host software.

I am wondering if the problem with the device-firmware is because i havn't put anything in my usbFunctionSetup function, it simply just return 0.

Here i a link to my main.c - http://dl.dropbox.com/u/11000332/HelloUSB/main.c

and my usbconfig.h - http://dl.dropbox.com/u/11000332/HelloUSB/usbconfig.h

I havn't been tampering too much with the config file yet, but im sure that the DPLUS and DMINUS is set to the correct pins on the ATmega88 and i have set the USB_CFG_INTERFACE_CLASS option to 3 to represent a HID.

A link to the schematics of the board im using - http://robocard.dk/images/rc10_diagram.png

Just to make it clear, what I'm asking about: Why can't i get Windows to recognize my USB device?

I'm kinda lost with this and really need a push in the right direction. It is much appreciated.

Hope this info will help u, help me.

Greetings Kent

Re: Descriptors

Posted: Sun Jan 30, 2011 7:56 am
by _frank26080115
err, your code isn't sending anything to the computer at all, that usually causes a "device cannot start" error.

try implementing usbFunctionSetup completely, also sending out reports using the interrupt endpoint

remember to change USB_CFG_HAVE_INTRIN_ENDPOINT

Re: Descriptors

Posted: Sun Jan 30, 2011 12:28 pm
by Quizzarex
Thank you for the reply, very much appreciated Frank.

Are you the "USnooBie"-Frank? If so, great project you got going.

I think I'm about to understand how it works, it's something like the request from the computer is handled by usbFunctionSetup, but the device itself just sends out reports by the interrupt-in endpoints?

Greetings Kent

Re: Descriptors

Posted: Mon Jan 31, 2011 1:46 am
by _frank26080115
Yea it's me, I'm glad you like my work

Your understanding is correct. I suggest you take a look at another project that is very similar to your own. http://yveslebrac.blogspot.com/2008/10/ ... alaxy.html , it sends data from two ADC channels, just like your project. Although the source code for that particular project might cause some confusion because it's actually pretending to be a gamepad.