Intrudoction to AVR

 Hi everybody,

This is somewhat a tutorial, so here I wanna present you some information about ATmel's processors, and I will present those two chips that I am using.

Atmel is the company which produce AVR and ARM chips. These are the two CPU types that they are fabricating and each has different architecture but the program can be compiled with AVR Studio for both and as I understood, ARM support C# .NET application which can be coded in Visual C#.

ATmel produces different architecture type of micro controllers like the AVR 8-bit and 32-bit, 8051, AT91 etc.

ARM and AT91 Chips

ARM chips has a better technology and call it a mini computer... I saw somebody running Linux on them etc but I don't know much about them. So abut ARM chips that's all that I can say. They has a so called Q-Touch technology and it needs Q-touch library for the AVR Studio to be able to use these functions.

These chips brings new features and peripherals, and they have low power consumption for battery operation. They are used by mobile phone accessories, industrial control, POS terminals, etc etc

8051 Chips

These are small chips with 14, 16, 20, 28 pins used most in card readers, USB applications etc etc. Nice chips but I never used them.

AVR Chips

  • 32 bit

The 32 bit family is built on high performance 32 bit architecture. These chips delivers high speed, low power consumption, low cost, single cycle SRAM etc.

Never used them in robotics, yet, so that's all I know....

  • 8/16 bit Xmega

These chips delivers 16 bit performance for a cost of an 8 bit MCU. These has crypto engine, high speed ADC (analog - digital converter) and DAC (digital analog converter) etc. The nice part of them is that they are  compatible with Tiny and Mega MCUs. Another nice part is that within Xmega family, it is 100% code compatible with other Xmega controller, so switching between them, they don't need the program to be recoded.

  • 8-bit Tiny & Mega

These are my personal favourites. I've started developing with AT Tiny2313.

So for introduction I would say some words about these:

  • Tiny

The intro level into robotics it is used ATTiny. You know simple applications, Learns PWM, digital I/O and such simple things. They are cheaps and comes in packages with 8 leads (ATTiny25, 45, 85), up to 20 leads (ATTiny2313, ATTiny2313V).

I forgot to mention that the smallest one has only 6 pins, and its name is ATTiny10.

AT Tiny25 has 2kb of flash, ATTiny 45 has 4kb of flash, etc so the names describes almost everything.

I usually use ATTiny2313 with simple pince, the simple Through hole packages. I got ATTiny2313-20PU. Difference between PI and PU is that PU are PB-free packaging alternative, european ROHS compliant. Thats all.

Difference between 2313 and 2313V... eh, 2313 work with a frequency up to 20 Mhz, 2313V work only at maximum 10Mhz. But the V works from 1.8 up to 5.5V, while the simple 2313 works from 2.7 up to 5.5V. Of course both are industrials so the temperature range of works is -40C and 85C.

They are different packages like the 20P3, 20S, 20M1.

Difference?

20P3 - 20 leads, PDIP (plastic dual inline package)

20S - 20 leads, SOIC (Small Outline Package)

20M1 - 20 pads, 4x4x0.8mm, QFNL (quad flat no-lead).

Some things useful in these MCUs:

  1. Small package
  2. Fast and code efficient
  3. picoPower technology
  4. High level of integration
  5. Integrated boost controller
  6. Communication

It can be used in electronic toys, remote controls, home automation, circuit breakers etc.

I used them in the miniPOV, and a personal project I made for my girlfriends birthday.

  • Mega

I am new to them. I use Mega8-16PU, and I used them only in Oldsmobile but soon in TRACAR too.

These are nice chips. They replaces Tinys only when it is really needed. The price is almost triple (at least here) for Mega8 so now I thought that buying two Tiny2313 which communicates via TTL with each other it would be a better solution but As I designed the code for Oldsmobile, I saw that the program in Tiny occupies 400% in the tiny flash, and in mega it uses only 60% by the way... Lets see what these things are really are...

What this have and Tiny has too?

everything...

What this have and Tiny doesn't?

self-programming, 8kb and more of flash, ADC converters (tiny has too but not all), etc.

And for the packages, it comes as Through hole mounts (PDIP), surface mound devices (smd), quad flat no lead, etc.

Thats all about them....

AVR Studio

Oh yeah this is the program you need to write the code and even to program fusebits, flash, eeprom, but programming the chip needs a programmer.

