Let's Make Robots!

Program standalone ATtiny / ATmega chips through an Arduino

1 Program standalone ATtiny / ATmega chips through an Arduino


Table of content
1 . . . . Program standalone ATtiny / ATmega chips through an Arduino
1.1 . . . . Atmel AVR
1.2 . . . . What we will be doing
1.2.1 . . . . What you will learn
2 . . . . Requirements and Resources
3 . . . . Computing environment - Windows or Linux
3.1 . . . . Windows
3.1.1 . . . . Software
3.1.2 . . . . Scripting
3.2 . . . . Linux
3.2.1 . . . . Software
3.2.2 . . . . Scripting
4 . . . . Programming the blank AVR
4.1 . . . . Fuse bits
4.1.1 . . . . Fuse bit examples . . . . Fast running ATtiny13A . . . . Slow ATtiny13A . . . . ATmega8 on internal clock . . . . ATmega8 on internal clock for optiboot . . . . ATmega328p as on my Arduino Duemilanove . . . . ATmega328p with optiboot . . . . ATmega328p slow and low.
4.2 . . . . The program to be loaded onto the targets
4.2.1 . . . . blink . . . . Writing a program (blink) without using the Arduino IDE . . . . Compiling blink.cpp
4.2.2 . . . . optiboot . . . . Download and compile . . . . Comping with the makefile . . . . Hand compiling.
4.3 . . . . Communication with target
4.3.1 . . . . ArduinoISP
4.3.2 . . . . Wiring
4.3.3 . . . . Programming fuse bits
4.3.4 . . . . Uploading program
5 . . . . Adding a new "board" to the Arduino IDE
6 . . . . Manual upload of code to a bootloader (optiboot)
6.1 . . . . Source code
6.2 . . . . Compile statements
6.3 . . . . Upload serially with avrdude
7 . . . . About this article
7.1 . . . . History
7.1.1 . . . . Feb.2012
7.1.2 . . . . Apr.2012
7.1.3 . . . . Jun. 2012
7.2 . . . . Creole




Ok, I did it, I made the ATtiny13A blink a LED.

You see, I got this small ATtiny13A for $0.99 on ebay and the SIP8 to DIP8 board for another $0.90, soldered them together using the drag soldering technique. Go check it on youtube if you wanna try yourself.

After this I only had to write a small blink program and load it onto the chip to reach my first milestone.

This article will try to explain how I did the programming part. After reading it you will hopefully be able to do the same, and an awful lot more!

1.1 Atmel AVR

Atmel have made a series of small micro controllers they call AVR. They are quite popular among hobbyists and on LMR as well. This popularity has not become lesser with the Arduino boards based on these AVR chips.

I will focus on only a few models from this AVR series, ATtiny13A, ATmega8 and ATmega328p.

Depending on the model there are one or more ways to load software on the chip. A common method that works on all three of them is using an ISP - an In-System Programmer.

The ATmegas can also program themselves if they have been preloaded with an bootloader. optiboot is a good free one of those.

1.2 What we will be doing

On the ATtiny we will load the simple blink, and then we will put the optiboot boot loader on the ATmegas.

BTW. Throughout this guide the chip that is going to be programmed is sometimes called the target

1.2.1 What you will learn

  • Building programs for AVR outside the Arduino IDE
  • Calculating fuse values for the AVR
  • Connecting an target AVR chip to an ISP
  • Using your Arduino as ISP

2 Requirements and Resources

To follow the guide here you will need a few resources. I will list what I used, you will most certainly have to improvise a little here and there.

  • A Linux machine running kubuntu-10.04
  • An Arduino Duemilanove
  • A breadboard
  • Some breadboard jumper wires
  • Patience and google!

I read a lot of different tutorials on the net to figure out all the details. Here are some of the more informative ones I found, and still remember: (in random order..)

3 Computing environment - Windows or Linux

Almost all of this guide is based on a using a computer. Even though this is not a general computing textbook we need to establish a common ground, and you have to know a tiny bit about executing commands and scripting them.

I'm a Linux user myself but realize that many of my fellow LMR'ians are Windows users. Therefore I will try to make the guide here compatible with both environments. I have an old windows XP machine to test on, but maybe thing work different on newer windows, I don't know. Since I come from the Linux side, and before that from UNIX, I'm not scared of extremely long command lines. The guide here will include some of those too. I suggest that you simply copy-paste those commands into script files

There are, for this guide to work, two important areas of difference: Software and Scripting

I will make this walk through really quick. This is not a general computing guide!

3.1 Windows

3.1.1 Software

Windows users should install the WinAVR package which can be found here: http://winavr.sourceforge.net/

3.1.2 Scripting

On windows scripts are stored in .bat files. When putting a command into such a file and double clicking on it from the file manager, it will open a command box, execute the command, and close the command box again. Unfortunately the user cannot read the output of the executed command before the box closes again. To overcome this .bat files can be made waiting for user action before proceeding. This is done with command pause

Try copying these two lines to a file named foo.bat, and then executing that file


3.2 Linux

3.2.1 Software

On my linux, which is a kubuntu-10.04 i have installed the following packages which I think is what will be needed:

  • avr-libc
  • avrdude
  • binutils-avr
  • gcc-avr

3.2.2 Scripting

On linux scripts are stored in files too, but they do not have common extension. On linux it's possible to run launch the command files through a file manager, but just as often we would just type their name in a command shell. One important thing is to set the execute bit on the files before trying to run them. This can be done with the command chmod a+x foo.sh

And again, if run via a file manager, the window will close before you can say boo, and you would need some sort of "wait for user input" at the bottom of the script file.

Try copying these three lines to a file named foo.sh, and then executing that file

echo -n Press the Enter key to continue...

4 Programming the blank AVR

Programming a blank AVR involves three tasks

  • The fuse bits to be programmed on the target chip
  • The program code to be loaded onto the target chip
  • Communication with the target chip

The fuse bits tell the target how to work on the most basic levels, some of the more interesting parameters could be:

  • clock generation and dividers
  • reserved memory areas
  • Minimum operational voltage (brown out)

The program can either be something you write yourself (eg. blink) or a program somebody else has written (eg. optiboot).

Communication with the target again consists of two elements

  • An ISP - In-System Programmer
  • Some wiring to connect ISP and target

4.1 Fuse bits

The fuse bits is a set of bits which when programmed into the target, defines how the target work on the lowest possible level. The selection of available fuse bits vary from one AVR model to the next one.

Though its possible to calculate these bits by hand using data sheets and lots of time I strongly recommend the use of an automated tool for this otherwise complex task. I have found the following online tool very easy to use. http://www.engbedded.com/fusecalc

First you select the AVR model, and then the desired options in the "Feature configuration" section. Depending on model the possibilities will be different. At this point I will only bring two warnings

  • DO CHECK "Serial program downloading"
  • DO NOT CHECK "Reset Disabled"

If you fail to do so, and program the resulting bit sets, you could effectively brick your AVR chip. The default values are fine, please make sure the stay that way.

When you are done selecting features scroll down to the "current settings" section. Here you will see two or three hex bytes representing the codes you will have to put into your chip to make it behave the way you have decided. If there is two values they are named Low and High, and if there are three its Low High and Extended. But to make things really easy for you, the tool have even calculated the correct options for avrdude. Simply copy-paste the string which look like the following to your scripts later on to save you some time.

-U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m

By now you should have a clear idea of one particular parameter: clock speed Make a note of your selection, you will be needing it when compiling programs later on.

It's worth noting that you only have to program these fuse bits onto the target once. They stay there until you decide to reprogram them for some reason. Also, since these bits define some internal functional details you could have some dependencies between fuse bits and program. Especially bootloaders like the optiboot we will try later on have some requirements.

Btw. its worth mentioning that fusecalc can also work the opposite way. Take your fuse bits, enter them into the two or three lower fields and see the features they represent above.

4.1.1 Fuse bit examples

I have made a few examples here, just to get you started. Fast running ATtiny13A


  • 9.6MHz internal osc
  • 2.7V brownout

Fuse string for avrdude:

