Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
jokkebk
PostPosted: Jan 22, 2012 - 09:14 PM
Rookie


Joined: Apr 07, 2011
Posts: 39


Hi all!

I recently managed to implement an USB powered device using ATtiny2313 and V-USB library. As a beginner, I needed several evenings of research prior to the project so I decided to compile a tutorial covering the steps for building a simple USB device:

http://codeandlife.com/2012/01/22/avr-attiny-usb-tutorial-part-1/

This first part covers the basics of getting USB connector to breadboard and using it to power a simple LED circuit. It can be extended to any USB-powered project.

http://codeandlife.com/2012/01/25/avr-attiny-usb-tutorial-part-2/

The second part goes through rest of the test breadboard setup, including wiring the ATtiny2313 to the USB with proper pullups for a low-speed device on D+ and D-, as well as enabling the 12 MHz crystal.

http://codeandlife.com/2012/01/29/avr-attiny-usb-tutorial-part-3/

The third part is the longest of the three and contains both device side and host side code, as well as a chapter on creating Windows drivers for V-USB devices using libusb-win32's INF-wizard.

http://codeandlife.com/2012/02/04/avr-attiny-usb-tutorial-part-4/

Fourth part details how to send data from and to your device. It also wraps up the tutorial series and contains the source code and schematic as well as needed libraries and drivers for Windows in one neat package.

I'm using quite a lot of pictures so I put the tutorial to my blog, but would appreciate any comments, feedback and discussion here. The spark for my electronics hobby started here in AVRfreaks tutorial section, so I felt it was time to contribute something.

Update: Two new parts have been added, first for making a HID mouse, and second which goes through adapting the tutorial for use with zener diodes to run the AVR at 5 volts, as well as switching to ATtiny85 (45 and 25 probably work just as well) and using internal oscillator instead of external crystal!

http://codeandlife.com/2012/02/11/v-usb-tutorial-continued-hid-mouse/
http://codeandlife.com/2012/02/22/v-usb-with-attiny45-attiny85-without-a-crystal/

Update2: Due to some requests, I've continued the tutorial with treatment of HID keyboards, too:

http://codeandlife.com/2012/06/18/usb-hid-keyboard-with-v-usb/


Last edited by jokkebk on Jun 18, 2012 - 05:00 PM; edited 5 times in total
 
 View user's profile Send private message  
Reply with quote Back to top
jokkebk
PostPosted: Jan 25, 2012 - 08:48 PM
Rookie


Joined: Apr 07, 2011
Posts: 39


Second part is now also up. I felt that the breadboard connections, reprogramming the fuse bits for 12 MHz crystal & testing was suitably long already so I'll cover the V-USB in part 3. Stay tuned!
 
 View user's profile Send private message  
Reply with quote Back to top
toffie
PostPosted: Jan 27, 2012 - 05:16 PM
Newbie


Joined: Jan 19, 2009
Posts: 14
Location: Stockholm

Seems to be quite some nice tutorials there, will surely check back for part 3! Smile
 
 View user's profile Send private message  
Reply with quote Back to top
ItsMike
PostPosted: Jan 27, 2012 - 05:26 PM
Hangaround


Joined: Sep 15, 2011
Posts: 136
Location: Israel

I'm glad someone is doing V-USB tutorial. I was too lazy to figure it out by my self.

Waiting for the critical 3rd part : )
 
 View user's profile Send private message  
Reply with quote Back to top
jokkebk
PostPosted: Jan 29, 2012 - 04:27 PM
Rookie


Joined: Apr 07, 2011
Posts: 39


Part 3 is now finally up, thanks for all the comments so far. This is the longest and most detailed part, I may yet do some housekeeping work on the article, add one zip file for all the source code and insert proper copyright and license notices in the beginning of the files.

There will be part 4 with some additional techniques shortly, at least sending and receiving short buffers of data will be covered then.
 
 View user's profile Send private message  
Reply with quote Back to top
toffie
PostPosted: Jan 29, 2012 - 06:41 PM
Newbie


Joined: Jan 19, 2009
Posts: 14
Location: Stockholm