AVR studio is a free program that can be downloaded from their site, and it work with the assembler language. This is a hard language, as called machine language, no that doesn't mean that you need to press 1 and 0 to get the code, this means that you need to use a really basic language, you declare the registers where data is stored, you don't have variables like uint8_t myvariable, you only have data registers like r16, you can not use x + y statement, but you can use r16 ADD r17 etc. It's not so hard but near C this is really hard.

To use the C language you need the so called AVR-GCC or what, ah by the way you need WinAVR installed, this is the compiler, pronounced "whenever", and if you install it you don't need anything else to do, run AVR Studio, select AVR Simulator 1 or 2, select the chip, and write the code. Easy huh?

Of course on the net you can find other compiler like CodeVisionAVR, mikroC for AVR, Bascom AVR etc etc but I used to know AVR Studio cause this is free...

Now that's all about this MCUs, Compilers, etc. Later I'll talk about the programmers ;)

bye,

Hesit8

AVR-GCC, not AVR-GNU :-PYou

AVR-GCC, not AVR-GNU :stuck_out_tongue:

You can also use the arduino environment and code on almost any ATMEGA these days.

Eclipse + plugins

my setup is

 

Eclipse 3.5

http://eclipse.org/

 

AVR Eclipse Plugin

http://avr-eclipse.sourceforge.net/wiki/index.php/The_AVR_Eclipse_Plugin

 

Arduino NG hacked into ISP programmer

http://www.flickr.com/photos/twodotone/394578537/

 

I can configure fuses, write code in C/C++, compile and upload to the chip.

I also own an Atmel STK500 but the hacked arduino is less hassle to use.

it’s already USB :slight_smile:

http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2735

 

if you’re on mac, I think this is the best and cheapest setup.

 

hope this’ll help someone :slight_smile:

 

ciao.ubi

It helps me as I had no idea

It helps me as I had no idea there was an avr plugin for eclipse…I never actually looked though… still very awesome!

Tiny26P

Greetings,

I thought I’d just share a little info on the Tiny26P chip which is the one I’m currently using for most of my robot stuff. It’s a nice and cheap chip which has 11 ADC channels, 2 hardware PWMs, 2 timers, hardware support for I2C (which is perfect for making a lot of modules that can communicate with each other - like for example a motor driver, a line sensor, an LCD driver, etc.). In short this is a cheap chip that has all the stuff you need for basic robot building - although it doesn’t have a whole lot of memory.

For developing (running ubuntu) I use the vim editor and a makefile since my robot code projects tend to not be so big that they would require an IDE like eclipse, but it’s always nice to hear that there are plugins for AVR out there.

Cheers

you are welcome :slight_smile:

you are welcome :slight_smile:

can it be used with com0com

can it be used with com0com and usbTiny from lady ada?

 

I use com0com a null port emulator btw and an stk500 bridge for the tiny to be recognized as an stk500…

if this is working than :smiley:

Tiny861

Tiny861 is the big brother of Tiny26 with 8k Flash instead of only 2k. It also has the possibility to use a second pair of I2C pins in case the first pair is used for other purposes, like Timer output. And is in the works to be Arduino compatible, along with the other 8k Tinys (84 and 85). They are making Tiny2313 compatible too, but Arduino adds a lot of base code that almost fills up the available space. But on the 8k chips, there is plenty flash space available. A modified version of the Optiboot bootloader is in the works to program these chips, but it’s hard because there is no bootloader protection fuse and it erases itself. I don’t think I’ll use the bootloader since I can upload the sketches with a hardware programmer directly from Arduino IDE.

Since others are throwing

Since others are throwing out the love for their favs, I’ll just say that the attinyX4(24,44,84) series is a nice compact version that can really accomplish a lot when pin count is an issue. It’s the big brother to the attinyX5 series which I’ve found very limiting due to the loss of the reset pin. You can use the reset pin for other purposes, but you’ll need to reset the proc with an hv programmer if you do set it. The X4 is the little brother to the X6 series but with some of it’s own nice characteristics, like 8 and 16bit timers, 4 channel pwm and 8 adc channels.

arduino for other AVR

I use Arduino a lot, since I teach workshops in amsterdam about physical computing and other stuff.

I always like going under the hood, so I started looking at the real power of AVR chips, 

and although arduino is still my choice for quick development, I like the idea of knowing what exactly happens in the micro.

Eclipse is awesome (and cause of much anger), and that plugin makes the development (especially setting fuses and such) really quick with all its editor features.

please, Emacs users, don’t hate me.

ubi

try it

:slight_smile: