Tuesday, 31 March 2015

TRIS and PORT setting

Usually, those who study programming will first have this confusion of TRIS and PORT value setting . Here is what it is.

Before doing programming we have to define each port as input or output ports.. A particular pin ONLY can perform one duty at a time.. OUTPUT or INPUT .. So before starting programming we have to specify what pin it is whether input or output..For that we use TRIS command

If a port contains 8 pins.. to set 0th pin as input and rest as output (consider PORT as B)

    "1" shows that particular pin as input and "0" sets that particular pin as output.



Thursday, 10 April 2014

First program on mplab _ led program

First program on mplab _ led program


LED blinking  is a basic thing that a fresher must do in electronics..
Moving on to MPLAB IDE .. requirements for this led blinking project

1. MPLAB IDE
2. Proteus ISIS

Now I am not going to show how select a new project in MPLAB, since i already have explained it in the previous blog
for reference

http://gettingstartedwithmplab.blogspot.in/

Now here I am using PIC 16F873

I am connecting a led in the RB0 pin .

positive end of the led is connected to the supply voltage +5v through a 330 ohm resistor.

program is as follows


#include<pic.h>
volid main()
{
TRISB=0X00;
PORTB=0XFF;
}


This small program will turn on led connected to any pin the the PORT B..

TRISB is a command that we used to initialize the port B as output..
PORTB is used to give value to the pins of the port B. 0XFF
will declare value '1' to all the pins in the port that is logically high and that makes the led glow ..


if you have a doubt with setting TRISB and PORTB commands go to the following link ..


here is the screenshot of Proteus ISIS simulation

hope you guys understood everything.. Thankyou . :) 

Tuesday, 8 April 2014

GETTING STARTED WITH MPLAB IDE


                GETTING   STARTED   WITH    MPLAB IDE


           Hope you have all basic requirements that i have told for this tutorial .
           If yes we can proceed or  else  click the link below and find requirements ..

http://gettingstartedwithmplab.blogspot.in/2014/04/basic-requirements-before-you-start.html


So double click on MPLAB IDE shortcut on desktop or in the start button ..







Now a window will open, like



Now what we have to do is to start a new project .For that on the main toolbar you can see many like
File , Edit , View , Project ,Debugger, Programmer  etc ..
we will discuss about these whenever needed. So for now you just click on PROJECT

Project >> Project wizard...
Now a window will open like shown in image below


Click on next button .
now a window will open and here you have to choose  the PIC you going to use.



Here i am using PIC 16F873A , so am selecting that . MPLAB IDE got a wide range of pics and you can select your own by clicking on that down arrow key..

And now click on the next button ..
new window will be like ..


This part is to choose your compiler..choosing compiler is up to you and depends on what kind of programming style and PIC that  we are choosing . Here am choosing 16f873a pic and we will go with HI-TECh UNIVERSALtool suite.. This may be not there in the available lists but no  need to worry , you can download the toolsuite file from below link.

                 http://hi-tech-universal-toolsuite-plugin-for-m.software.informer.com

Now , if you dont have hitech universal toolsuite download that and restart mplab ide.. and if you have tool suite,select that from the list , to see the list click on that down arrow

 now select hitech universal toolsuite in this window select that click NEXT .


Now what we have done is that we have selected our PIC and COMPILER.  Next part or window is where we create our project file.




You can see a browse button near to that field .

I will suggest you to create a new folder somewhere in your computer for new project and in this browse section , select your folder in which u want to  store program and particular project .
Here i had created a folder on desktop named "getting started" . So i will click on browse and select that folder from desktop
click open and then ,


Now type name of your project file and click save . Here i had created a project named sample .



Now click on NEXT for our last section of creating project file ..


Now click next .. 

This page is the last page.. In this summary you can check everything  PIC , COMPILER , FOLDER , are wright or not now if everything is wright  click finish and your new project is ready ..  :)
Now the project you have saved is a "mcp" file , sometimes another dialogue box appears asking to save mcw file. click save ..
now both mcp and mcw files are craeted that means you can start programming now .. :)


Finished page will look like


Now check three things,

1. Your project name on top left of screen


2. Your pic name on bottom of the screen.

3. A box on left of screen with , Your project.mcp file and source file, header file etc as subdivisions ..



Now if these  3 are perfect then you have successfully created a new project in mplab ide :)

Now we can  start programming :)

For starting from the basics of programming check on my next post or follow the link below :)

gettingstartedwithmplab.blogspot.in/2014/04/first-program-on-mplab-led-program.html

Basic requirements - Before you start MPLAB IDE

           

       BASIC  REQUIREMENTS - BEFORE  YOU START 

                                     MPLAB  IDE


 MPLAB IDE is a software used for writing  and burning  a program in your pic and there by control your circuit in your own way .  

Before starting with our tutorial what all u need 

* MPLAB IDE (any version, here i am using v8.33) - 
( you can d=find the software in microchip website or follow the link below)


*BASIC C programming language knowledge.. no need to be a professional in coding . Just basics will do the job. You should be familiar with for loops and while loops

* PROTEUS - software for virtual testing of our program and circuits 

you can find one from labcenter electronics website or follow the below  link 

                        www.labcenter.com/products/pcb/pcb_overview.cfm     

          
          

Now if these three basics are there with you we will start .. 

                                                
see the next post "GETTING STARTED WITH MPLAB"