Will go through it when I hit the bed tonight on my TV-pc, will be fun to read it. Good job jokkebk!
 
 View user's profile Send private message  
Reply with quote Back to top
jokkebk
PostPosted: Feb 04, 2012 - 05:00 PM
Rookie


Joined: Apr 07, 2011
Posts: 39


Fourth and so far final part is now released. It will explain transferring data from a to device in more detail, and I zipped everything up in one package so you don't have to cut-and-paste so much if you don't want to.

Planning to do a simple 7 segment multiplexing tutorial and a brief bit on driving LCDs directly with MCU when I get some free time. Smile

_________________
http://codeandlife.com
 
 View user's profile Send private message  
Reply with quote Back to top
jokkebk
PostPosted: Feb 11, 2012 - 10:27 AM
Rookie


Joined: Apr 07, 2011
Posts: 39


Wow, I made it to Hack a Day with the tutorial!

To celebrate this, I made a new post outlining how to turn the tutorial project into a HID mouse. The current implementation just randomly moves the cursor, but with a few buttons a simple directional pad or joystick would be really easy to implement.

http://codeandlife.com/2012/02/11/v-usb-tutorial-continued-hid-mouse/
 
 View user's profile Send private message  
Reply with quote Back to top
jokkebk
PostPosted: Jun 18, 2012 - 05:03 PM
Rookie


Joined: Apr 07, 2011
Posts: 39


I've received several questions regarding USB HID keyboards, and decided to continue the tutorial with a new post on that subject.

This should enable all kinds of data logger and interaction projects, especially since the type of keyboard I cover can also receive caps/scroll/num lock state changes from PC and react to them. Smile

_________________
http://codeandlife.com
 
 View user's profile Send private message  
Reply with quote Back to top
ae2903
PostPosted: Jun 23, 2012 - 04:11 AM
Newbie


Joined: Jun 21, 2012
Posts: 1


Awesome effort..!! However I had a question. Can this method be employed for making a USB programmer for Atmega 8,16,32,64 or 128?
 
 View user's profile Send private message  
Reply with quote Back to top
jwatte
PostPosted: Jun 23, 2012 - 05:54 AM
Wannabe


Joined: Apr 28, 2012
Posts: 72


Quote:
Can this method be employed for making a USB programmer for Atmega 8,16,32,64 or 128?


Yes: http://dicks.home.xs4all.nl/avr/usbtiny/
 
 View user's profile Send private message  
Reply with quote Back to top
meteor
PostPosted: Jan 19, 2013 - 10:21 PM
Hangaround


Joined: Dec 11, 2010
Posts: 211


Hi, Joonas...

Based on trying to assist someone in this 'V-USB Command line client' thread, I was looking at your tutorial and realized that, unless I'm missing something, you're attempting to drive an ATTiny2313 MCU at 12 MHz but only on 3.3V. If all of my datasheets are correct, then that is beyond the specifications of that MCU! If you want to run it (within spec) over 10 MHz, you must use 4.5V - 5.5V.

I reviewed all of the comments on that page but I see nobody ever mentioning that MCU spec violation.

I do see where you (wisely) modified that design for your ATTiny85 V-USB tutorial to power the MCU from +5V, but the ATTiny2313 tutorial is still using 3.3V.

Am I missing something?

Regards,
Bill
 
 View user's profile Send private message  
Reply with quote Back to top
jokkebk
PostPosted: Jan 22, 2013 - 07:25 AM
Rookie


Joined: Apr 07, 2011
Posts: 39


Hi Bill,

You are correct, when I did the tutorial I was not aware of the frequency limitation. In practice, I've never had any problems "undervolting" the ATtiny2313 @12MHz. But it is possible that some problems people have had might be connected to this.

I'll add a note in the tutorial and advice people to try out the zener diode configuration if they continue to have problems. If I have the time, I might even do an additional post with new power supply and diagrams.

Thanks for the feedback!

Joonas

_________________
http://codeandlife.com
 
 View user's profile Send private message  
Reply with quote Back to top
parthi2
PostPosted: Feb 22, 2013 - 06:11 AM
Wannabe


Joined: May 21, 2012
Posts: 75


