Author Topic: V-USB and ATmega problems  (Read 9826 times)

0 Members and 1 Guest are viewing this topic.

Offline skerdzius

  • Contributor
  • Posts: 26
V-USB and ATmega problems
« on: December 05, 2012, 07:47:46 pm »
hi, i have some trouble doing well explained project here: http://codeandlife.com/2012/01/22/avr-attiny-usb-tutorial-part-1/ . i do all steps required, but my hardware is not recognized on my laptop. i asked my tutor for help, he also couldn't find solution.
i use ATmega 8 or ATtiny2313, i used all three options for 3.3V usb powering (zener diodes, voltage regulator and diodes) nothing helps. i used 12 MHz crystal and 16MHz one and yes, i changed settings in required files and makefile compile my code... can someone please give me some guidelines for this project to make it work?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 7439
  • Country: nz
Re: V-USB and ATmega problems
« Reply #1 on: December 06, 2012, 12:34:43 am »
Picture of your breadboard/circuit?


Do you have a common ground between the laptop and the MCU?
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline skerdzius

  • Contributor
  • Posts: 26
Re: V-USB and ATmega problems
« Reply #2 on: December 06, 2012, 07:15:26 pm »
i do my project with this schematic http://codeandlife.com/wp-content/uploads/2012/01/usb_schematic.png . i mostly use common ground from my laptop, but i also tried different ground while powering from other computer but still no luck
 

Offline hotshot05

  • Newbie
  • Posts: 1
Re: V-USB and ATmega problems
« Reply #3 on: December 08, 2012, 03:06:59 pm »
hi, i have some trouble doing well explained project here: http://codeandlife.com/2012/01/22/avr-attiny-usb-tutorial-part-1/ . i do all steps required, but my hardware is not recognized on my laptop. i asked my tutor for help, he also couldn't find solution.
i use ATmega 8 or ATtiny2313, i used all three options for 3.3V usb powering (zener diodes, voltage regulator and diodes) nothing helps. i used 12 MHz crystal and 16MHz one and yes, i changed settings in required files and makefile compile my code... can someone please give me some guidelines for this project to make it work?

Did you change the fuse bits ?
Since you are using an external oscillator, you will have to change the fusebits to tell the chip about the presence of the external oscillator. Otherwise it will continue running with the internal oscillator @ 1MHz.

Check the makefile. There will be s section with the words highfuse and lowfuse. Hexadecimal values of the form 0x?? [? represents and unknown value] will follow these words. The fuse bits will have to be set with these two values.
 

Offline skerdzius

  • Contributor
  • Posts: 26
Re: V-USB and ATmega problems
« Reply #4 on: December 09, 2012, 06:26:33 pm »
sure, i changed fuse bits. i personally think i made everything right, but my windows laptop doesn't recognize my usb device it shows 0x000 PID and VID unknown device, however i have installed libusb drivers for it. and when i turn to linux OS it even doesn't show any device connected at all.
 

Offline miceuz

  • Frequent Contributor
  • **
  • Posts: 373
  • Country: lt
    • chirp - a soil moisture meter / plant watering alarm
Re: V-USB and ATmega problems
« Reply #5 on: December 09, 2012, 09:55:34 pm »
aha, so the device does get enumerated! Atleast in windows.

Why don't you try uploading some simple HID firmware to it? Somethig like mouse running pointers in circles, etc - v-usb page has some simple examples. At least that's how I've started using v-usb once before.

One strange glitch I've encontered with v-usb is that it wasn't enumerating the device upon connection unless I reset it via reset button. The device had usbasp bootloader in it and worked as a HID mouse, so it had TWO v-usb stacks. Unfortunatelly, I never resolved this issue...

Offline skerdzius

  • Contributor
  • Posts: 26
Re: V-USB and ATmega problems
« Reply #6 on: December 13, 2012, 02:28:38 pm »
i uploaded this code
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>

#include "usbdrv.h"

#define F_CPU 12000000L
#include <util/delay.h>

USB_PUBLIC uchar usbFunctionSetup(uchar data[8]) {
        return 0; // do nothing for now
}

int main() {
        uchar i;

    wdt_enable(WDTO_1S); // enable 1s watchdog timer

    usbInit();
       
    usbDeviceDisconnect(); // enforce re-enumeration
    for(i = 0; i<250; i++) { // wait 500 ms
        wdt_reset(); // keep the watchdog happy
        _delay_ms(2);
    }
    usbDeviceConnect();
       
    sei(); // Enable interrupts after re-enumeration
       
    while(1) {
        wdt_reset(); // keep the watchdog happy
        usbPoll();
    }
       
    return 0;
}
to my ATmega8 or ATtiny2313 but nothing interesting happens. i'll try to make my project from scratch once again today.. hoping the best :)
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7306
  • Country: us
    • SiliconValleyGarage
Re: V-USB and ATmega problems
« Reply #7 on: December 13, 2012, 03:28:59 pm »
I hope you do realise that vusb is NOT usb compliant. It is a kludge and pile of trickery that may or may not work. It does not implement a full USB engine , nor does it implement a correct USB engine. It is one of these things that may or may not work.

If your USB host uses a different order of commands or slightly different timing this whole thing stops working. VUSB is an experiment in futility. Nothing more. Making something with it that works reliably is not possible.  End of story.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline skerdzius

  • Contributor
  • Posts: 26
Re: V-USB and ATmega problems
« Reply #8 on: December 13, 2012, 03:53:56 pm »
yes, i know that it is firmware-only usb driver, and ATmega8 doesn't have hardware to support usb, but i thought it must work with my laptop as this v-usb thing is widely popular among developers  :-\ and i must make this in order to make my university project, or other option would be to make STM32F4 Discovery board to communicate with pc in a similar way via USB. and i thought using ATmega would be much easier than ARM programming :-//
 