-U lfuse:w:0x7A:m -U hfuse:w:0xFB:m Slow ATtiny13A


  • 9.6MHz internal osc
  • clock divide by 8
  • 2.7V brownout

Fuse string for avrdude:

-U lfuse:w:0x6A:m -U hfuse:w:0xFB:m ATmega8 on internal clock


  • 8MHz internal osc
  • 2.7V brownout

Fuse string for avrdude:

-U lfuse:w:0xA4:m -U hfuse:w:0xCC:m ATmega8 on internal clock for optiboot


  • 8MHz internal osc
  • 2.7V brownout
  • Reserved 256 words (double bytes) for optiboot

Fuse string for avrdude:

-U lfuse:w:0xa4:m -U hfuse:w:0xcc:m ATmega328p as on my Arduino Duemilanove


  • Fast external crystal osc
  • 2.7V brownout
  • Reserved 1024 words (double bytes) for old school bootloader.

Fuse string for avrdude:

-U lfuse:w:0xff:m -U hfuse:w:0xda:m -U efuse:w:0x05:m ATmega328p with optiboot


  • Fast external crystal osc
  • 2.7V brownout
  • Reserved 256 words (double bytes) for the small optiboot bootloader

Fuse string for avrdude:

-U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m ATmega328p slow and low.


  • Runs stable as low as 1.8v. and with low power consumption too.
  • 1MHz internal osc (8MHz divided with 8)
  • 1.8V brownout
  • Reserved 256 words (double bytes) for the small optiboot bootloader

Fuse string for avrdude:

-U lfuse:w:0x62:m -U hfuse:w:0xDE:m -U efuse:w:0x06:m

4.2 The program to be loaded onto the targets

Going through all this has one particular goal, to put a program onto a AVR chip. But which program? It could be anything, something you create yourself or a program somebody else has written. In the following two sections I will show you:

  • how to write your own blink program
  • how to download and install optiboot

Many of the tasks involved are exactly the same and yet other looks the same but differs a little in some obscure parameters. Writing a program (blink) without using the Arduino IDE

To make it clear whats going on, without the obfuscation if the Arduino IDE, and to release me from the task of figuring out all the details of the IDE, I will here show you how to program a AVR without the Arduino IDE. Lets call it Ghetto Style!

The sample program is the classic Blink.cpp, and it's identical on both the ATmega8/ATmega328P and the ATtiny13A. It will flash a LED on pin PB3.

Chip / Board pin
ATmega8 and ATmega328p 17
ATtiny13A 2
Arduino 11

The program looks like this. Copy-paste it to a text editor and save to a file named blink.cpp

#include <avr/io.h>
#include <util/delay.h>

int main(void)
  DDRB = 1<<3; // port B3, ATtiny13a pin 2
  PORTB = 0x0;

  while (1)
    PORTB = 1<<3; // port B3, ATtiny13a pin 2
    PORTB = 0X0;

I suggest that you create a new folder for your project, call it blink or something else that pleases you. Compiling blink.cpp

To compile blink.cpp you will have to do something like the commands below. Remember the notes on scripting above? you probably want to put the lines above into a script and something to pause the script before it terminates, pause for windows and read for linux.

avr-gcc -g -DF_CPU=9600000 -Wall -Os -mmcu=attiny13a -c -o tmp.o blink.cpp
avr-gcc -g -DF_CPU=9600000 -Wall -Os -mmcu=attiny13a -o tmp.elf tmp.o
avr-size tmp.elf
avr-objcopy -j .text -j .data -O ihex tmp.elf tmp.hex

But before you actually runs the script you should pay attention to the options to the compiler, avr-gcc, -DF_CPU=9600000 defines the cpu clock, and -mmcu=attiny13a the type of chip the code will be build to

You will most likely have a clear idea about the chip you are going to program. You probably already have it in front of you.

It is possible to ask the avr-gcc compiler which chips it knows about. (it gives a huge output)

avr-gcc --target-help

The important ones is for this guide:

chip compiler option Example usage
attiny13a -mmcu=attiny13a really small app
atmega8 -mmcu=atmega8 a simple robot
atmega328p -mmcu=atmega328p Arduino Duemilanove

The clock speed is defined by fuse bits and an eventual external oscillator component (crystal, resonator, rc-circuit) You will need to supply this speed to the compiler in Hz. Some examples

Clock speed compiler option Example usage
128KHz -DF_CPU=128000 ATtiny13A on low power
1MHz -DF_CPU=1000000 could be a low voltage appliance
8MHz -DF_CPU=8000000 ATmega8 on fast internal RC osc.
16MHz -DF_CPU=16000000 Arduino Duemilanove

Simply put in the correct value to the script above in the two avr-gcc lines.

After running the compile script you should have a file called tmp.hex in the same folder. please check that before proceeding.

4.2.2 optiboot

optiboot is a bootloader, enabling some of the larger AVR's, mainly the ATmega family to receive new programs via a serial interface. I will go rather quick over these, and especially the options. The details were explained in the blink example above. Download and compile

I use optiboot_v4_4.zip which can be found here: http://code.google.com/p/optiboot/ download and unpack somewhere on your disk, preferably in an newly created directory.

After unpack it must be compiled. You can either use the includes Makefile or do it by hand. Comping with the makefile

A Makefile is a script file usually used for compiling computer programs. Makefiles are read by the program make which in turn executes the commands specified in the makefile. Optiboot is shipped with such a makefile, to make compile and install easy and convenient. The makefile can be used to build optiboot for a wide range of different AVR chips. Since makefiles are just simple textfiles i suggest you at least take a peek inside it, simply open the file in a text editor and look around.

To compile an optiboot bootloader for an ATmega328p it goes like this I type make atmega328 and it looks like this:

> make atmega328
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=16000000L  '-DLED_START_FLASHES=3' '-DBAUD_RATE=57600'   -c -o optiboot.o optiboot.c
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=16000000L  '-DLED_START_FLASHES=3' '-DBAUD_RATE=57600' -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o optiboot_atmega328.elf optiboot.o 
avr-size optiboot_atmega328.elf
   text	   data	    bss	    dec	    hex	filename
    500	      0	      0	    500	    1f4	optiboot_atmega328.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega328.elf optiboot_atmega328.hex
avr-objdump -h -S optiboot_atmega328.elf > optiboot_atmega328.lst
rm optiboot.o optiboot_atmega328.elf

At this point the bootloader is compiled, and now it needs to be installed on the target. To do this I type make ISPTOOL=usbasp atmega328_isp. Here make calls avrdude to do the actual hard work of loading the compiled HEX file onto the chip. More about this a few sections below. This is just to remind you that the shipped makefile can help you here too. Hand compiling.

The folowing is an example on how it's done for the ATmega8 chips. You will need to adjust a little in the second line for the ATmega328p chips. -Wl,–section-start=.version=0x1ffe should be -Wl,–section-start=.text=0x7e00 then. For other chips I suggest to either use of at least look in the makefile mentioned in the previous section.

avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega8 -DF_CPU=8000000L -DLED_START_FLASHES=3 -DBAUD_RATE=115200 -c -o tmp.o optiboot.c
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega8 -DF_CPU=8000000L -DLED_START_FLASHES=3 -DBAUD_RATE=115200 -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o tmp.elf tmp.o
avr-size tmp.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex tmp.elf tmp.hex

Besides the chip type and clock speed options explained in the blink example above there are some specific option for optiboot:

-DBAUD_RATE=115200 code upload rate. if you select a really low cpu clock you will have to lower this one too,
-DLED_START_FLASHES=3 the optiboot code can be made even smaller of this is omitted

I suggest you read the documentation for optiboot before modifying these.

4.3 Communication with target

4.3.1 ArduinoISP

Included with the Arduino IDE package is a version of the ArduinoISP sketch. At least with my IDE version 0022 i found that sketch a little outdated. So I downloaded a new one from http://code.google.com/p/mega-isp/ -> https://github.com/rsbohn/arduinoisp. It is a .ino file, for the version 1.0 of the Arduino IDE. I simply copy-pasted the program to a sketch in my older IDE and saved it for further uses. Upload the sketch to your Arduino and you have a ArduinoISP running with version 04m3. One of the bonuses with version 04m3 is the three status LED's that can be attached to the Arduino to tell you operational status.

Put an LED (with a current limiting resistor) on the following pins:

9 Heartbeat shows the programmer is running
8 Error Lights up if something goes wrong (use red if that makes sense)
7 Programming In communication with the slave

At this point, with your Arduino board turned into a ISP we will not be needing the Arduino IDE any longer; at least not in this tutorial. One last thing you should do before closing the IDE down is to make a note about which serial port were used to communicate with the Arduino. Open the menu Tools->Serial Port and see whcih one is checked. On windows it's usually something like COM13 or as it were on my machine COM99. On my linux it were found at /dev/ttyUSB99. You will need this port name in a little while…

4.3.2 Wiring

Even though this guide mainly focus in using an Arduino as ISP (in-system programmer), I should mention that most of the tasks made here also works with the low cost usbasp, i got mine on ebay for $3.5 incl shipping. Your luck may wary. Of cause the wiring and the way avrdude till talk to the ISP differs.

Back to wiring. Basically its all about connecting the SPI, Serial Peripheral Interface Bus. SPI consists of four signals:

SCK serial clock (output from master)
MISO master input, slave output (output from slave)
MOSI master output, slave input (output from master)
SS slave select (active low, output from master)

As you can see this naming is quite clever, it eliminates the uncertainty that sometimes is seen about from which point of view are we talking. with the SPI everything is clear from the moment you see the four pin names. It's simply a question of connecting SCK to SCP, MOSI to MOSI and MISO to MISO.

The SS signal is not used but instead a signal to reset the target AVR is needed. The use is sorta the same as the SS signal but the polarity and slope is different. On the Arduino, if using the ArduinoISP sketch, this reset-slave-output is even on the same pin as the SS signal.

ArduinoISP targets
SCK 13 19 7
MISO 12 18 6
MOSI 11 17 5
SS/reset 10 1 1
GND GND 8 and 22 4
VCC 5V 7 and 20 8

4.3.3 Programming fuse bits

To program the fuse bits, and the compiled code in the next section, we use the program avrdude. avrdude communicate with the ArduinoISP program that's running on your Arduino. avrdude will instruct ArduinoISP to reset the target and enter programming mode, and then set our fuse bits. Mighty long chain, but it usually works.

To get all this going we need some information, which you should all have at this point:

  • Com port where your arduino is connected (most likely an USB port, but thats OK)
  • The set of fuse bits in two or three bytes. (the pre-cooked avrdude command string is even better)
  • Target type (which chip are we going to program)

The actual avrdude command will look something like this:

avrdude -p attiny13 -P com99 -c stk500v1  -b 9600 -q -U lfuse:w:0x7a:m -U hfuse:w:0xff:m
-p attiny13 type of target
-P com99 com port, linux ports are something like /dev/ttyUSB99
-U lfuse:w:0x7a:m low fuse bits
-U hfuse:w:0xff:m high fuse bits
-U efuse:w:0xff:m extended fuse bits, not used above

Simply replace the "-U lfuse:w:0x7a:m -U hfuse:w:0xff:m" part with the avrdude-command-options you calculated earlier with fusecalc.

4.3.4 Uploading program

If you followed my guide or compiled either blink or optiboot you will have tmp.hex file in your project folder.

Again you will have to adjust type and port parameters as done above when we set the fuses.

avrdude -p attiny13 -c stk500v1 -P com99 -b 9600 -q -U flash:w:tmp.hex

… and now, voila, you have a programmed chip ready to use!

5 Adding a new "board" to the Arduino IDE

Ok, I almost promised myself not to teach you anything about the Arduino IDE, but here comes a tiny bit anyway. If you have been following me this far and have been loading optiboot on a ATmegaXXX chip to use it from the Arduino IDE it would be nice of me to teach you how to learn the IDE about your new "Arduino Board" wouldn't it?

To do this you only need pieces of information you already have used above:

  • chip type
  • clock speed

Under your Arduino sketch folder, you have to create a folder named hardware, and under that yet another folder named something you like eg. MyFancyArduinoClone. And in that folder you create a text file named boards.txt and load it with the following content:

atmega8_8int.name=ATmega8 on a breadboard (8 MHz internal clock)

You should recognize some of the parameters.

parameter meaning
f_cpu clock speed
mcu AVR chip type

6 Manual upload of code to a bootloader (optiboot)

I like to completely understand whats going on, so often I find myself calling compilers and tools directly by hand or simple scripts instead of using an IDE while writing and testing programs. So here comes an example showing how to compile and upload blink to a standalone chip with optiboot. In this case I use the ever popular ATmega328p chip.

6.1 Source code

#include <avr/io.h>
#include <util/delay.h>

int main(void)
//  _delay_ms(5000);
  DDRB = 1<<5;
  PORTB = 0x0;

  while (1)
    PORTB = 1<<5;
    PORTB = 0X0; 

6.2 Compile statements

for a 16MHz ATmega328p

avr-gcc -g -DF_CPU=16000000L -Wall -Os -mmcu=atmega328p -c -o tmp.o blink.cpp
avr-gcc -g -DF_CPU=16000000L -Wall -Os -mmcu=atmega328p -o tmp.elf tmp.o
avr-size tmp.elf
avr-objcopy -j .text -j .data -O ihex tmp.elf tmp.hex

6.3 Upload serially with avrdude

avrdude  -p atmega328p -c arduino -P /dev/ttyUSB98 -b 9600 -U flash:w:tmp.hex -D

7 About this article

7.1 History

7.1.1 Feb.2012

Initial article only focusing in the ATtiny13A, and then a few updates.

7.1.2 Apr.2012

This is a major overhaul of the previous version of my Program standalone ATtiny / ATmega chips through an Arduino Tip/Walk through. NilsB convinced me to try to merge all the updates into one consistent article which is the thing you see here.

7.1.3 Jun. 2012


  • a little about optiboot's makefile.
  • a few ATmega328p examples for the fuse section.
  • how to use the optiboot afterwards

7.2 Creole

The whole thing is written of-line in a text editor (kate) in the creole wiki language and then transformed into html which I have pasted into the LMR page.

Unfortunately LMR/Drupal got really confused about my anchors on the header lines, so I had to remove those. So no direct jumping from the table of content…

And in case you are curious, a have written the creole2html in perl and will put it somewhere on LMR. (when I find a good place to it. perhaps I should make another tip on writing in creole… nah, too far out, I must be the only one neerdy enough to get such an idea…)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Mogul

Great tutorial!

I want to program an atmega16A-PU, but its not listed in the Fuse Calculator site. Is it the same as Atmega16A?

I also want to program it using the Arduino IDE, using a 16Mhz external Crystal. I have a ISP programmer, and a development board for inserting the atmega before going to the barebones/standalone scheme

Im not sure about the right programming fuses for that atmega and the 16Mhz external crystal, with no bootloader.


Could you please help me with this?


Thanks in advance!!


fritsl's picture

What an amazing article, mogul! :)

mogul's picture

Thanks, it took way longer to write that the work it describes took.

vishurockssrivastava's picture

I want to ask a sort of silly question- If all chips require other chips to be bootloaded (I mean, even the bootloaders that come specifically for this purpose have chips in them that are already bootloaded), how was the first chip programmed and run? Any ideas?

Dan M's picture

The original program would have been written in a computer and then downloaded into the individual chips.  The method of copying a bootloader shown here is just a way you can do so at home.


DaveyJones's picture

well IC stands for integrated circuits, and are essentially just a circuit in a box.
i suspect there wasn't really a'first chip' but rather a slow evolution of concepts.


birdmun's picture

hackaday had this post about making a SOIC clip to program smaller packages, and, a couple of the responses also looked useful.

Dan M's picture

This is a very good tutorial. (Collected as a reference to give people).


merser's picture

What a well formatted and detailed explanation. Thanks for this. Collected.

mogul's picture

Thanks. As you probably have guessed, I have spend more than a few hours writing this. Now I just hope it have become clearer this time. When I look at it now I just get overwhelmed....