Header Ads

Make Rotation Counter use PIC Microcontroller and code

Welcome to MINA TECHNOLOGY.

In this tutorial we will learn how make rotation counter use PIC Microcontroller. Rotation counter count the rotation of motor and wheel. The IR sensor convert the rotation in pulse. Here I am use PIC16F877A Microcontroller and LM16x2 Lcd display. You can watch the video or read the written tutorial below.





In this project I am use IR sensor module. IR sensor module has two IR LED. IR signal transmitter and receiver. Transmitter LED transmit the IR signal and receiver LED receive the IR signal.


Circuit Diagram:
circuit schematic of rotation counter







Mikro C dode:

// Lcd module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
//end lcd module connections
#define IR PORTD.RD7      // RD7 pin is pulse input pin
#define SW1 PORTD.RD0
#define SW2 PORTD.RD1
int rotation=0;
int puase=0;
char text[15];
void main() {
     TRISD.F0 = 1;                     // RD0 pin is input
     Lcd_Init();                        // Initialize the Lcd module
     Lcd_Cmd(_LCD_CLEAR);                // Clear Lcd display
     Lcd_Cmd(_LCD_CURSOR_OFF);            // Lcd Cursor off
     Lcd_Out(1,1,"Rotation Counter");
     Lcd_Out(2,5,"Circuit");
     delay_ms(2000);                      // 2 second delay
     Lcd_Cmd(_LCD_CLEAR);
     Lcd_Out(1,3,"DEVELOPED BY");
     Lcd_Out(2,1,"MINA TECHNOLOGY");
     delay_ms(2000);
     Lcd_Cmd(_LCD_CLEAR);
     Lcd_Out(1,1,"Rotation:");



     while(1){
              if(IR==1){
                        while(IR==1);
                        rotation++;
                        }
              if(SW1==1){
                         while(SW1==1);
                         rotation = 0;
                         }
              if(SW2==1){
                         while(SW2==1);
                         puase++;
                         while(puase){
                                      if(SW2==1){
                                                 while(SW2==1);
                                                 puase=0;
                                                 }
                                      if(SW1==1){
                                                  rotation=0;
                                                  puase = 0;
                                                  }
                                      }
                         }
              if(rotation>=10000000) rotation  = 0;
              if(RD0_bit==1) rotation = 0;          // Reset the counter

              IntToStr(rotation,text);                // Lcd show the pulse
              Lcd_Out(2,1,text);
              }

}



Click the download button for source code:

download


1 comment:

  1. Make Rotation Counter use PIC Microcontroller and code. With relley in 12v motor cut automatic off.
    Plz, send diagram.

    ReplyDelete

Theme images by 5ugarless. Powered by Blogger.