Search This Blog

Powered By Blogger
Showing posts with label ATmega16. Show all posts
Showing posts with label ATmega16. Show all posts

Wednesday, September 18, 2013

So,you want to start learning microcontroller and other embedded stuffs?

Hello guys,
Well...this is a post for newbies in microcontroller world.Here,I didnt mean a complete newbie by the term "newbie".I am neither gonna talk about resistor capacitor and transistors nor what is microcontroller etc.This post is for someone who knows at least what a microcontroller is and wants to start learning it and requires a guide line on how to start.

WELL...you know what a microcontroller is...hmm???okay...thats cool.Now lets talk about how to start.Well...the first thing is to choose a microcontroller family.Well...I dont want to hurt the feelings of the fanboys of other families...but AVR from Atmel and PIC from Microchip are the two best families for newbies currently...its because of the gigantic number of tutorials and example projects you are gonna find online. www.extremeelectronics.co.in is an excellent site for learning both these families,or the winavr.scienceprog.com for AVR.One hint for the first site...their tutorials are kept in reverse order...so for getting the basic tutorials...u need to go to the last page of the tutorials.
Now lets come to another very very important thing...availability of microcontroller and tools.Well...u need a microcontroller and a tool to program it.Now if you are  not confident enough to make your own programming tool or if you havent got someone who can do it for you,I recommend you buy one...for PIC,buy Pickkit2 or 3(2nd one isrecommended).If you cant buy them,look for their clones.I am giving a few links here

http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en538340&redirects=pickit3

http://www.ebay.com/sch/i.html?_odkw=usbasp&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0.Xpickit2&_nkw=pickit2&_sacat=0

http://www.ebay.com/sch/i.html?_odkw=pickit2&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0.Xpickit3&_nkw=pickit3&_sacat=0

You can check other sources too.

For AVR,

http://www.ebay.com/sch/i.html?_odkw=pickit3&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR2.TRC1.A0.Xusbasp&_nkw=usbasp&_sacat=0
This little programmer is really cool,but its not their official programmer...but you can use it...In fact,I use it for my work and it works just great

http://www.atmel.com/tools/AVRDRAGON.aspx
This is the official one.

Now...a million dollar question...which one to choose???PIC or AVR...well....u guys wont even believe that this question can trigger World war 3(u will see someday,trust me)!!!Well...I would say...go for any.See which one you can afford(Talking about tool),which one is available in your country,..or which one your friend or known ones are using(this suggestion has been given so that you might get help from them).
Now...both Microchip PIC and Atmel AVR are families,not a single microcontroller.There are hundreds of different models of PIC and AVR microcontrollers...My advice is,decide which one you are gonna use,get to the market and buy one model,any model.But onw thing you must know...for starting,choose from 8bit PIC or AVRs...For AVR,I would suggest ATmega16 or ATmega32(a good general purpose microcontroller).For PIC,go for PIC16F877...these micros are highly available AFAIK.
Now...one thing.you might have heard about another thing,ARDUINO....right?????If you havent,dont try to know about it for now.If you have and your friend told you its extremely easy bla bla bla,Now,for that,I want to ask you a question,
Why do you want to learn microcontroller???Is it just for some university term project?Are you going to wipe off all you microcontroller lessons after that project???or do you want to learn microcontroller and become a professional embedded systems expert in your future life?If the first one is the reason,you can go for ARDUINO...but if the second is the reason,dont even think of getting near it for now.Its an excellent platform that uses several microcontrollers from Atmel AVR family(or Microchip PICs or ARMs in different but similar platforms).Its like a magical tool for rapid prototyping etc. and its highly tempting for newbies as well since its extremely easy to use...but sometimes shortcuts DO come with their side effects.If Arduino is your first choice for "learning", you wont even scratch the surface of this vast embedded systems world.First,learn the basics of AVR or PIC,then you will be able to use an Arduino to its limit.So, for now,forget the word Arduino.Its not for newbies who want to become professional.First learn AVR/PIC,then move to Arduino....the path wont be smooth,but at the end of it there is a huge reward.

Saturday, March 31, 2012

Simple Fun Morse Code decoder with AVR microcontroller




Hi people...let's have some fun with AVR micros.This is my first post on any hardware project based on microcontroller except programmer or programming hardware.It's just a fun project but can also be useful to those who practice morse code...Well by this time u know what that thing is...it's a simple morse code decoder with one button,ATmega16(not overkill,kind of superkill for anything like this,but at that time,that was easy to work with for me as I had a development board for 40pin avrs),LCD for showing output.