Offline Ragorh

  • Contributor
  • Posts: 5
  • Country: no
  • Maker
    • Norwegian Creations
Re: V-USB and ATmega problems
« Reply #9 on: December 13, 2012, 05:13:12 pm »
I made a HID device with V-USB a long time ago.. And it worked:) But a bit unstable though..
My first thought when I saw the breadboard-pic, was noise.. I think you can get enumeration problems because of package loss.

Place a scope probe at the USB header and take a closer look!
Pictures from the scope will look good in your school report;)
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7306
  • Country: us
    • SiliconValleyGarage
Re: V-USB and ATmega problems
« Reply #10 on: December 13, 2012, 07:01:35 pm »
but i thought it must work with my laptop as this v-usb thing is widely popular among developers ..

not guaranteed to work with anything ... it will work with some usb controllers , not with others. its hit and miss.

as for being popular.... not with developers. with idiots maybe.... you have to be mad to do this.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline skerdzius

  • Contributor
  • Posts: 26
Re: V-USB and ATmega problems
« Reply #11 on: December 13, 2012, 07:30:50 pm »
So maybe STM32F4 with RTOS would do the trick? i am in desperate situation right now. i want to make it work badly. so i think i have to make USB transfer with ARM then. P.S. i made this schematic with atmega again, but no luck as always.
 

Offline senso

  • Frequent Contributor
  • **
  • Posts: 896
  • Country: pt
    • My AVR tutorials
Re: V-USB and ATmega problems
« Reply #12 on: December 13, 2012, 08:28:07 pm »
Buy a Teensy 2, it has an atmega32u4, and code to use with the Arduino IDE, putting native USB working is a matter of buying one of them and 5 lines of code..
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7306
  • Country: us
    • SiliconValleyGarage
Re: V-USB and ATmega problems
« Reply #13 on: December 13, 2012, 09:06:03 pm »
But why do you make it so bloody difficult ? slap on an ftdi chip and off you go ! guaranteed to work right. and no mucking with USB.

USB is not an easy bus to handle if you have never done it . the learning curve is steep. Having correct hardware is problem number one. VUSB is NOT the answer there. they are shoehorning a badly emulated USB rptocol on an , electrically incorrect, i/o structure. The voltage levels are wrong , the thresholds are wrong and much more. It may work with some usb host controller but not with others. Especially with the newer controllers i predict trouble. The USB standards for timing have tightened ove rthe years  and now with USB3.0 it is going to be even more misery to get it to do anything.

VUSB will work if you have a 1.1 compliant USB port. plug it into a 2.0 host and all bets are off. the host will most likely not be able to detect correctly that he has to switch down to 1.1 speeds.

Take a cpu that does have a USB engine on board and load the LUFA stack and off you go.

VUSB really is a pest that needs to die. The only reason it has for exisiting is to show off some low level programming skills of a madman. It was made becasuse there were very few small cpu's available with an on board USB hardware block. ( simply because the USB hardware block is large ).

Do yourself a favor and grab a cpu supported by LUFA. Or grab a PIC processor and use the USB library available on Mikroe compilers. Or any other cpu that has USB supported including a library that does work. you don;t want to be mucking about trying to develop that if you are under time pressure. The same goes for the 'other side' , meaning the operating system driver. Use an existing class like VCP or CDC.

Still the simplest solution is : slap on an FTDI chip. they give you the drivers and the new H versions go full throttle at 480Mbit/s
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline skerdzius

  • Contributor
  • Posts: 26
Re: V-USB and ATmega problems
« Reply #14 on: December 13, 2012, 09:32:53 pm »
it was my main purpose to understand USB more deeply and to make it a little more difficult than just few lines of code in Arduino for example. but now i see it is too hard to make it work for me. thanks for guidance anyway :) :-+
 

Offline jeroen74

  • Frequent Contributor
  • **
  • Posts: 397
  • Country: nl
Re: V-USB and ATmega problems
« Reply #15 on: December 13, 2012, 09:50:55 pm »
If you want to understand USB more deeply, for example, read 'USB Complete' by Jan Alexson or 'USB in a nutshell' on beyondlogic.org.

I have to agree that V-Usb is a nice experiment, but no more.

Is USB a main objective of your uniproject?
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7306
  • Country: us
    • SiliconValleyGarage
Re: V-USB and ATmega problems
« Reply #16 on: December 13, 2012, 09:57:04 pm »
 :-+ What jeroen74 said.

Read USb complete or get the intel book on USB. Better yet , get the USB spec. it's free. And a bloody nightmare to read.
To develop a USB system stack from scratch ( assuming correct hardware .... ) is a major undertaking. And you will need some advanced tools to actually 'sniff' the bus. Getting it to be fully compliant will cost you some $$$. be prepared to buy a USB bus analyser like the CATC machines ( now owned by lecroy-teledyne) that can tap into a bus stream and fulle decode the packets.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline cwalex

  • Frequent Contributor
  • **
  • Posts: 302
  • Country: au
Re: V-USB and ATmega problems
« Reply #17 on: December 14, 2012, 11:26:08 am »
Years ago I got the CDC demo with VUSB working perfectly first time. I looked at the code to make the micro do the other things I wanted and quickly realised I was way over my head and gave up  :-[
 

Offline skerdzius

  • Contributor
  • Posts: 26
Re: V-USB and ATmega problems
« Reply #18 on: December 15, 2012, 08:19:26 pm »
yes, USB was one of key elements in this project.. another one is ADC which is capturing sine wave and uC outputs its period to pc. but now i think i could change usb interface with something else in order to make everything working.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf