Kamis, 26 Juli 2012

Arduino Simulator

Simulator for Arduino is the most full featured Arduino Simulator available at the present time
The benefits and features of an Arduino Simulator are:
  • The ability to teach and demonstrate the inner workings of an Arduino sketch
  • Test out a sketch without the hardware, or prior to purchasing hardware
  • Debug a sketch

Download the free version below with a short delay timer on loading a sketch, and when ready upgrade to the Pro Version. Simulator for Arduino Pro Version is currently used in Many countries over six continents. The download consists of a zip file containing a setup.exe file which installs an exe file, help files, images and examples. It is designed for the Arduino Uno or Mega and does the following:
  • Steps through the program line by line. If a new line is selected, the program will continue from that point.
  • Performs digitalWrite, digitalRead and PinMode for pins 0-53
  • analogRead for pins 0-16 and analogWrite for digital pins 0-53
  • Emulates Serial, LCD output, Ethernet, Servo, SD card, EEPROM, SoftSerial,SPI, Wire
  • If,while,for,switch, do whileloop functionality
  • Subroutines (multi-level) with arguments
  • View variables in real-time
  • Step Into, Step Over, Step Out of or Run mode
  • Ability to edit sketch or open in Arduino IDE
  • Tabs for separate files in the sketch
  • Context-sensitive help
  • 2 and 4 line LCD support only with improvised CGRAM
  • 2 dimensional arrays (without initialisation)
  • BreakPoint now with a conditional option
  • load custom libraries automatically after setting the Library Directory
  • Change the font, size and style of the Simulator
  • Advanced watch for easy variable viewing
  • Minimize mode for demo/training
  • Limited support for custom libraries
  • Limited support for pointer and structures
 here is a datasheet for how to use the simulator :
simulator for arduino datasheet





Download the Latest free version here

Arduino Simulation using Proteus

This post will teach you how to simulate arduino sketches using proteus.
The sketch will be written using arduino 0017 edition and you can download it from the following link :
http://arduino.cc/en/Main/Software

We will simulate a simple sketch which flashes a LED.

Here is the sketch to be  :
// example 01 : blinking an LED
const int LED = 13;   // LED connected to pin 13
void setup()
{
  pinMode(LED,OUTPUT);
}

void loop()
{
  digitalWrite(LED,HIGH);
  delay(1000);
  digitalWrite(LED,LOW);
  delay(1000);
}

Steps :

1- After writing the sketch press verify to compile the code.
     (Be sure to select  arduino duemilanove or nano w/atmega328 board from tools tab )
2- And you will find that a new folder named applet has been created this folder containing the .hex file to be simulated using proteus.
3- Build the following schematic using proteus as shown in the following figure :
    ( The crystal used has a frequency 16Mhz)

4-Double click on the microcontroller to load the hex file.
5 Then adjust the CKSEL and clock frequency as shown in the following figure :

Here is a link containing the arduino files and the simulation file :
http://www.mediafire.com/?t2i8s2x4346fnyf\

Download this tutorial in PDF HERE

ATmega 16 problem PC2 to PC5 always high

I have about 5 atmega 16 microcontrollers with PC2 to PC5 pins are always high even if i programmed them as outputs and make PORTC=0x00.this problem occurs when the JTAG interface is enabled in ATmega 16.

To get rid from this problem you have to disable the JTAG.

Here I disablled the JTAG interface using the avr studio and STK500 board.

Steps :

1- Connect the STK500 board through usb .

2- Press on the connect icon as shown in the following picture :

3- Select the STK500 board and auto in the port as shown :

4-  Be sure that atmega 16 microcontroller is selected in the main tab

5- In the fuses tab disable the JTAG interface by unchecking the JTAGEN fuse and the press program at the bottom as shown in the figure :

 WARNING: Before proceeding, I'm not responsible for any damage or short circuit on your circuit. The code and circuit is tested and verified working.

 AIM: To help younger minds to understand the c language and embedded systems working in simple way.

Let me be straight forward to you on this one :)

What is ADC?
Its basically a device having internal comparators and resistors arrangement which gives you digital output value of a corresponding input voltage.
ADC stands for Analog to Digital Converter.

