Total Pageviews

Wednesday, February 12, 2014

VOLTAGE REGULATOR

LM7805

              LM7805 is an voltage regulator. The last two digits of 7805 ie.(05)
shows the regulated output voltage. The input of LM7805 is 9V or 12V . Circuit for LM7805 is given below

Tuesday, January 28, 2014

4x4x4 led cube connection diagram



8 bit lcd library function for hitech-c

8 bit lcd library function for hitech-c



#ifndef D0
#define D0 RB0
#define D1 RB1
#define D2 RB2
#define D3 RB3
#endif



void Lcd8_Port(char a)
{
if(a & 1)
D0 = 1;
else
D0 = 0;

if(a & 2)
D1 = 1;
else
D1 = 0;

if(a & 4)
D2 = 1;
else
D2 = 0;

if(a & 8)
D3 = 1;
else
D3 = 0;

if(a & 16)
D4 = 1;
else
D4 = 0;

if(a & 32)
D5 = 1;
else
D5 = 0;

if(a & 64)
D6 = 1;
else
D6 = 0;

if(a & 128)
D7 = 1;
else
D7 = 0;
}
void Lcd8_Cmd(char a)
{
  RS = 0;
  RW=  0;         // => RS = 0
  Lcd8_Port(a);             //Data transfer
  EN  = 1;             // => E = 1
  __delay_ms(5);
  EN  = 0;             // => E = 0
}

Lcd8_Clear()
{
 Lcd8_Cmd(1);
}

void Lcd8_Set_Cursor(char a, char b)
{
if(a == 1)
 Lcd8_Cmd(0x80 + b);
else if(a == 2)
Lcd8_Cmd(0xC0 + b);
}

void Lcd8_Init()
{
Lcd8_Port(0x00);
RS = 0;
RW=0;
__delay_ms(25);

  Lcd8_Cmd(0x30);
__delay_ms(5);
  Lcd8_Cmd(0x30);
__delay_ms(15);
  Lcd8_Cmd(0x30);

  Lcd8_Cmd(0x38);    //function set
  Lcd8_Cmd(0x0C);    //display on,cursor off,blink off
  Lcd8_Cmd(0x01);    //clear display
  Lcd8_Cmd(0x06);    //entry mode, set increment
}

void Lcd8_Write_Char(char a)
{
   RS = 1;             // => RS = 1
RW=0;
   Lcd8_Port(a);             //Data transfer
   EN  = 1;             // => E = 1
  __delay_ms(4);
   EN  = 0;             // => E = 04
}

void Lcd8_Write_String(char *a)
{
int i;
for(i=0;a[i]!='\0';i++)
Lcd8_Write_Char(a[i]);
}

void Lcd8_Shift_Right()
{
Lcd8_Cmd(0x1C);
}

void Lcd8_Shift_Left()
{
Lcd8_Cmd(0x18);
}

EXTERNALINTERRUPT(PIC16F877A)-programming





PROGRAM

#include<pic.h>
#include<htc.h>

#define RS RC0
#define RW RC1
#define EN RC2
#define D0 RD0
#define D1 RD1
#define D2 RD2
#define D3 RD3
#define D4 RD4
#define D5 RD5
#define D6 RD6
#define D7 RD7 

#define _XTAL_FREQ 4000000
__CONFIG(WDTDIS & XT & UNPROTECT);
#include"lcd.h"
char a[10];
int count=0,i;
void interrupt isr()
{
if(INTF==1)
{
count++;
i=count;
a[1]=i%10+0x30;
i=i/10;
a[2]=i%10+0x30;
if(count<10)
{
Lcd8_Clear();
Lcd8_Set_Cursor(1,0);
Lcd8_Write_Char(a[1]);
}

if(count>9)
{
Lcd8_Clear();
Lcd8_Set_Cursor(1,0);
Lcd8_Write_Char(a[2]);
Lcd8_Set_Cursor(1,1);
Lcd8_Write_Char(a[1]);
}
INTF=0;
}
}



void main()
{

TXSTA=0X24;
RCSTA=0X90;
SPBRG=0X19;
TRISC=0x80;
TRISD=0x00;
TRISB=0x01;
TXIF=0;
RCIF=0;
GIE=1;
PEIE=1;
RCIE=1;
INTE=1;
INTEDG=1;
INTF=0;
Lcd8_Init();
Lcd8_Clear();
Lcd8_Set_Cursor(1,0);
Lcd8_Write_String("interrupt");
while(1);
}

EXTERNAL INTERRUPT CONFIGURATION IN PIC16F877A

EXTERNAL INTERRUPT CONFIGURATION IN PIC16F877A


  1. External interrupt pin of pic16f877a is RB0.
  2. for setting external interrupt first set TRISB=0x00;(as output)
  3. Then GIE=1,PEIE=1 and INTE=1
  4. Then write interrupt service routine
  5. When interrupt happen the flag INTF will set.
  6. Then clear the flag in interrupt routine itself for next interrupt
  7. sample code is given below.
   #include<pic.h>
    int i;
    void interrupt isr()
   {
     if(INTF==1)
     {
         i++;
         INTF=0;
      }
    }
 
    void main()
    {
        TRISB=0x00;
        GIE=1;
        PEIE=1;
        INTE=1;
      while(1);
     }


This is the program for external interrupt in pic 16f877a micro controller