-->
Showing posts with label Electronics. Show all posts
Showing posts with label Electronics. Show all posts

ATmega Based MENU Building -LCD 16x2 -with 4 Button

By
A menu system Not fully completed only for learning the full code and proteus are available below to download for learning purpose thanking you 

/*
* push_button__lcdMenu.c
*
* Created: 7/30/2017 11:48:27 AM
* Author: Krishna
*/

#include
#include "lcd.h"
#include "delay.h"
#include "button_key.h"
# define F_CPU 1000000UL



struct menu s1= {0}; //s1.menu_up-key =1;


int main(void)
{ int a;
struct menu s1= {0}; //s1.menu_up-key =1;
const char *menu_display[10];
menu_display[0] = " Select Menu";
menu_display[1] = " Set Time";
menu_display[2] = " Set Date";
menu_display[3] = " Set Alaram";
menu_display[4] = " Set Alaram ";
//sub menu
menu_display[5] = " Enter Time ";
menu_display[6] = " Enter Date ";
menu_display[7] = " Enter Alarm ";
menu_display[8] = " Enter Alarm";
LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PB_4,PB_5,PB_6,PB_7);
LCD_Init(2,16);
LCD_GoToLine(0);

DELAY_ms(100);
//LCD_Clear();
while(1)
{

// key_display( key_value);
menu_key_display (s1,menu_display);


LCD_Clear();
for(a=0; a<5 a="" d="" lcd_printf="" pre="" s1.time="">
/*
* button_key.c
*
* Created: 7/30/2017 12:02:39 PM
* Author: Krishna
*/ #include
#include "delay.h"
#include "button_key.h"
#include "lcd.h"

void menu_key_display(struct menu s1,const char *menu_display[]);
void UP_Down_Keyvalue(struct menu s1,int i,int j);

/* Function Key Value For get key */
int Key_pressed(void)
{
while(1){
if (LEFT_S) { while(LEFT_S);return 1; }
if (RIGHT_S){ while(RIGHT_S);return 2; }
if (UP_S) { while(UP_S); return 3; }
if (DOWN_S) { while(DOWN_S);return 4 ; }
if (OK_S) { while(OK_S);return 5 ; }
}
}


/* Function Key Value For Up Key & Enter*/

void menu_key_display(struct menu s1,const char *menu_display[])
{
int ch;
int a;
int menu_position =0;
LCD_DisplayString(menu_display[menu_position]);
do{

repat:
ch = Key_pressed();
if(ch==1||ch==2)
{
if(ch==2)
{ if(ch==2)
{ if(s1.menu_side_key==4)
s1.menu_side_key = 0;
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(*((++s1.menu_side_key)+menu_display));
menu_position=1;

}
}
else if(ch==1)
{
if(ch==1)
{if(s1.menu_side_key==1 ||s1.menu_side_key==0)
{
s1.menu_side_key=5;
}
LCD_Clear();
LCD_DisplayString(*((--s1.menu_side_key)+menu_display));
menu_position=1;
}
}
}

if(menu_position==0)
goto repat;
}while(ch!=5);

a = s1.menu_side_key;
switch(a)
{
case 1: // set time
{
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(menu_display[5]);
LCD_GoToLine(1);
LCD_DisplayString(" HH:MM:SS:PM/AM");
UP_Down_Keyvalue(s1,2,4);
break;
}
case 2: // Set date
{
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(menu_display[6]);
LCD_GoToLine(1);
LCD_DisplayString(" DD:MM:YY");
UP_Down_Keyvalue(s1,2,3);
break;
}

case 3: // set alarm
{
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(menu_display[7]);
LCD_GoToLine(1);
LCD_DisplayString(" HH:MM:SS:AM/PM");
UP_Down_Keyvalue(s1,2,4);
break;
}
case 4: // set alarm
{
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(menu_display[8]);
LCD_GoToLine(1);
LCD_DisplayString(" HH:MM:SS:PM/AM");
UP_Down_Keyvalue(s1,2,4);
break;
}
}

while(Key_pressed()!=5);


}




/* Function Key Value For UP_Down Key */
void UP_Down_Keyvalue(struct menu s1,int i,int j)
{

int ch,lower,upper;
do{
if(j==4)
{
if(i==2)upper=1;
if(i==3)upper=9;
if(i==5)upper=5;
if(i==8)upper =5;
if(i==9)upper =9;
}
if(UP_S)
{
while(UP_S);
if(s1.menu_up_key==upper)
s1.menu_up_key = lower-1;
LCD_GoToXY(1,i);
LCD_Printf("%d",++s1.menu_up_key);
s1.time[i-2]=s1.menu_up_key;
}
else if(DOWN_S) // down

{ while(DOWN_S);
if (s1.menu_up_key==lower)
s1.menu_up_key = upper+1;
LCD_GoToXY(1,i);
LCD_Printf("%d",--s1.menu_up_key);
s1.time[i-2]=s1.menu_up_key;
}
if(RIGHT_S)

{ while(RIGHT_S);
s1.menu_up_key=0;
if(i==9) goto exit1;
if(i==3||i==6)
++i;
i++;
}
exit1:
if (LEFT_S)
{ while(LEFT_S);
s1.menu_up_key=0;
if(i==2) goto exit2;
if(i==5||i==8)
--i;
i--;

}
exit2:continue;


} while (ch!=5); // if Okay key exit loop

}






https://youtu.be/bNwrHuY4Kxk

ATmega Based MENU Building -LCD 16x2 -with 4 Button

By
A menu system Not fully completed only for learning the full code and proteus are available below to download for learning purpose thanking you 

/*
 * push_button__lcdMenu.c
 *
 * Created: 7/30/2017 11:48:27 AM
 *  Author: Krishna
 */ 

#include 
#include "lcd.h"
#include "delay.h"
#include "button_key.h"
# define F_CPU 1000000UL



struct menu s1= {0}; //s1.menu_up-key =1;


int main(void)
{   int a;
 struct menu s1= {0}; //s1.menu_up-key =1;
 const char *menu_display[10];
 menu_display[0] = "   Select Menu";
 menu_display[1] = "  Set Time";
 menu_display[2] = "  Set Date";
 menu_display[3] = "  Set Alaram";
 menu_display[4] = "  Set Alaram ";
 //sub menu
 menu_display[5] = "  Enter Time ";
 menu_display[6] = "  Enter Date ";
 menu_display[7] = "  Enter Alarm ";
 menu_display[8] = "  Enter Alarm";
    LCD_SetUp(PB_0,PB_1,PB_2,P_NC,P_NC,P_NC,P_NC,PB_4,PB_5,PB_6,PB_7);
    LCD_Init(2,16);
    LCD_GoToLine(0);
   
    DELAY_ms(100);
 //LCD_Clear();  
  while(1)
 {
     
  // key_display( key_value); 
   menu_key_display (s1,menu_display);
   
  
   LCD_Clear();
   for(a=0; a<5 a="" d="" lcd_printf="" pre="" s1.time="">
/*
 * button_key.c
 *
 * Created: 7/30/2017 12:02:39 PM
 *  Author: Krishna
 */ #include 
 #include "delay.h"
  #include "button_key.h"
  #include "lcd.h"  
    
void menu_key_display(struct menu s1,const char *menu_display[]);
void UP_Down_Keyvalue(struct menu s1,int i,int j);

 /* Function Key Value For get key  */
int Key_pressed(void)
 { 
 while(1){
    if (LEFT_S) {  while(LEFT_S);return 1; }      
 if (RIGHT_S){  while(RIGHT_S);return 2; }
 if (UP_S)  {  while(UP_S); return 3; }
 if (DOWN_S) { while(DOWN_S);return 4 ; }
 if (OK_S) { while(OK_S);return 5 ; }
 } 
 } 
 
 
 /* Function Key Value For Up Key  & Enter*/
 
 void menu_key_display(struct menu s1,const char *menu_display[])
 {   
  int ch; 
   int a; 
  int  menu_position =0;
   LCD_DisplayString(menu_display[menu_position]);
            do{  
    
    repat:          
    ch = Key_pressed();
    if(ch==1||ch==2)
    {
                  if(ch==2)
                    {  if(ch==2)
                   { if(s1.menu_side_key==4)
                     s1.menu_side_key = 0;
                  LCD_Clear();
                  LCD_GoToLine(0);
                              LCD_DisplayString(*((++s1.menu_side_key)+menu_display)); 
         menu_position=1;            
         
                 } 
                      }
                   else if(ch==1)
                   {   
                             if(ch==1)
                    {if(s1.menu_side_key==1 ||s1.menu_side_key==0)
                      {
                    s1.menu_side_key=5;
                      }
                      LCD_Clear();
                            LCD_DisplayString(*((--s1.menu_side_key)+menu_display));                            
          menu_position=1;   
                         }
                   }  
          }
      
    if(menu_position==0)
    goto repat;
        }while(ch!=5);
       
        a = s1.menu_side_key; 
  switch(a)
     { 
 case 1: // set time
          { 
    LCD_Clear();
       LCD_GoToLine(0);
       LCD_DisplayString(menu_display[5]);
    LCD_GoToLine(1);
    LCD_DisplayString("  HH:MM:SS:PM/AM");
    UP_Down_Keyvalue(s1,2,4);    
          break;
          } 
 case 2: // Set date
        {
         LCD_Clear();
         LCD_GoToLine(0);
         LCD_DisplayString(menu_display[6]);
      LCD_GoToLine(1);
      LCD_DisplayString("  DD:MM:YY");
      UP_Down_Keyvalue(s1,2,3);     
         break;
        }
 
 case 3: // set alarm
          {
         LCD_Clear();
            LCD_GoToLine(0);
         LCD_DisplayString(menu_display[7]);
      LCD_GoToLine(1);
      LCD_DisplayString(" HH:MM:SS:AM/PM");
      UP_Down_Keyvalue(s1,2,4);      
          break;
             }
 case 4:  // set alarm
           {
            LCD_Clear();
          LCD_GoToLine(0);
          LCD_DisplayString(menu_display[8]);
    LCD_GoToLine(1);
    LCD_DisplayString("  HH:MM:SS:PM/AM");
    UP_Down_Keyvalue(s1,2,4);    
          break;
            }
     } 
    
  while(Key_pressed()!=5); 
  
       
 } 
 
 
 
 
 /* Function Key Value For UP_Down Key */
 void UP_Down_Keyvalue(struct menu s1,int i,int j)
 {    
  
  int ch,lower,upper;    
  do{  
    if(j==4)
     {
      if(i==2)upper=1;
      if(i==3)upper=9;
      if(i==5)upper=5;
      if(i==8)upper =5;
      if(i==9)upper =9;
     } 
      if(UP_S)   
      {
      while(UP_S);    
      if(s1.menu_up_key==upper)
      s1.menu_up_key = lower-1;
      LCD_GoToXY(1,i); 
      LCD_Printf("%d",++s1.menu_up_key);
      s1.time[i-2]=s1.menu_up_key;          
      }
   else if(DOWN_S) // down 
             
          {    while(DOWN_S);
            if (s1.menu_up_key==lower)
            s1.menu_up_key = upper+1;        
            LCD_GoToXY(1,i);
            LCD_Printf("%d",--s1.menu_up_key);
      s1.time[i-2]=s1.menu_up_key;       
     }
          if(RIGHT_S)
       
             { while(RIGHT_S);
       s1.menu_up_key=0;
          if(i==9) goto exit1;
          if(i==3||i==6)
          ++i;
          i++;
              }
      exit1:
           if (LEFT_S)
             { while(LEFT_S);
        s1.menu_up_key=0;
            if(i==2) goto exit2;         
            if(i==5||i==8)
            --i;
            i--;
     
             }
    exit2:continue;
   
   
  } while (ch!=5);  // if Okay key exit loop
  
 }
 
 
 



https://youtu.be/bNwrHuY4Kxk

Attepmt to Accessing Keyboad Up and down Key by C programm for a project

By

 * main.c
*
* Created on: Aug 12, 2017
* Author: thannara123




#include
#define FALSE 0
#define TRUE 1 // 0r //!FALSE
struct menu
{
char menu_up_key;
char menu_down_key;
char menu_enter_key :1; // bit feild 1 bit
};
struct menu s1= {0}; //s1.menu_up-key =1;
void struct_1( struct menu,const char *menu_display[]);



int main()
{

const char *menu_display[10];
menu_display[0] = "Menu0";
menu_display[1] = "Menu1";
menu_display[2] = "Menu2";
menu_display[3] = "Menu3";
menu_display[4] = "Menu4";
menu_display[5] = "menu 5";
menu_display[6] = "menu 6";


struct_1(s1,menu_display);
getchar();
return 0;

}


void struct_1(struct menu s1 ,const char *menu_display[])
{

char ch;
do{
ch=getch();


if(ch!='\0')
{
ch=getch();
if(ch=='H')
{
s1.menu_up_key++;
if(s1.menu_up_key==7)
s1.menu_up_key =0;
// printf("UP\n");
printf(" %s\n",*(s1.menu_up_key+menu_display));
}
else if(ch=='P')
{
s1.menu_up_key--;
if(s1.menu_up_key==-1)
{ s1.menu_up_key =6;
goto here;
}
//printf("down\n");

here:
printf("%s\n",*(s1.menu_up_key+menu_display));


}

}
}
while(ch!='e');// while oka key
}
/*
* button_key.c
*
* Created: 7/30/2017 12:02:39 PM
* Author: Krishna
*/ #include
#include "delay.h"
#include "button_key.h"
#include "lcd.h"

void menu_key_display(struct menu s1,const char *menu_display[]);
void UP_Down_Keyvalue(struct menu s1,int i,int j);

/* Function Key Value For get key */
int Key_pressed(void)
{
while(1){
if (LEFT_S) { while(LEFT_S);return 1; }
if (RIGHT_S){ while(RIGHT_S);return 2; }
if (UP_S) { while(UP_S); return 3; }
if (DOWN_S) { while(DOWN_S);return 4 ; }
if (OK_S) { while(OK_S);return 5 ; }
}
}


/* Function Key Value For Up Key & Enter*/

void menu_key_display(struct menu s1,const char *menu_display[])
{
int ch;
int a;
int menu_position =0;
LCD_DisplayString(menu_display[menu_position]);
do{

repat:
ch = Key_pressed();
if(ch==1||ch==2)
{
if(ch==2)
{ if(ch==2)
{ if(s1.menu_side_key==4)
s1.menu_side_key = 0;
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(*((++s1.menu_side_key)+menu_display));
menu_position=1;

}
}
else if(ch==1)
{
if(ch==1)
{if(s1.menu_side_key==1 ||s1.menu_side_key==0)
{
s1.menu_side_key=5;
}
LCD_Clear();
LCD_DisplayString(*((--s1.menu_side_key)+menu_display));
menu_position=1;
}
}
}

if(menu_position==0)
goto repat;
}while(ch!=5);

a = s1.menu_side_key;
switch(a)
{
case 1: // set time
{
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(menu_display[5]);
LCD_GoToLine(1);
LCD_DisplayString(" HH:MM:SS:PM/AM");
UP_Down_Keyvalue(s1,2,4);
break;
}
case 2: // Set date
{
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(menu_display[6]);
LCD_GoToLine(1);
LCD_DisplayString(" DD:MM:YY");
UP_Down_Keyvalue(s1,2,3);
break;
}

case 3: // set alarm
{
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(menu_display[7]);
LCD_GoToLine(1);
LCD_DisplayString(" HH:MM:SS:AM/PM");
UP_Down_Keyvalue(s1,2,4);
break;
}
case 4: // set alarm
{
LCD_Clear();
LCD_GoToLine(0);
LCD_DisplayString(menu_display[8]);
LCD_GoToLine(1);
LCD_DisplayString(" HH:MM:SS:PM/AM");
UP_Down_Keyvalue(s1,2,4);
break;
}
}

while(Key_pressed()!=5);


}




/* Function Key Value For UP_Down Key */
void UP_Down_Keyvalue(struct menu s1,int i,int j)
{

int ch,lower,upper;
do{
if(j==4)
{
if(i==2)upper=1;
if(i==3)upper=9;
if(i==5)upper=5;
if(i==8)upper =5;
if(i==9)upper =9;
}
if(UP_S)
{
while(UP_S);
if(s1.menu_up_key==upper)
s1.menu_up_key = lower-1;
LCD_GoToXY(1,i);
LCD_Printf("%d",++s1.menu_up_key);
s1.time[i-2]=s1.menu_up_key;
}
else if(DOWN_S) // down

{ while(DOWN_S);
if (s1.menu_up_key==lower)
s1.menu_up_key = upper+1;
LCD_GoToXY(1,i);
LCD_Printf("%d",--s1.menu_up_key);
s1.time[i-2]=s1.menu_up_key;
}
if(RIGHT_S)

{ while(RIGHT_S);
s1.menu_up_key=0;
if(i==9) goto exit1;
if(i==3||i==6)
++i;
i++;
}
exit1:
if (LEFT_S)
{ while(LEFT_S);
s1.menu_up_key=0;
if(i==2) goto exit2;
if(i==5||i==8)
--i;
i--;

}
exit2:continue;


} while (ch!=5); // if Okay key exit loop

}



See You



Attepmt to Accessing Keyboad Up and down Key by C programm for a project

By


 * main.c
 *
 *  Created on: Aug 12, 2017
 *      Author: thannara123
 



#include
#define FALSE 0
#define TRUE  1  // 0r //!FALSE
struct menu
 {
   char menu_up_key;
   char menu_down_key;
   char menu_enter_key :1; // bit feild 1 bit
 };
struct menu s1= {0}; //s1.menu_up-key =1;
void struct_1( struct menu,const char *menu_display[]);



int main()
{

     const char *menu_display[10];
      menu_display[0] = "Menu0";
      menu_display[1] = "Menu1";
      menu_display[2] = "Menu2";
      menu_display[3] = "Menu3";
      menu_display[4] = "Menu4";
      menu_display[5] = "menu 5";
      menu_display[6] = "menu 6";


       struct_1(s1,menu_display);
             getchar();
             return 0;

      }


void struct_1(struct menu s1 ,const char *menu_display[])
{

     char ch;
      do{
            ch=getch();


            if(ch!='\0')
            {
              ch=getch();
              if(ch=='H')
              {
               s1.menu_up_key++;
               if(s1.menu_up_key==7)
                 s1.menu_up_key =0;
            // printf("UP\n");
                  printf(" %s\n",*(s1.menu_up_key+menu_display));
               }
         else    if(ch=='P')
               {
              s1.menu_up_key--;
              if(s1.menu_up_key==-1)
                  {  s1.menu_up_key =6;
                   goto here;
                  }
                //printf("down\n");

                  here:
         printf("%s\n",*(s1.menu_up_key+menu_display));


                   }

            }
               }
              while(ch!='e');// while oka key
}
/*
 * button_key.c
 *
 * Created: 7/30/2017 12:02:39 PM
 *  Author: Krishna
 */ #include 
 #include "delay.h"
  #include "button_key.h"
  #include "lcd.h"  
    
void menu_key_display(struct menu s1,const char *menu_display[]);
void UP_Down_Keyvalue(struct menu s1,int i,int j);

 /* Function Key Value For get key  */
int Key_pressed(void)
 { 
 while(1){
    if (LEFT_S) {  while(LEFT_S);return 1; }      
 if (RIGHT_S){  while(RIGHT_S);return 2; }
 if (UP_S)  {  while(UP_S); return 3; }
 if (DOWN_S) { while(DOWN_S);return 4 ; }
 if (OK_S) { while(OK_S);return 5 ; }
 } 
 } 
 
 
 /* Function Key Value For Up Key  & Enter*/
 
 void menu_key_display(struct menu s1,const char *menu_display[])
 {   
  int ch; 
   int a; 
  int  menu_position =0;
   LCD_DisplayString(menu_display[menu_position]);
            do{  
    
    repat:          
    ch = Key_pressed();
    if(ch==1||ch==2)
    {
                  if(ch==2)
                    {  if(ch==2)
                   { if(s1.menu_side_key==4)
                     s1.menu_side_key = 0;
                  LCD_Clear();
                  LCD_GoToLine(0);
                              LCD_DisplayString(*((++s1.menu_side_key)+menu_display)); 
         menu_position=1;            
         
                 } 
                      }
                   else if(ch==1)
                   {   
                             if(ch==1)
                    {if(s1.menu_side_key==1 ||s1.menu_side_key==0)
                      {
                    s1.menu_side_key=5;
                      }
                      LCD_Clear();
                            LCD_DisplayString(*((--s1.menu_side_key)+menu_display));                            
          menu_position=1;   
                         }
                   }  
          }
      
    if(menu_position==0)
    goto repat;
        }while(ch!=5);
       
        a = s1.menu_side_key; 
  switch(a)
     { 
 case 1: // set time
          { 
    LCD_Clear();
       LCD_GoToLine(0);
       LCD_DisplayString(menu_display[5]);
    LCD_GoToLine(1);
    LCD_DisplayString("  HH:MM:SS:PM/AM");
    UP_Down_Keyvalue(s1,2,4);    
          break;
          } 
 case 2: // Set date
        {
         LCD_Clear();
         LCD_GoToLine(0);
         LCD_DisplayString(menu_display[6]);
      LCD_GoToLine(1);
      LCD_DisplayString("  DD:MM:YY");
      UP_Down_Keyvalue(s1,2,3);     
         break;
        }
 
 case 3: // set alarm
          {
         LCD_Clear();
            LCD_GoToLine(0);
         LCD_DisplayString(menu_display[7]);
      LCD_GoToLine(1);
      LCD_DisplayString(" HH:MM:SS:AM/PM");
      UP_Down_Keyvalue(s1,2,4);      
          break;
             }
 case 4:  // set alarm
           {
            LCD_Clear();
          LCD_GoToLine(0);
          LCD_DisplayString(menu_display[8]);
    LCD_GoToLine(1);
    LCD_DisplayString("  HH:MM:SS:PM/AM");
    UP_Down_Keyvalue(s1,2,4);    
          break;
            }
     } 
    
  while(Key_pressed()!=5); 
  
       
 } 
 
 
 
 
 /* Function Key Value For UP_Down Key */
 void UP_Down_Keyvalue(struct menu s1,int i,int j)
 {    
  
  int ch,lower,upper;    
  do{  
    if(j==4)
     {
      if(i==2)upper=1;
      if(i==3)upper=9;
      if(i==5)upper=5;
      if(i==8)upper =5;
      if(i==9)upper =9;
     } 
      if(UP_S)   
      {
      while(UP_S);    
      if(s1.menu_up_key==upper)
      s1.menu_up_key = lower-1;
      LCD_GoToXY(1,i); 
      LCD_Printf("%d",++s1.menu_up_key);
      s1.time[i-2]=s1.menu_up_key;          
      }
   else if(DOWN_S) // down 
             
          {    while(DOWN_S);
            if (s1.menu_up_key==lower)
            s1.menu_up_key = upper+1;        
            LCD_GoToXY(1,i);
            LCD_Printf("%d",--s1.menu_up_key);
      s1.time[i-2]=s1.menu_up_key;       
     }
          if(RIGHT_S)
       
             { while(RIGHT_S);
       s1.menu_up_key=0;
          if(i==9) goto exit1;
          if(i==3||i==6)
          ++i;
          i++;
              }
      exit1:
           if (LEFT_S)
             { while(LEFT_S);
        s1.menu_up_key=0;
            if(i==2) goto exit2;         
            if(i==5||i==8)
            --i;
            i--;
     
             }
    exit2:continue;
   
   
  } while (ch!=5);  // if Okay key exit loop
  
 }
 
 
 
See You 



16 Bit Event Counter & Displaying on LCD1

By
An External Pulse Counter Using 8051 and Dispalying on 16x2 LCD 

  A circuits which is used to count the external pulses And which is displaying on an 16x2 LCD display . You can simply use this project for various purpose .It is a default  project for counting Purpose.



Tutorials : - 


To use 16 Bit counter we need to configure some register in 8051 as follows 

TMOD Register is need to configure as follows
16 bit counter Setting with timer 0

TMOD=0x05; //  Giving 0x05 it configured so .

8051 has Two Timer (each has 16 bit ) i am taking here Timer 0 It has to part First 8 bit (TL)) and the second part is (TH0) .
This timer is using to store the Pulses from the external (ie it will increment up to 65535 or FFFF)

TL0 = 0; // that timer clearing 

TH0 = 0;  // that timer clearing 

 TR0 = 1 // TR0 setting to start the counting .


Done .................................


    After setting the above register as said  the resulted value (counting value ) will save periodically in TL0 and TH0 . That value displaying after converting it to decimal . for LCD Tutorials Go Here



Download Her the all Project Including Proteus file
Click Here

16 Bit Event Counter & Displaying on LCD1

By
An External Pulse Counter Using 8051 and Dispalying on 16x2 LCD 

  A circuits which is used to count the external pulses And which is displaying on an 16x2 LCD display . You can simply use this project for various purpose .It is a default  project for counting Purpose.



Tutorials : - 


To use 16 Bit counter we need to configure some register in 8051 as follows 

TMOD Register is need to configure as follows
16 bit counter Setting with timer 0

TMOD=0x05; //  Giving 0x05 it configured so .

8051 has Two Timer (each has 16 bit ) i am taking here Timer 0 It has to part First 8 bit (TL)) and the second part is (TH0) .
This timer is using to store the Pulses from the external (ie it will increment up to 65535 or FFFF)

TL0 = 0; // that timer clearing 

TH0 = 0;  // that timer clearing 

 TR0 = 1 // TR0 setting to start the counting .


Done .................................


    After setting the above register as said  the resulted value (counting value ) will save periodically in TL0 and TH0 . That value displaying after converting it to decimal . for LCD Tutorials Go Here



Download Her the all Project Including Proteus file
Click Here

Rotation Counter using 8051

By

Rotation Counter using 8051


 I need to make a counter for a transformer winding machine .In that the winding is made by hand . so the roation  need to be keep in mind ,that is too much difficult .So the winding shaft rotaion counting by an infrared sensor module which is connected with 89S52 microcontroler and a LCD .

Infrared based Rotation Counter by 805 or  (contact less Rotation Counter  or Rotation counter without using Interrupt.



 

Code : 


INFRARED Module 


Download the Full Project  CODE and with Proteus  Here

Rotation Counter using 8051

By

Rotation Counter using 8051


 I need to make a counter for a transformer winding machine .In that the winding is made by hand . so the roation  need to be keep in mind ,that is too much difficult .So the winding shaft rotaion counting by an infrared sensor module which is connected with 89S52 microcontroler and a LCD .

Infrared based Rotation Counter by 805 or  (contact less Rotation Counter  or Rotation counter without using Interrupt.



 

Code : 


INFRARED Module 


Download the Full Project  CODE and with Proteus  Here

Microcontroller Based ammeter and voltmeter using Atmega 16

By
Here  Atmega16  measuring the  current and voltage by inbuilt comparator  .Previous post described how to read ADC value click here . Two  ADC port is used  PA0/ADC0  is  measuring voltage .And PA1/ADC1 is  measuring current .

For Advancedtutorials click here Voltmeter Design

                We have to measure 0 to 12 volt, but controller can only read as maximum voltage 5 volt .
Hence a voltage divider circuit used to reduce the corresponding voltage level  at a mximum 5Volt.










take
Vin  = 12volt
Vout = 5 volt.
Assume one of the resistor value and find out the other .
***********************************************************************************
  we have to measure current ,But we cant directly measure the current . there are more technique to measure the current. we uses a shunt resistor method .
The millivoltmeter voltage is taken and calculated by some equation and displayed as current .for more click here

For example .
According Ohm's law,  0.1 Ohm resistor under 1A current will give 0.1V voltage drop
*********************************************************************************




                                             The program shown below
* Created: 14-Oct-15 6:44:15 PM
* Author: Gireesh
*/
#define F_CPU 16000000UL
#include <avr/io.h>
#include<util/delay.h>
#include"lcd.h"
#include "adc.h"

int main(void)

{

unsigned char volt[5] ,current[5];
DDRD = 0xFF;
int v,i;
char ch_sec =0;
adc_init();
lcd_init();
string ("G Electron ");
LINE2
string("Power Supply");
_delay_ms(50);
CLEAR
while(1)

{
v = read_adc(0); // reading voltage
i = read_adc(1); // reading voltage for current
v = (v * 4.89 * 2.4)/10;
i = (i * 2.92);
i = ((i*4.89)/0.47)/10;



if(v< 1200)
{
volt[0] = ((v /1000)%10)+0x30;
volt[1] = ((v /100) % 10) + 0x30;
volt[2] = '.';
volt[3] = ((v/ 10) %10) + 0x30;
volt[4] = (v % 10) + 0x30 ;


string("Volt : ");
for(int i =0; i<5;i++)
lcd_data(volt[i]); // just displaying ADC value
string("V");
}
else
{

string("Over Voltage");
}
LINE2
if(i<3100)
{
current[0] =((i /1000)%10)+0x30;
current[1] = '.';
current[2] = ((i /100) % 10) + 0x30;
current[3] = ((i/ 10) %10) + 0x30;
string("Current : ");
for(int i =0; i<4;i++)
lcd_data(current[i]);
string("A");
}
else
{

string("Over Current");
}
_delay_ms(50);
CLEAR
}
}
design circuits to feed controller for current and Volt. the whole project can be download Below including proteus file For downloading click below
      
                                                 Download

Microcontroller Based ammeter and voltmeter using Atmega 16

By
Here  Atmega16  measuring the  current and voltage by inbuilt comparator  .Previous post described how to read ADC value click here . Two  ADC port is used  PA0/ADC0  is  measuring voltage .And PA1/ADC1 is  measuring current .

For Advancedtutorials click here Voltmeter Design

                We have to measure 0 to 12 volt, but controller can only read as maximum voltage 5 volt .
Hence a voltage divider circuit used to reduce the corresponding voltage level  at a mximum 5Volt.










take
Vin  = 12volt
Vout = 5 volt.
Assume one of the resistor value and find out the other .
***********************************************************************************
  we have to measure current ,But we cant directly measure the current . there are more technique to measure the current. we uses a shunt resistor method .
The millivoltmeter voltage is taken and calculated by some equation and displayed as current .for more click here

For example .
According Ohm's law,  0.1 Ohm resistor under 1A current will give 0.1V voltage drop
*********************************************************************************




                                             The program shown below
* Created: 14-Oct-15 6:44:15 PM
 *  Author: Gireesh 
 */ 
#define F_CPU 16000000UL
#include <avr/io.h>
#include<util/delay.h>
#include"lcd.h"
#include "adc.h"

int main(void)
  
{   
 
 unsigned char volt[5] ,current[5];
   DDRD = 0xFF;
   int v,i;
   char ch_sec =0;
    adc_init();
    lcd_init(); 
 string ("G Electron ");
 LINE2
 string("Power Supply");
 _delay_ms(50);
 CLEAR
 while(1)
 
 {
   v =   read_adc(0);  // reading voltage    
   i =   read_adc(1);  // reading voltage for current  
   v = (v * 4.89 * 2.4)/10;
   i = (i * 2.92);
   i = ((i*4.89)/0.47)/10;
   
   
      
   if(v< 1200)
   {
   volt[0] = ((v /1000)%10)+0x30;
   volt[1] = ((v /100) % 10) + 0x30;
   volt[2] = '.';
   volt[3] = ((v/ 10) %10) + 0x30;
   volt[4] = (v % 10) + 0x30 ;
   
   
   string("Volt    : ");
   for(int i =0; i<5;i++)
  lcd_data(volt[i]); // just displaying ADC value 
  string("V");
  }
  else
  {
 
   string("Over Voltage");
    }
 LINE2
 if(i<3100)
 {
 current[0] =((i /1000)%10)+0x30;
 current[1] = '.';
 current[2] = ((i /100) % 10) + 0x30;
 current[3] = ((i/ 10) %10) + 0x30;
 string("Current : ");
 for(int i =0; i<4;i++)
 lcd_data(current[i]);
 string("A");
 } 
 else
 {
  
  string("Over Current");
 }
 _delay_ms(50);
 CLEAR 
 }  
}
design circuits to feed controller for current and Volt. the whole project can be download Below including proteus file For downloading click below
      
                                                 Download

ADC Reading With Internal Adc Of AVR - Atemga 32 And Displaying On LCD

By

Download HereADC Reading With Internal Adc Of  AVR - Atemga 32 And Displaying On LCD

According to data sheet there are 3 registers are used to works the ADC in AVR atmega 32 
ie , 

1) ADMUX
2)ADSCR
3)ADC



1) ADMUX :-

 It is an 8 bit Register ,each bit has some functions as follows 

REFS1 & REFS0 :- is used for the reference Voltage  with respect to our analog input (for resolution)  to know more search this blog.
I am giving 5volt as reference so selected REFS1 = 0 & REFS0 = 1

ADMUX=(1<<REFS0); // AVcc with external capacitor at AREF  ,giving a high to REFS0.

MUX0-MUX4  :- it is used to select the input channel ,ie 8  analog input channel can be given so desired one selection by giving appropriate value .
  ADLAR : - used to shift the resulted data (ADC Value) left or right .I am using right shift so makes as low.
.....................................................................................................................................

2) ADSCR :-  ADCSRA = (1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);