ADC0808 is 8bit conversion system. For more details read the datasheet.
Converts any analog input into 1byte digital output.
It has all-together 8 analog inputs (IN0 to IN7).
Each analog input has an address which is set through control signals A, B, C.
Clock has to be provided for conversion rate.
Faster clock faster conversion.
They recommend 600KHz clock.
I used 555timer at 687Hz which is good enough to convert data on one analog input.
LM324 is used so that there is no drawing current or loading effect on the input side.

First construct this schematic below on breadboard or pcb. (schematic is tested )


Based on my previous design on 16x2 LCD interface to AT89C51 I'm making advantage of it to display my adc data onto it. But this time I'm using separate header files.

After constructing the above schematic. Lets proceed with programming.
Make project in keil software selecting 89c51 microcontroller.
Now next, right click on target 1 and add a group "headers".
Now create this headers files as told below:

1. To make header files create a new file - > save the file in format "filename.h"
2. Add the files to header group in project workspace.
3. Do the above 2 steps for below codes.
This helps in debugging faster.

Check out the image below how its done. (I made group of source and header files)



Now add this files as show above. Keep them all blank and with same names.
Now open the blank 16_2lcd.h file and enter the code below and save it:

///////////////////////////////////////////INSIDE 16_2lcd.h   FILE////////////////////////////////
#include "AT89X51.H"
#include "delay.h"
#include "stdio.h"
#define RW P0_1
#define RS P0_0
#define EN P0_2
#define DATA P2

int lcd_inst(void);     //Instruction sel
int lcd_data(void);      //Data sel
int lcd_latch(void);       //Latch the bus
int lcd_write_str(char *str, int str_len, int line);       //Write string
int lcd_write_int(int num, int num_len, int line); //Write integer
int lcd_write_float(float num, int num_length, int line); //Write float
int lcd_clear(void); //clears lcd screen
int lcd_linsel(int line);    //Lcd line sel
int lcd_initialize(void);    //Initialize the LCD

///////////////////////////////////////////INSIDE 16_2lcd.h   FILE END////////////////////////////////

 Now open the blank adc0808.h file and enter the code below and save it:

///////////////////////////////////////////INSIDE adc0808.h  START////////////////////////////////

#include "AT89X51.H"
#include "delay.h"


#define OE P3_0
#define ALE P3_1
#define A P3_2
#define B P3_3
#define C P3_4

#define ADC_DATA P1


int read_ain(int ain_pin);//Reads ext. Analong in
int set_analongin(int ain_pin);// Sets in0 to in7 pin select.

///////////////////////////////////////////INSIDE adc0808.h  END////////////////////////////////

Now open the blank  delay.h file and enter the code below and save it:

///////////////////////////////////////////INSIDE delay.h  START////////////////////////////////

 void delay(int n); //Universal delay routine


///////////////////////////////////////////INSIDE delay.h  END////////////////////////////////



Now open the blank  16_2lcd.c  file and enter the code below and save it:



///////////////////////////////////////////INSIDE 16_2lcd.c START////////////////////////////////

#include "16_2lcd.h"

int lcd_inst(void)     //Instruction select
{
    RS=0;
    RW=0;
    return 0;
}

int lcd_data(void) // Data select
{
     RS=1;
     RW=0;
     return 0;
}

int lcd_latch(void) // Latch routine
{
            EN=1;
            delay(100);
            EN=0;
            delay(100);
            EN=1;
            delay(100);
            return 0;
}

int lcd_initialize(void)    //Initialize the LCD
{
             RS=0; 
             RW=0;
             EN=1;
             delay(100000);
             lcd_inst();
             DATA=0X38;     //This instruction will Enable 8-bit Databus, Set 2 lines, and Select font size 5x7
             lcd_latch();
             lcd_latch();
             lcd_latch();
             lcd_latch();
             DATA=0X0c;       //It will display the characters, will not display the cursor
             lcd_latch();
             DATA=0X80;    //Set cursor on line 1
             lcd_latch();
             DATA=0X01;       //Clear screen
             lcd_latch();
             lcd_data();
             return 0;
}

int lcd_clear(void)
{
            lcd_inst();
             DATA=0X01;       //Clear screen
             lcd_latch();
             lcd_data();
            return 0;
}
int lcd_linsel(int line)    //Lcd line sel
{
    lcd_inst();
    if(line==1)
    {
             DATA=0X80;    //Set cursor on line 1
             lcd_latch();          
    }
    if(line==2)
    {
             DATA=0XC0;    //Set cursor on line 2
             lcd_latch();          
    }
    lcd_data();
}

int lcd_write_str(char *str,int str_len, int line)
{
    int i;
    lcd_linsel(line);    //Lcd line sel
    lcd_data();
    for(i=0;i<=str_len-1;i++)
    {
            DATA=str[i];
            lcd_latch();
    }
    return 0;
}

int lcd_write_int(int num,int num_len,int line) //Write integer
{

    int i;
    char str[16];
    str[0]=0;
    str[1]=0;
    str[2]=0;
    lcd_linsel(line);    //Lcd line sel
    lcd_data();
    sprintf(str,"%3.0d",num);
    for(i=0;i<=num_len-1;i++)
    {
            DATA=str[i];
            lcd_latch();
    }
    return 0;
}

int lcd_write_float(float num,int num_len,int line) //Write integer
{

    int i;
    char str[16];
    str[0]=0;
    str[1]=0;
    str[2]=0;
    lcd_linsel(line);    //Lcd line sel
    lcd_data();
    sprintf(str,"%3.3f ",num);
    for(i=0;i<=num_len-1;i++)
    {
            DATA=str[i];
            lcd_latch();
    }
    return 0;
}
///////////////////////////////////////////INSIDE 16_2lcd.c END////////////////////////////////


 Now open the blank  adc0808.c  file and enter the code below and save it:

///////////////////////////////////////////INSIDE adc0808.c START////////////////////////////////
#include "adc0808.h"


int read_ain(int ain_pin)// Reads adc value at given pin
{
  int num;
  ADC_DATA=0xFF;
  OE=0;
  set_analongin(ain_pin);
  OE=1;
  num=ADC_DATA;
  OE=0;
  return num;
}

int set_analongin(int ain_pin)// Sets in0 to in7 pin select.
{
      ALE=0;
    switch(ain_pin)
    {
        case 0: A=0;B=0;C=0;break;
        case 1: A=1;B=0;C=0;break;
        case 2: A=0;B=1;C=0;break;
        case 3: A=1;B=1;C=0;break;
        case 4: A=0;B=0;C=1;break;
        case 5: A=1;B=0;C=1;break;
        case 6: A=0;B=1;C=1;break;
        case 7: A=1;B=1;C=1;break;
        default:break;
    }
    ALE=1;
      delay(100);
      ALE=0;
    return 0;
}


///////////////////////////////////////////INSIDE adc0808.c END////////////////////////////////


 Now open the blank  delay.c  file and enter the code below and save it:

///////////////////////////////////////////INSIDE delay.c START////////////////////////////////

 #include "delay.h"


 void delay(int n) //Universal delay routine
{
 int i=0,j=0;
 for(i=0;i<=n;i++)
 for(j=0;j<=10;j++);
}

 ///////////////////////////////////////////INSIDE delay.c END////////////////////////////////


Now open the blank  main.c  file and enter the code below and save it:

  ///////////////////////////////////////////INSIDE main.c START////////////////////////////////

//Programmed by Macjan Camilo Fernandes
//Test Version 1.0.0

#include "16_2lcd.h"
#include "adc0808.h"
#include "delay.h"
#include "REGX51.H"
#include "stdio.h"

