This chapter is based on the practical consideration of controller circuit.
Fig.8.1 Shows the Pin diagram of AVR atmega 16 micro controller
Fig. 8.1 Pin diagram
- Most Single Most Single-clock Cycle Execution clock Cycle Execution
- 32 x 8 General Purpose Working Registers
- Fully Static Operation
- Up to 16 MIPS Throughput at 16 MHz
- On-chip 2-cycle Multiplier
- 16K Bytes of In-System Self-programmable Flash program memory
- 512 Bytes EEPROM
- 1K Byte Internal SRAM
- Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
- Optional Boot Code Section with Independent Lock Bits In-System Programming by On-chip Boot Program true Read- While-Write Operation
- Programming Lock for Software Security
Fig. 8.2 Circuit Diagram of AVR controller
Fig. 8.3 Power supply for Micro Controller
Programming is done in C language.
Following is program of generating pulse for multilevel inverter
#include <avr/io.h>
#ifndef F_CPU
#define F_CPU 3590000UL
#endif
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include <avr/eeprom.h>
#include "LCD.h"
void delayT2();
prog_uchar COMP_NAME1[]="VGEC CHANDKHEDA";
prog_uchar COMP_NAME2[]="PWE GROUP NO ";
prog_uchar DUTY_INV[]="Tms IN1%IN2%IN3%";
unsigned int dinv1,dinv2,dinv3,Tduty;
int main(void)
{
DDRB|=(1<<3); // B3 AS OC0 PWM O/P, B1 & B2 TOGGLE AT TCCR2 TIME 10ms
DDRD|=(1<<4)|(1<<5)|(1<<7); // D4,D5,D7 AS OC1A/OC1B/OC2 PWM O/P &
DDRD=0XFF;
TCCR0=0X73; // CLK/64, FOC=3.59 MH, PHASE INV PWM MODE
TCCR1B=0X03;
TCCR1A=0XF1;
TCCR2=0X7E;
OCR0=26; // .5 MS
OCR1B=77; //1.5 ms
OCR1A=153; //3ms
OCR2=128; //9ms
Tduty=0X14; // TOTAL DUTY CYCLE TIME 20ms=510 pulses of one timer cycle
dinv1=0X59; // dinv1=(510-(2*OCR0)/510)*100 %
dinv2=0X46; // dinv2=(510-(2*OCR1A)/510)*100 %
dinv3=0X28; // dinv3=(510-(2*OCR1B)/510)*100 %
InitLCD(ALL_BLINK);
_delay_ms(100);
LCDGotoXY(0,0);
LCDWriteString(COMP_NAME1,0,0);
LCDGotoXY(0,1);
LCDWriteString(COMP_NAME2,0,1);
_delay_ms(10000);
LCDClear();
_delay_ms(100);
LCDGotoXY(0,0);
LCDWriteString(DUTY_INV,0,0);
LCDGotoXY(0,1);
LCDWriteInt(Tduty,2,0,0);
LCDGotoXY(5,1);
LCDWriteInt(dinv1,2,0,0);
LCDGotoXY(9,1);
LCDWriteInt(dinv2,2,0,0);
LCDGotoXY(13,1);
LCDWriteInt(dinv3,2,0,0);
while(1);
return(0);
}