16 Bit Event Counter & Displaying on LCD

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




What is a Timer ? 

A Timer is device it sense the time interval and produce an output at a set value . example alarm Timer setting.(Timer in Wikipedia )

,What is the need of a timer in Micro controller ?
1) Some time  micro controller Code need some accurate  Delay  ( Example blinking An LED in each      accurate 1 sec. Look LED Blinking example

2)Some Time the code needs the code Repeat

3) Most of the Interfacing devices with micro-controller needs a clock (accurate interval of clocks)
   Example:   LCD module require Clock  Signal Look LCD Interfacing

Timer in 8051

Also a Timer actually require a clock pulse  (pling) .These pulse are given from controller  (actually it is in software based not giving ) see below picture
8051 type controller has  two Timer Timer 0 and Timer 1 (These two timer is the length of 16 bit ,0000 to  FFFF ).These Timer is named as TR0 and TR1. 

The Timer Setting/configuring  can controlling by the TMOD register 

These TMOD register Values is used to decide how the Timer Works .
Sample program

download the fullcode and Test

Rotation Counter using 8051


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 : 


Download the Full Project  CODE and with Proteus  Here

Switch Bounce Tutorials


Switch Bounce

Microcontrolers may not in Human thinking frequency .Human thinking frequency is lies in some of low Hz .  Microcontroler works variety range of frequency ie ,12Mhz,20 Mhz etc .  In a push Button  micro controller interfacing, Human and Micro controller are feels that whether the push is pressed or not  in different way as follows in the graph .

Some small duration pulse due to denounce generated as multiple touch error
Hardware solution
It can be made by a resistor and a capacitor in the following manner or any other for comfortable

When ever the switch is pressed the capacitor will charge  rapidly ,practically the first charge wil be across  the  ,capacitor ,

So we can avoid the denouncing effect .

The capacitor and the resistor will be select in accordance with time constant . as follows

For more information go here

Will be update 


Working of  74HC138 IC

               74HC138 is a decoder of the type octal 3- to- 8 Line Decoder / Demulator and Inverter.
The chip enables 3 pins - A, B and C - to output 8-bit , meaning that decodes three address lines in 8 possible ways . Simple, with 3 input bits to form 8 Address : 2 3 = 8; See the truth table:

An address decoder is also called a " demultiplexer " or " demux " . Although these terms are more generic and can refer to devices other than decoders addresses, TTL 74138 mentioned here can be called " demux 3- to -8" .
Decoders addresses are fundamental building blocks for systems using bus bars. They are represented in all families of integrated circuits and all the standard libraries FPGA and ASIC . They are discussed in introductory texts in digital logic design

Making multiple input by 3 wire Interfacing

Parallel to serial  Interfacing with Micro controller 

Interfacing with 74HC165 with 8051

   I am trying to make multiple input with using minimum input port of micro controller ,ie 3 wire .
By using a 3 wire we can interface more input as we wish.

 I am making a tutorial for it , Basics of 74HC165  which is a parallel to serial shift register .


Only three pin is connected with this IC . 
1)   SH/LD  or PL  is used load  parallel data to the IC .A low pulse (ground) is applied for store the         parallel data at the pin from A to H . And a High (5 Volt) is applied to stop the reading from the          PIN A to H .
2) Then to read the loaded or saved data to Micro controller we have to give clock to the PIN 2 of           74HC165  (CLK) . 8 pulses is applied to read 8 bit (Pin A to B)

3) QH / SO . serial out pin is used to get the stored parallel data to serially.

The CLK INH pin must be connect in ground for enable clock.

    To use cascaded 74HC165 for increasing i/p .connect the Seriall output pin (PIN 9) of first satge into serial input of first stage see the following circuit.

see the code below

#include "lcd.h"  
sbit PL  = P1^0;   // Loading parallel data to HC165.
sbit CLK = P1^1;   // Clock pulse to HC165.
sbit Beep  = P1^2;   // 
sbit data_in  = P1^3;

  void clock(void);
  void display(unsigned char value);
void main()
 unsigned char position ,no_of_ip = 17;
  string("   gElectron");     

      PL = 0 ;
  PL = 1;

   for(position = 1; no_of_ip > position; position++ , clock())
    if(data_in == 1)


 void clock(void)
   CLK = 1;
   CLK = 0;


void display(unsigned int value)
  unsigned int a[1];
    Beep =   1;
    string("Pressed key ");
     Beep = 0;

Download the whle file here github.

Google Photo Backup


        Google lunched a New application called Google photos   where we can add our lime time photos with each album with geo tagging location . google app automatically upload the photos and with our location . So we can see the photos including the location where was the photo taken .
The great advantage is that who is suffering with low memory mobile ,but they need to upload their photos accordingly , use the Google photo application sync with it. After syncing the photos we can delete the photos from the mobile .It delete only from the mobile and available on the net ever .

* It can easily share on social network
* It can be see Monthly view ,day view and more

 A geotaging location shown in the album cover . The photos automatically created while travelling.and tagged with the location


More Posts

gElectron. Powered by Blogger.