Atmel AVR Micro Controller
.Atmel ATmega8 in 28-pin narrow DIP
The AVR is
a modified Harvard
architecture 8-bit RISC single
chip microcontroller which was developed by Atmel in
1996. The AVR was one of the first microcontroller families to use on-chip flash memory for
program storage, as opposed to one-time programmable
ROM, EPROM,
or EEPROM used
by other microcontrollers at the time.
- MegaAVR — the ATmega series
- 4–512 kB program memory
- 28–100-pin package
- Extended instruction set (multiply instructions and instructions for handling larger program memories)
- Extensive peripheral set
The mega-8 micro controller will used in our all discussion and experiments, its pin out is explained as under.
Basic circuit of AVR mega-8
In basic circuit a resistor and a capacitor is tied up to reset pin(No-1).
one quartz crystal (normally 4 or 8 MHz) with 2 nos of stabilizing capacitors
In above circuit the pins on left side are dedicated to specific
task along with power supply.On the other hand all the pins are available to user as general I/Os.
these pins can be either made inputs or out puts.
If you look at the text before the pins you will realized some pins are performed more than on task in addition to general I/Os.This is very useful and it works with full power as multi functional device.
A quartz crystal is works as heart of controllers and provide basic timing signals.
is works as square wave clock generator. Every micro controller has built in clock generator with many mode.
The simplest form of AVR clock generator is RC clock of 1 MHz. it is a default setting of
controller clock. It comes with this setting from vendor. For this setting no need of any external part for the clock.
Mega-8 Trainer
I have design a AVR micro controller trainer. In this design of Trainer I have used minimum components to make a simple controller board for the students to start.
It can be grow as well as your learning is proceed further.
I have place one RS-232 chip and one ULN2003 for some basic practicals.
6 Nos of LEDs are on controller board to perform some basic LEDs practicals.
ULN2003 driver circuit is driving 6 LED and it even drive 6 nos of Relay with relay extension
board.
MAX232 chip perform simple programming without pulling out the controller chip out from the PCB board, and also this chip will perform serial communication with Host PC and other controllers.
It has all the ports header pin to interface with other control board.
There are 4 nos of 8-pins interfacing ports available on this trainer, so LCD board, Relay Board and all other interfacing board can be connected easily.
To see more specifications and price check products tab
Software to develop program
To develop a software program I have choose BASCOM AVR , a very simple IDE to start
learning micro controller programming even if you don't have any previous programming experience.
This software is available at http://www.mcselec.com/, It is very powerful IDE for program writing, debugging, compiling, simulation and program burning into the controller chip.
I have selected Basic program IDE, because it is very "BASIC" and easy for learning.
once you will be expert on one programming language like this it will be very easy to switch over to other language as C those are rather cumbersome to learn at beginning.
This free demo software allow you to make and develop a program up to 4K of flash ROM.
ATMEGA-8 have 8 K Flash program memory space, but this 4K program is more than enough for starting.
When you install this software (BASCOM AVR) in your PC it also install a plenty of learning examples and a help file.
Installing BASCOM AVR
Download the BASCOM AVR free demo program fron the http://www.mcselec.com/
Remember also install LPT1 when installing the program.once finished installation reboot computer as normal. and run the program, you will find window like this.
When we write a program we compile it, if no error it makes many files one of this HEX file which is mostly used for dumping in the controller by the the help of programmer
Write a simple program
I have write a simple program to check Micro-controller trainer board, It will simulate the 6 nos of on-board LEDs and increment one veritable and send a message with the variable current value on PC serially .BASCOM AVR IDE also have one terminal program that can be run within the IDE so the message can be received and viewed on it without leaving the IDE program.
Here is the program.
$regfile = "m8def.dat" ' we use the M8
$crystal = 8000000 ' A 8MHz crystal is used
$baud = 9600 ' Baud rate for serial communication
$hwstack = 32 'Forgot the following 3 lines now
$swstack = 8
$framesize = 24
Dim Num As Word 'We assume a veriable and named it "num"
Config Portb = Output ' Port B cofigure as output
Num = 0 'Initial value of veriable before loop
Do 'Here start loop
Portb = &HFF
Print "Welcome to my world" ; " " ; Num 'send welcome message and veriable
Waitms 100
Portb = 0
Incr Num
Loop 'From here program go up and start from by Do
End 'every program must end with "End"
The above program will switch on and off all 6 leds and send serially a text message "Welcome to my world" and incremental value of variable num to any serial terminal program or built-in BASCOM AVR terminal window.
All comments of green color has no effect in program, even when you compile the program these comments are ignored.
The BASCOM-AVR IDE have many option of program burning.
For mega-8 trainer I have used MCS boot loader programming method.
for this you have to select this option from menu option and programmer then the following window will open
from this window you have to choose MCS Bootloader option programmer drop down combo box as shown in above picture.
Single axes sun tracker projects for solar system
As every body knows sun moves continuously from east to west, if your solar panel is stationary it will loose light concentration and less voltage will result.
For tracking the sun I have designed a project to track and fallow up the sun.
In this project two outputs are used for motor to rotate clockwise and anti clock wise.
Some more addition to be done in this program in future.
program
'$sim
'------------------------------------------------------------------------------
'name : Sun Tracker.bas
'purpose : Tracking the SUN for maximum light for soler system
'micro : Mega8
'------------------------------------------------------------------------------
$regfile = "m8def.dat" ' we use the Mega-8
$crystal = 8000000
$baud = 9400
$hwstack = 32
$swstack = 8
$framesize = 24
Config Portb = Output
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Dim Ldr_left As Word , Ldr_right As Word
Dim Diff1 As Word , Diff2 As Word
Relay1 Alias Portb.2
Relay2 Alias Portb.1
Do
Ldr_left = Getadc(5)
Ldr_right = Getadc(4)
If Ldr_left > Ldr_right Then
Diff1 = Ldr_left - Ldr_right
End If
If Ldr_right > Ldr_left Then
Diff2 = Ldr_right - Ldr_left
End If
If Diff1 > 10 Then
Reset Relay2
Set Relay1
End If
If Diff2 > 10 Then
Reset Relay1
Set Relay2
End If
If Diff1 < 10 And Diff2 < 10 Then
Reset Relay1
Reset Relay2
End If
'******************************************
'For checking purpose only.
Print "LDR Left " ; Ldr_left
Print "LDR Right " ; Ldr_right
Print "diff1 " ; Diff1
Print "diff2 " ; Diff2
'********************************************
'Clear the sun light intency veriables for new values.
Diff1 = 0
Diff2 = 0
Waitms 2 ' wait for sometime for new values.
Loop
End
Nice informative Blog about AVR Micro controller.
ReplyDelete