int main(void)
{
    float calc;
    int test,i;
    char mac[16];
P3=0;
 //Initialize LCD
 lcd_initialize();
 lcd_clear();
 //write title
//i can be from 0 to 7 since only 8 channel select
  i=3; // to read analog input at pin in3 of ADC0808
  sprintf(mac,"ADC Data %d in V",i+1);
  lcd_write_str(mac,15,1);       //Write string
 while(1)
 {
   test=read_ain(i); //reads analog input of channel i
   calc= test*0.0195; //calculates voltage for vref=5v vref-=0v
   delay(100);
  //Write_adc data on LCD
  lcd_write_float(calc,5,2);         //Write adc data
 }


return 0;
}

  ///////////////////////////////////////////INSIDE main.c END////////////////////////////////

After doing this above process. Compile and program the microcontroller.
Check the ADC value. 
The adc0808.h and adc0808.c was done by me so that you can make use of adc easily if you include this header files in main code as shown above.
Use this function   
int read_ain(int ain_pin);// Reads adc value at given pin

eg: x=read_ain(3); 

This instruction above will store value of adc input IN3 value into x variable which you can then process into your desired calculations.
You can go though the header files and source files for deeper details.

Some snapshots of my demo for one ADC input at ADC0808 in3





All the best to you,
Will be updating my blog with lots of interfaces. Be in touch.

Thank you for reading,
Macjan Camilo Fernandes (MCF) 

Rabu, 27 Juni 2012

ATMEGA32 AVR course

Watchdog Timer Concept

The Watchdog Timer is a timer connected to a completely separate RC oscillator within the microcontroller.
If the watchdog timer is enabled, every time it counts up to the program end, the microcontroller reset occurs and program execution starts from the first instruction. The point is to prevent this from happening by using a specific command. The whole idea is based on the fact that every program is executed in several longer or shorter loops.
If instructions which reset the watchdog timer are set at the appropriate program locations, besides commands being regularly executed, then the operation of the watchdog timer will not affect program execution. If for any reason (usually electrical noises in industry), the program counter “gets stuck” on some memory location from which there is no return, the watchdog will not be cleared and the register’s value being constantly incremented will reach the maximum et voila! Reset occurs!



for more details and learn more about microcontroller modules see the following link :
Source:mikroe

Simple Programmer for ATMEGA8

>> ATMEGA 8 used a lot in arduino kits and in this post we will show you how to make a simple programmer for atmega8.

 Main components :

1) components for the programmer.


2) components for the board

Schematic diagram :

 The board circuit diagram :

>> to use this programmer you have to use PonyProg  software which can be downloaded at the following link :

>> after installing the software adjust the connection paramters as following :

>> then connect the cable and choose avr micro and atmega8 as shown :

>> open the hex file as shown :

>> then press command and choose write program flash and the following message will appear :

>> press yes and the writing process started :

===========================================================
DONE



Real Time Clock using ATMega16

Description

The ATMega16 chip has a real-time counter that operates asynchronously when a 32,768hz watch crystal is connected to it, providing a real-time clock. The watch crystal needs to connect to pins TOSC1(pin 28) and TOSC2(pin 29).


 

 Hardware requirements

  • ATMega16
  • 32,768 KHz crystal
  • LCD display
>> The following software (using codevision avr compiler ) uses timer 2 CTC compare match and ther are three switches used to adjust seconds,minutes and hours.
>> Timer 2 use prescalar 1024 and the OCR value will be 32 or (20 hex).

Code Sample

#include <mega16.h>
// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x1b ;PORTA
#endasm
#include <lcd.h>
char s=0,m=0,h=0;
char t,u;
// Timer 2 output compare interrupt service routine
interrupt [TIM2_COMP] void timer2_comp_isr(void)
{
// Place your code here
s=s+1;
    if (s==60)
    {
    s=0;
    m=m+1;
        if (m==60)
        {
        m=0;
        h=h+1;
            if (h==24)
            {
            h=0;
            }
        }
    }
   
}

// External Interrupt 1 service routine
interrupt [2] void int0(void)
    {
    s=s+1;
    if(s==60)
        {
        s=0;
        }
    }
interrupt [3] void int1(void)
    {
    m=m+1;
    if(m==60)
        {
        m=0;
        }
    }
interrupt[19] void int2(void)
    {
    h=h+1;
    if(h==24)
        {
        h=0;
        }
    }