ya thank you, i learned most of things of usb from this tutorial then i want to learn ethernet programming if guys know about ethernet communication, you can teach to lot of peoples also give details for beginners.
 
 View user's profile Send private message  
Reply with quote Back to top
Rohalamin
PostPosted: Feb 22, 2013 - 08:29 AM
Posting Freak


Joined: Feb 22, 2013
Posts: 1050
Location: Ab Pakhsh , Bushehr , Iran

great job!
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
ralphd
PostPosted: Feb 12, 2014 - 04:48 AM
Hangaround


Joined: Feb 11, 2014
Posts: 421
Location: GWN

meteor wrote:
Hi, Joonas...

Based on trying to assist someone in this 'V-USB Command line client' thread, I was looking at your tutorial and realized that, unless I'm missing something, you're attempting to drive an ATTiny2313 MCU at 12 MHz but only on 3.3V. If all of my datasheets are correct, then that is beyond the specifications of that MCU! If you want to run it (within spec) over 10 MHz, you must use 4.5V - 5.5V.

I reviewed all of the comments on that page but I see nobody ever mentioning that MCU spec violation.

I do see where you (wisely) modified that design for your ATTiny85 V-USB tutorial to power the MCU from +5V, but the ATTiny2313 tutorial is still using 3.3V.

Am I missing something?

Regards,
Bill


Though with the ATtiny85, 12Mhz @3.3V is in spec according to Figure 22-2 of the datasheet.
It's also in spec for the 2313A/4313.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
meteor
PostPosted: Feb 12, 2014 - 04:31 PM
Hangaround


Joined: Dec 11, 2010
Posts: 211


ralphd wrote:
Though with the ATtiny85, 12Mhz @3.3V is in spec according to Figure 22-2 of the datasheet.
I disagree.

Figure 22-2 is simply plotting the active supply current versus MCU operating frequency. Just because Atmel happened to plot the 3.3V line out past the 12 MHz point does not (to me) imply that it's "in spec" under such conditions.

Sure, some people are operating ATTiny85 MCUs successfully under those conditions, but I would not call that "in spec". To me, and, I suspect, most others, the "Speed Grade" callout on the very 1st page of the datasheet is the relevant guideline and it clearly says:
ATTiny25/45/85 datasheet wrote:
0 - 20 MHz @ 4.5 - 5.5V

ralphd wrote:
It's also in spec for the 2313A/4313.
I see no evidence for that claim in my datasheet ("Rev. 8246BS-AVR-09/11") for the ATTiny2313A/4313 variants. In fact, the "Speed Grades" callout on page 1 is, for the speeds in question, identical to the quote above.

In summary: People are free to operate their MCUs (and PC CPUs/GPUs, for that matter) at whatever speed/voltage combination they're comfortable with. But I would not call combinations that violate the "Speed Grade" callout as being "in spec".

Regards,
Bill
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Feb 12, 2014 - 04:55 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71189
Location: (using avr-gcc in) Finchingfield, Essex, England

My (fairly recent) copy of the t25/45/85 data has this.

One would need to interpolate but it looks like 12MHz/3.3V appears to be "safe"?

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
meteor
PostPosted: Feb 12, 2014 - 06:48 PM
Hangaround


Joined: Dec 11, 2010
Posts: 211


Very interesting! Thanks for pointing that out, Cliff. It was in my older ("2586K-AVR-01/08") ATTiny25/45/85 datasheet as well, but I somehow missed it. I had even searched for "speed grade" before posting but upon further analysis, I clearly only had done that in the 2313A/4313 datasheet, where the same chart/info is (maddeningly!) under a different sub-section label (i.e. "Maximum Speed vs. VCC" instead of "Speed Grades").

Having my eyes further opened, I will happily concede that "in spec" is rather more debatable than I previously asserted, especially since Atmel's own documentation is somewhat misleading (almost contradictory, in fact).

But, since Joonas thoughtfully updated his tutorial long ago to address my point, this is now more of an academic (and interesting) debate rather than a real concern.

Thanks again (to both of you) for the added enlightenment.

Regards,
Bill
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits