pulse counter

pulse counter is used in many application, you can see visitor counter installed at the entry and exit of mall,theater etc and many times in a factory for production measurement and control.pulse counter that i have designed is based on Atmel AT89C4051 micro-controller operated at 11.0592 MHZ frequency. it is assumed you know to interface LCD with MCU.

PROTEUS DESIGN

port P2 is connected to lcd ,number of pulses being fed on Port pin P3.4 is displayed on lcd continuously.port pin P3.1 of the microcontroller is used to interface with the PC’s hyper terminal through RS-232 interface MAX232 IC is shown here by virtual terminal.. Transmit data pin (TXD) is specified at port pin P3.4. every time pulse goes low led at port pin P1.7 will blink.

how could i see output data on my PC?

those using window xp open the HyperTerminal program,go to

Start → Programs → Accessories → Communications → Hyper Terminal 

those who are working on window 7 and window can download extraputty or hypertrm.

steps of making new hyper-terminal connection

1)Type the desired name and click ‘ok.’ 

2)Select a COM port and click ‘ok.

3)Now select the baud rate as ‘9600,’ data bits as ‘8,’ parity as ‘none,’ stop bits as ‘1,’ flow control as ‘Xon/Xoff’ and click ‘ok'.

CODE 

the pulse being fed to controller is counted infinitely.for each high pulse at port P3.5. the variable count goes increase by one.The data is sent to the LCD in ASCII format for display hence 48 is added before sending to lcd and virtual terminal.this is accomplished here by using function   convert(); maximum pulses would be counted are upto 999 after that it again starts counting from 000.

complete code

#include<reg51.h>
#define lcdport P2 
sbit rs=P3^2;
sbit rw=P3^6;
sbit en=P3^7;
sbit led=P1^7;
sbit pulse=P3^5;
int k,p;
unsigned int count=0;
unsigned int digit[5];
void lcdcmd(char);
void lcdint();
void lcddata(char);
void lcdstring(char *);
void delay(unsigned int);
unsigned char str1[]="PULSE COUNTER";
unsigned char str2[]="PULSE:000";
void uart_int();
void transmitstring(char *);
void transmit(unsigned char);
void convert(unsigned int);
void ldelay(unsigned int);
            
void main()
{
uart_int();
lcdint();
led=0;
pulse=0;
lcdstring(str1);
transmitstring(str1);
transmitstring("\r");
delay(1000);
lcdcmd(0xC0);
lcdstring(str2);
transmitstring(str2);
transmitstring("\r");
delay(1000);
 while(1)
        {
lcdcmd(0xc6);
led=1;
ldelay(10);
if(pulse==1)
        {
        count=count+1;
        convert(count);    
        }
        }
        }
void convert(unsigned int value)
           {
led=0;      
  for(k=0;k<=2;k++)
        {
        digit[k]=value%10;
        value=value/10;
        }  
for(p=2;p>=0;p--)
        {
        lcddata(digit[p]+48);
        transmit(digit[p]+48);
        ldelay(1);
        }
transmit('\r');
ldelay(10);
        }        
void transmitstring(char *s)
            {
while(*s!='\0')
        {
        transmit(*s);
        delay(500);
        s++;
        }
        }   
void transmit(unsigned char x)
           {
                SBUF=x;
                while(TI==0);
                TI = 0;
           }     
void uart_int()
      {
       TMOD=0x20;
        TH1=0xFD;
        SCON=0x50;
        TR1=1;
      }            
void delay(unsigned int x)
           {
        unsigned int i;
        for(i=0;i<x;i++);
           }     
void lcdint()
          {
         lcdcmd(0x38);
         delay(500);
         lcdcmd(0x01);
         delay(500);
         lcdcmd(0x0c);
         delay(500);
         lcdcmd(0x80);
         delay(500);
         lcdcmd(0x0e);
         delay(500);
    }
void lcdcmd(char value)
       {
         lcdport = value;
         rw=0;
         rs=0;
         en=1;
         delay(500);
         en=0;
       }         
void lcdstring(char *p)
      {
         while(*p!='\0')
          {
            lcddata(*p);
            delay(2000);
            p++;
          }
      }  
void lcddata(char value)
           {
         lcdport=value;
         rs=1;
         rw=0;
         en=1; 
         delay(500);
         en=0;
       }
void ldelay(unsigned int x)
          {
           unsigned int i,j;
           for (i=0;i<=x;i++)
           for (j=0;j<=1275;j++);
          }

VIDEO

Category: 

tags: 

Share

Comments

What's the secret of obtaining this source without disecting the page source code?The select and mouse right click menu seems to be disabled.
Select & Copy does work in FireFox, just not in Chrome...

Thanks Antwan, Issue has been resolved.

Who's new

  • ravirajpatil871...
  • shubhambajoria
  • yassir
  • demiholyman890954
  • scottgillum51169040

Get Notified

 

Share

We are Social

Syndicate

Subscribe to Syndicate