///////////////////////////////
char tenth(char a)
{
t=a/10;
return t;
}
//////////////////////////////
//////////////////////////////
char unit(char b)
{
t=b/10;
u=b-t*10;
return u;
}
////////////////////////////////
// Declare your global variables here
void main(void)
{
// Timer/Counter 2 initialization
// Clock source: TOSC1 pin
// Clock value: PCK2/1024
// Mode: CTC top=OCR2
// OC2 output: Disconnected
ASSR=0x08;
TCCR2=0x0F;
TCNT2=0x00;
OCR2=0x20;
// LCD module initialization
lcd_init(16);
TIFR|=0x80;
// Global enable interrupts
#asm("sei")

while (1)
      {
      // Place your code here
      lcd_gotoxy(0,0);
      t=tenth(h);
      lcd_putchar(t+0x30);
      u=unit(h);
      lcd_putchar(u+0x30);
      lcd_putsf(":");
      t=tenth(m);
      lcd_putchar(t+0x30);
      u=unit(m);
      lcd_putchar(u+0x30);
      lcd_putsf(":");
      t=tenth(s);
      lcd_putchar(t+0x30);
      u=unit(s);
      lcd_putchar(u+0x30);
      };
}


Proteus Simulation

Real Time Clock using ATMega16

>>>> Here is a link containing the project avr and its proteus simulation
Download Here

Download this tutorial in PDF HERE

Speed and Direction Control of a DC motor

>> The pulse width modulation (PWM) mode in timers of ATmega 16 have the main purpose of controlling the speed of a dc motor.
>> This is a simple program where the PWM is used to gradually increase the speed of the dc motor until reach max speed.
>> Also the speed of the dc motor is decreased gradually until the motor stops.

Program Specification

1- The program use ATmega16 MUC.
2- L293D to supply the required current for the motor
3- 4 buttons are uesd to contol dc motor.
      >> sw1 : to speed up dc motor speed until max in clock wise direction.
      >> sw2 : to decrease dc motor speed until it stops in clock wise direction.
      >> sw3 : to speed up dc motor speed until max in counter clock wise direction.
      >> sw4 : to decrease dc motor speed until it stops in counter clock wise direction.

>>>>>>> This code can be used in controlling lift (elevator ) motor.

Code Sample

#include <mega16.h>
unsigned int d=4369,x,y;
char flag;   // flag =1 left direction , flag =0 right direction
// Timer 1 overflow interrupt service routine
interrupt [9] void timer1_ovf_isr(void)
{
// Place your code here
if (flag ==1)
    {
    if (x==0)
        {                     
        TIMSK &=0b11111011;     // disable interrupt
        }
    else
        {
        OCR1A=OCR1A-d;
        x=OCR1A;
        }
       
    }
if(flag==0)
    {
    if (y==0)
        {                     
        TIMSK &=0b11111011;     // disable interrupt
        }
    else
        {
        OCR1B=OCR1B-d;
        y=OCR1B;
        }
    }   
   
}


void main(void)
{
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Ph. & fr. cor. PWM top=ICR1
// OC1A output: Non-Inv.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: On
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x10;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0xFF;
ICR1L=0xFF;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Global enable interrupts
#asm("sei")

while (1)
      {
      // Place your code here
      if (PINA.0==1)
         {
          OCR1A=0xffff;
          x=OCR1A;
          TCCR1A |= 0b11000000 ; // inv mode for OC1A
          TCCR1B |= 0b00000010 ; // start timer one with 1 mhz
          flag =1;      
          TIMSK |=0b00000100;
          while (PINA.1==0)
          {}
          OCR1A=0xffff;
          x=OCR1A;
          TCCR1A &= 0b10111111 ; // non inv mode for OC1A  
          TIMSK |=0b00000100;
         
         }
      if (PINA.2==1)
         {
         OCR1B=0xffff;
         y=OCR1B;
         TCCR1A |= 0b00110000 ; // inv mode for OC1B
         TCCR1B |= 0b00000010 ; // start timer one with 1 mhz
         flag =0;
         TIMSK |= 0b00000100;    // enable interrupt
         while (PINA.3==0)
         {}
         OCR1B=0xffff;
         y=OCR1B;
         TCCR1A &= 0b11100000 ; // non inv mode for OC1B
         TIMSK |= 0b00000100;    // enable interrupt
         
         }
      };
}

Proteus Simulation

>>>> Here is a link including the project file using codevision avr compiler and proteus simulation
Download Here

Download this tutorial in PDF Here

Selasa, 26 Juni 2012

STK 500 troubleshooting problems

 Problem 

A problem occured while executing the command. make sure that you are using the correct programming method.current mode is ISP ..............


 SOLUTION  ( 1 ) 

Step 1:

>> Go to the tab HW settings in the connection dialog and set the clock generator to max (3.6 MHZ) as shown in the following image

Step 2:

>> Go to the main tab and inprogramming mode and target settings press on settings.

>> Select the ISP frequency to be 115.2 KHZ and then press write.

SOLUTION  (2)

Disconnect all connections to all ports.

Testing UART of Atmega16

Here is a simple program to test the UART communication of the atmega 16

>> The UART in atmega 16 can send frames ranges from 5 bits to 9 bits
>> In this program we use the assynchronous mode
>> The frames used 8 and 9 bits.

UART  transmitter code


// USART initialization
// Communication Parameters: 8 Data, 1 Stop, Even Parity
// USART Receiver: Off
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x08;
UCSRC=0xA6;
UBRRH=0x00;
UBRRL=0x19;

while (1)
      {
      // wait for UDR register to be empty (bit 5 in UCSRA register)
      while((UCSRA & 0b00100000)==0)
      {}
      UDR = PINA;
       };



UART receiver code


// USART initialization
// Communication Parameters: 8 Data, 1 Stop, Even Parity
// USART Receiver: On
// USART Transmitter: Off
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x10;
UCSRC=0xA6;
UBRRH=0x00;
UBRRL=0x19;

while (1)
      {
      // wait for reception flag to be raised (bit 7 in UCSRA)
      while ((UCSRA & 0b10000000)==0)
      {}
      // check for errors
      if (((UCSRA&0b00010000)|(UCSRA&0b00001000)|(UCSRA&0b00000100))==0)
      {
      PORTC=UDR;
      }
      else
      {
      PORTD.7=1;  // indication for error
      }
      };


>>>> Here is a link including codevision project for UART tx and rx using frames of 8 bits and 9 bits and their proteus simulation :

Testing SPI communication

Here is a simple code written in c to test the SPI communication using atmega16 the avr code vision compiler is used here.

>> In SPI communication : one uc is programmed as a master (initiates communication) and the other uc is programmed as a slave.

Here is the master C code

// SPI initialization
// SPI Type: Master
// SPI Clock Rate: 1000.000 kHz
// SPI Clock Phase: Cycle Half
// SPI Clock Polarity: Low
// SPI Data Order: MSB First
SPCR=0x50;
SPSR=0x00;

while (1)
      {
      // Place your code here
      PORTB.4=0;
      SPDR=PINA;
      while(SPSR.7==0)
      {}
      status=SPSR;
      PORTC=SPDR;
      };

Here is the slave C code

// SPI initialization
// SPI Type: Slave
// SPI Clock Rate: 1000.000 kHz
// SPI Clock Phase: Cycle Half
// SPI Clock Polarity: Low
// SPI Data Order: MSB First
SPCR=0x40;
SPSR=0x00;
while (1)
      {
      // Place your code here
      SPDR=PINA;
      while(SPSR.7==0)
      {}
      status=SPSR;
      PORTC=SPDR;
      };



Proteus simulation




Here is the link of the master and slave codevision projects and proteus simulation :
Two types of AVR programmers can be built :

Serial port programmer(reference: At-Prog) is shown here. Main advantage of using serial port is you can have cable length upto 2m. You can use PonyProg2000 software to program your AVR using this programmer. Serial port generates +- 12V on its pins, thus diodes and zener diode is used to clamp +12V to +5.0V(4.7V due to zener + 0.3V due to bat85) and -12V to -0.3V (due to lower Bat85). You can substitute Bat85 with 1n4148, however it is not recommended because, this diode will clamp +12V and -12V to +5.4V and -0.7V which are not desirable, as per datasheet of microcontroller. Its not that micro will burn if you use 1N4148 diodes, but why to take risk !!.