Unfortunately,that circuit is a history now so I cant post any image of it(Sorry folks).But I will post the schematic and a video I uploaded then to youtube(Though the video quality is...better see for yourselves).
Okay let's come to the point.Many of you know what morse code is...it's an old system of electrical communication where messages are sent as a combination of Dash(long duration beeps or current flow) and dots(shot beeps or current flow).This was used in morse telegraph communications systems.The morse code chart is given below for interested people from wikipedia:


Though I didnt follow the timing issues then,only used the codes.

Now,why this old stuff using new things right???Well,answer is simple...mainly for fun and some skill testing also :) .
Here goes my schematic:

Circuit is pretty simple...just one button for taking input.

I had to add some extra things for displaying to LCD and clearing the LCD etc. such as a 7sec delay after entering the code to show the result on LCD.

The source code was written in Bascom AVR.Its a pretty cool compiler and easy to work with and awesome for string handling and code optimization.The source code is not BIG so It is posted here.

THE CODE:

'8th pin of PORTA used for input

$regfile = "m16def.dat"

$crystal = 8000000

$lib "lcd4busy.lib"
'defining LCD pins
Const _lcdport = Portb
Const _lcdddr = Ddrb
Const _lcdin = Pinb
Const _lcd_e = 2
Const _lcd_rw = 1
Const _lcd_rs = 0
Dim A As Integer 'the delay counter
Dim Bttn_pressed As Integer 'variable to check if the button has been pressed before when released
Dim Mrsc As String * 32 'string for holding the morse code input
Dim Strf As String * 32 'string for holding the processed output
Dim X As Integer 'LCD upper line character position

Mrsc = ""
Strf = ""
Ddra = 0
Cursor Off
Cls
X = 1
Do
If Pina.7 = 1 Then
A = A + 1
Bttn_pressed = 1
Waitms 500
Elseif Pina.7 = 0 Then
If Bttn_pressed = 1 Then
If A = 1 Then
A = 0
Bttn_pressed = 0
End If
If A > 1 And A < 3 Then
Upperline
Locate 1 , X
Lcd "."
Mrsc = Mrsc + "."
A = 0
'Waitms 10
Bttn_pressed = 0
X = X + 1
Elseif A >= 3 And A < 6 Then
Upperline
Locate 1 , X
Lcd "_"
Mrsc = Mrsc + "_"
A = 0
Bttn_pressed = 0
X = X + 1
'Waitms 10

Elseif A >= 6 And A < 12 Then
Select Case Mrsc
Case "._"
Strf = Strf + "A"
Case "_..."
Strf = Strf + "B"
Case "_._."
Strf = Strf + "C"
Case "_.."
Strf = Strf + "D"
Case "."
Strf = Strf + "E"
Case ".._."
Strf = Strf + "F"
Case "__."
Strf = Strf + "G"
Case "...."
Strf = Strf + "H"
Case ".."
Strf = Strf + "I"
Case ".___"
Strf = Strf + "J"
Case "_._"
Strf = Strf + "K"
Case "._.."
Strf = Strf + "L"
Case "__"
Strf = Strf + "M"
Case "_."
Strf = Strf + "N"
Case "___"
Strf = Strf + "O"
Case ".__."
Strf = Strf + "P"
Case "__._"
Strf = Strf + "Q"
Case "._."
Strf = Strf + "R"
Case "..."
Strf = Strf + "S"
Case "_"
Strf = Strf + "T"
Case ".._"
Strf = Strf + "U"
Case "..._"
Strf = Strf + "V"
Case ".__"
Strf = Strf + "W"
Case "_.._"
Strf = Strf + "X"
Case "_.__"
Strf = Strf + "Y"
Case "__.."
Strf = Strf + "Z"
Case "____"
Strf = Strf + " "
End Select
Cls
Lowerline
Lcd Strf
Mrsc = ""
A = 0
X = 1
Bttn_pressed = 0


Elseif A >= 15 Then
Cls
Bttn_pressed = 0
Mrsc = ""
Strf = ""
A = 0
X = 1
End If
End If
End If
Loop
End


Code has been commented so It should be easy to understand...

Here is the (Sorry again for quality)...well...video...:)

If you need some information...tell me.Have fun!!!