It is also an 8 bit register .

Bit 7 used to ADC ON (ADC Turn ONing by applying a high bit )
Bit6 ADSC is used to start the conversion .and still maintain it value as high  up to the conversion . after conversion it becomes low (Zero)
ADATE and ADIF is not used by me now .(not by using Intruppet
Bit 0 to bit2  is used for select ADC frequency . 

\
2) ADC: It is a 16 bit to 8 bit register ADCL & ADCH. By applying right shift value it is autmatically set as normal value so we can take simple value from it

 eg :  return (ADC);
 adc_value = read_adc(ch_sec); 

The program as follows . The full program can be download below including Proteus simulation file.






More Posts

gElectron. Powered by Blogger.

Contributors

16x2 LCD Interfacing with STM32,STM32F103C6

 16x2 LCD  Interfacing with STM32,STM32F103C6 lcd_init(); LCD_LINE1; lcd_String(" GeElectron"); LCD_LINE2; lc...

Contact Form

Name

Email *

Message *

Contact us

Name

Email *

Message *

Follow Us

https://www.facebook.com/gElectron-393939667321867/ FBbox/https://www.facebook.com/IVYthemes

Comments

[blogger]

MKRdezign

Test

Latest

[recent][newsticker]

Technology

Top Ads

RECENT COMMENTS

Subscribe Via Email

Subscribe to our newsletter to get the latest updates to your inbox. ;-)


Your email address is safe with us!

RECENT COMMENTS