NOTE: 

The ponyprog2000 software is found in the following link:

CIRCUIT DIAGRAM :


LIST OF COMPONENTS :

1)Resistors1K,1/4W4
2)Capacitors27pF,disc2
1µF , electrolytic2
3)Crystal4Mhz OR 8Mhz1
4)Voltage regulator78051
5)ConnectorD9 Female 1
6)DiodeBat858
7)Zener Diode 4.7V1
8)Grid PCB3″ x 3″
9)Connecting wires--

CONFIGURING AND USING PONYPROG2000 :

  1. All steps are same as described in parallel port programmer section, However during third step do the following settings : select “serial”, from list select “SI prog I/O”, select “COM1″( usually serial port is at COM1, if your computer have more than one serial ports multiple options will be active. Select appropriate, if you know, else do trial&error), check “Invert Reset”. Click on OK.

COMMENTS :

• Circuit diagrams shown above are generic and suitable for any AVR µC which supports ISP (almost all AVR, you can refer to www.atmel.com)
• Connect pins (e.g. MISO,MOSI, etc…) of AVR to appropriate points shown in circuit diagram.
• You can built programmer for more than one AVR devices by using different IC sockets for each device and doing appropriate connections of all above signal lines ( MISO,MOSI,SCK,RESET,X1,X2) and Vcc,Gnd of each AVR.
• Prefer using ZIF socket with IC base(refer: How to use ZIF socket in circuit without re-drilling holes on PCBs). Though It is bit costly, it proves extremely helpful.


NOTE:

you can use a usb to RS232 cable if you dont have a RS232 port in your pc
Two types of AVR programmers can be built :

PARALLEL PORT 

Following circuit diagram shows ultra simple AVR microcontroller (SOURCE: unkown). It requires very few components and its very simple to build on general purpose matrix PCB. You can use PonyProg2000 software to program your AVR using this programmer.


NOTE: 

The ponyprog2000 software is found in the following link:

CIRCUIT DIAGRAM :

LIST OF COMPONENTS :

1)Resistors220Ohms ,1/4W4
2)Capacitors27pF,disc2
1µF , electrolytic2
3)Crystal4Mhz OR 8Mhz1
4)Voltage regulator78051
5)ConnectorD25 Male1
6)Grid PCB3″ x 3″
7)Connecting wires--

• As programmer circuit is very simple, u can use substitutes if particular component is not available at your place.
• You will not get 3”x 3” GPCB ready made, you have to cut standard sized PCB. 3” x 3” is just rough estimate


CONFIGURING AND USING PONYPROG2000 :

  1. Open PonyProg2000
  2. Select menu : Setup>Interface Setup
  3. Select “parallel”, from drop down box select “Avr isp i/o”, select “LPT1″. Click OK.
     4.Now select menu Setup>Calibration. A dialog box will appear , click YES.
     5.Now PonyProg2000 is configured and ready to use.
     6.To burn your .Hex file into micro, select File>Open Program(FLASH) file.
     7.Select appropriate microcontroller from the list of devices at top-right. e.g >
      8.Connect your programmer ckt to PC, then place your micro into programmer ckt and turn on its power supply.
      9.Now click on the encircled icon :
        10.When device is programmed you will get “Program succesful” message.

Getting started with Atmel microcontroller

Here is a simple course to learn how to start using atmel microcontrollers.
We will use atmega16 microcontroller.
Getting started with Atmel microcontroller


Here is a link for atmega16 datasheet :
datasheet

Course contents

1- Introduction.
2-Memories in uc.
3-I/O ports.
4-External and Internal interrupts.
5-Timers.
6-clock sources and sleep modes.
7-reset sources and watch dog timer.
8-communication using SPI or USART.
9-dealing with analog signals.

Here is a link for lectures (presentations)

Programs used in this course are :

NOTE :

 You need to know basics of C language ( you can see this link : Summary of C language )