Pages

PIC 16f877 microcontroller based RPM Meter

Summary: The speed of the motor is measured in Rotations per Minutes,RPM.The RPM Meter is to read the running speed of Motor like DC MOTOR. Here the speed of the DC Motor is sensed with the help of a speed sensor and it is signal conditioned to have pulses which given as Timer1 clock input of PIC Microcontroller, configured to accept external clock input.The count value in Timer1 for one second represents speed in seconds which can be converted into RPM by multiplying the count by 60.The Display of the speed will be on Lyquid Crystal Display LCD .

AIM :

To develop a RPM meter using microcontroller & to display the speed on LCD Display PIC Microcontroller 16F877.

INTERFACING:

  1. Pulses from speed sensor connected to TMR1 clock input-RC2
  2. Run/Hold push button switch connected to –RC4
LCD Display –
  • Data lines connected to Port C - RC0: RC7
  • Control lines connected to Port D - RD0: RD2
  • Timer0 used for generating time slice of 1/16 sec in interrupt driven mode
NOTE: DC motor, DC motor driver circuit, speed sensor, signal-condition circuit to be Provided.
schematic dgm

SCHEMATIC DIAGRAM:

Figure1: Schematic Block Diagram for RPM Meter
Figure 1:
A dog sitting on a bed

DESCRIPTION:

Pulses from the speed sensor, after signal conditioning, is connected to Timer 1 input.
RPM meter works in two modes viz RUN & HOLD. The mode toggles for every push of the mode selection push of the mode selection push button switch:
HOLD Mode: Previous value of the speed is displayed
RUN Mode: Speed is measured for every second
  • By default meter will be in HOLD mode with display ‘00’.
  • Mode of operation and the speed are displayed on LCD

FLOW CHART:

Flow Chart
Figure 2:
Figure 2 (flowchart_03.jpeg)
Figure4: Functional Flow Chart for RPM Meter
LIST P=16F877
#INCLUDE"P16F877.INC"
CBLOCK 20H
HEX1
HEX2
DEC1
DEC2
DEC3
DEC4
DEC5
DD1
DD2
DV1
DV2
Q2
Q1
TEMP
DISNO
DLOC1
DLOC2
ENDC
ORG 00H
GOTO MAIN
MAIN CLRF CCP1CON ; CCP Module is off
CLRF TMR1H ; Clear Timer1 High byte
CLRF TMR1L ; Clear Timer1 Low byte
CLRF CCPR1L
CLRF CCPR1H
CLRF INTCON ; Disable interrupts and clear T0IF
BSF STATUS, RP0 ; Bank1
BSF TRISC, 2 ; Make CCP pin input
CLRF TRISD
CLRF TRISE
CLRF PIE1 ; Disable peripheral interrupts
BCF STATUS, RP0; Bank0
CLRF PIR1 ; Clear peripheral interrupts Flags
MOVLW 07 ; Capture mode, every 4th rising edge
MOVWF CCP1CON
BSF STATUS, RP0
BSF PIE1, CCP1IE
BCF STATUS, RP0
MOVLW 21H
MOVWF T1CON ; Timer1 starts to increment 1:8 PRESCALAR MODE
; The CCP1 interrupt is disabled,
; do polling on the CCP Interrupt flag bit
Capture_Event
BCF T1CON, TMR1ON; off the timer after capturing the 4th pulse
BANKSEL TRISA
CLRF TRISC
BANKSEL PORTA
BCF PIR1, CCP1IF ; This need to be done before next compare
MOVF CCPR1L, 0
MOVWF HEX1
MOVF CCPR1H, 0
MOVWF HEX2
BCF STATUS, C ; for performing right shift
RRF HEX2 ; dividing the period by 2 i,e right shift
RRF HEX1;
CALL DIVIDE ; converting the period into frequency i,e RPS=Fclk / (capture period)
CALL HEXDEC
BSF STATUS, RP0
CLRF TRISC ; configuring the PORTC as output in the LCD subroutine
BCF STATUS , RP0
CALL LCD ;display part
CALL DISP
GOTO MAIN
DIVIDE
NOP
MOVLW 0F4H ; loading the Fclk/2 value to the dividend, MSB IS DD1
MOVWF DD1
MOVLW 24H
MOVWF DD2 ; DD2 is the LSB
MOVF HEX1, 0 ; loading the capture period value to the divisor
MOVWF DV2
MOVF HEX2, 0
MOVWF DV1
CLRF Q1
CLRF Q2
BACK MOVF DV2, 0
SUBWF DD2, 1
BNC GETN
MOVF DD1, 0
BZ GETQT
MOVF DV1, 0
SUBWF DD1, 0
BNC GETQT
DECF DD1
GETN MOVF DV1, 0
SUBWF DD1, 1
BNC GETQT
INCF Q2
MOVF Q2, 1
BZ NQ
GOTO BACK
NQ INCF Q1
GOTO BACK
GETQT MOVF DD2, 0
ADDWF DV2, 0
MOVWF DD2
MOVF Q2, 0
MOVWF HEX1
MOVF Q1, 0
MOVWF HEX2
RETURN
DELAY CLRF DLOC2
MOVLW 03CH
MOVWF DLOC2
D1 MOVLW 0FFH
MOVWF DLOC1
DECFSZ DLOC1, 1
GOTO $-1
DECFSZ DLOC2, 1
GOTO D1
RETURN
HEXDEC CLRF DEC1
CLRF DEC2
CLRF DEC3
CLRF DEC4
CLRF DEC5
P100 MOVLW 64H ; START OF HEX-DEC CONVERTION
SUBWF HEX1, 0
BNC DIG2
B100
MOVWF HEX1
INCF DEC3, 1
MOVLW 0AH
SUBWF DEC3, 0
BZ CO3
GOTO P100
DIG2
MOVF HEX2, 1
BZ P10
DECF HEX2, 1
GOTO B100
P10
MOVLW 0AH
SUBWF HEX1, 0
BNC P1
MOVWF HEX1
INCF DEC2, 1
GOTO P10
P1
MOVF HEX1, 0
MOVWF DEC1
RETURN
CO3 CLRF DEC3
INCF DEC4, 1
MOVLW 0AH
SUBWF DEC4, 0
BNZ P100
CLRF DEC4
INCF DEC5, 1
GOTO P100
TABLE ADDWF PCL, 1
RETLW 'S'
RETLW 'P'
RETLW '='
CODE1 MOVWF TEMP
CALL BUSY
BCF PORTD, 1
BCF PORTD, 0 ; for WRITE OPERATION, R/W=0.
; To write the code, RS=0.
MOVF TEMP, 0
BSF PORTD, 2
MOVWF PORTC
BCF PORTD, 2
RETURN
BUSY BSF STATUS, RP0
MOVLW 0FFH
MOVWF TRISC
BCF STATUS, RP0
MOVLW 06H
MOVWF PORTD ; for READ OPRATION, R/W=1
; To read the busy flag,RS=0
MOVF PORTC, 0
BCF PORTD, 2
ANDLW 80H
BTFSS STATUS, Z
GOTO BUSY
BCF PORTD, 1
BSF STATUS, RP0
CLRF TRISC
BCF STATUS, RP0
RETURN
DATA1 MOVWF TEMP
CALL BUSY
BCF PORTD, 1
BSF PORTD, 0
MOVF TEMP, 0
BSF PORTD, 2 ; FOR WRITE OPN R/W=1
MOVWF PORTC ; RS=1;
BCF PORTD, 2
RETURN
; --------------------------------------------LCD-------------
LCD CALL DELAY
MOVLW 38H ; 8 BIT DATA LENGTH AND NUMBER OF DISPLAY .
CALL CODE1
MOVLW 0FH ; CLEAR DISPLAY
CALL CODE1
MOVLW 06H ; DISPLAY ON CURSOR ON.
CALL CODE1
MOVLW 01H
CALL CODE1
RETURN
DISP CLRF DISNO
BACK1 MOVF DISNO, 0
CALL TABLE
CALL DATA1
INCF DISNO, 1
BTFSS DISNO, 1
GOTO BACK1
BTFSS DISNO, 0
GOTO BACK1
MOVF DEC5, 0
ADDLW 30H
CALL DATA1
MOVF DEC4, 0
ADDLW 30H
CALL DATA1
MOVF DEC3, 0
ADDLW 30H
CALL DATA1
MOVF DEC2, 0
ADDLW 30H
CALL DATA1
MOVF DEC1, 0
ADDLW 30H
CALL DATA1
MOVLW 0C0H
CALL CODE1
MOVLW 'R'
CALL DATA1
MOVLW 'P'
CALL DATA1
MOVLW 'S'
CALL DATA1
RETURN
NOP
GOTO MAIN
END
References:
  1. Microchip Mid Range Manual on PIC Microcontroller
  2. PIC Microcontrollers by Peatman. Pearson Edn

0 comments:

Post a Comment

Share your knowledge

Related Posts Plugin for WordPress, Blogger...

Popular Projects

program for Dual DAC 8051 Microcontroller Based DC Motor Control A Microcontroller Based Turbidity Meter A m -Controller Based Thermostat ASCII to BCD conversion in 8051 AT90LS8515 Digital Message Machine Audio Frequency Response Analyzer Audio Homing Robot Automated Juice Mixer Automated Pet Feeder Autonomous Car Autonomous Parallel Parking RC Car Autonomous Search Robot Autonomous Tank Autonomous Vehicle Contrast Following Rover Autonomous navigating robot BCD number to ASCII in 8051 Balance Bot Blind Bot Blood Pressure Monitor Bloodshed Dev-C++ 5 Compiler/IDE Breath Alcohol Tester Converters on TI MSP430 CrossStudio MSP430 IDE Design of a Real-Time Digital Guitar Tuner Digital Oscilloscope Digital Stethoscope Digital clock project using PIC16C54A microcontroller Digital thermometer ECG monitoring system GPS Data Logger with Wireless Trigger Handwriting Recognition Systm Home Security System Home energy managment IAR Embedded Workbench IDE INFRARED TRACKING SYSTEM IntelliBOT Laser Communications System Line following van MSP-EXP430FG4618 Development Tool and the eZ430 kits MSP430FG4618 device implement a Buzzer tone generator MSP430FG4618 device implement a Real Time Clock MSP430FG4618 device implement a voltage ramp generator MSP430FG4618 device present a message on the LCD Basic Microcontroller(8051) Lab Mivo- RFID based mobile payment system Multi-Zone Fire Alarm System PC based temperature control PIC 16f877 RPM Meter PIC16C54 dual dice electronic project circuit PIC16F84A digital thermometer microcontroller project PIC16F886 horn driver PWM motor contoller with MSP430 Program Block data transfer in 8051 Program to add two BCD numbers in 8051 Program to check whether a 4th bit of a byte is 1 Program to convert ASCII to hex in 8051 Program to count from 0-9 in 8051 Program to count number of 1's in a given data byte in 8051 Program to divide an 8 bit no by another 8 bit number in 8051 Program to find largest of n numbers in 8051 Program to find the LCM of two numbers in 8051 Program to find the square of an 8 bit number in 8051 Program to generate 50msec delay in 8051 Program to implement BCD counter to count from 0-99 in 8051 Program to implement BCD counter to count from 99-0 in 8051 Program to interchange two blocks of data in 8051 Program to multiply 16 bit number by 8 bit number in 8051 Program to search an element in an array in 8051 Program to sort an array of 10 elements in 8051 Programming the ez430 Proximity Security System RAMP wave in 8051 RC Car Controller RObo Dog Radio-controlled Truck Retina color tracker Robotic Arm Controller with GUI Robotic Car Traction Control Safety-sensor vehicle Security Entrance System Self-Powered Solar Data Logger Snake Arm Ultrasonic Positioning Control System Store FFh if 1 Super Train Controller TI MSP430 Microcontrollers Timers on the MSP430 TouchPad Drawing Board Ultra-Sonic Parking Assistant Ultrasonic Parking Controller Ultrasonic Range finder Voice Activated Alarm Clock Voice Recognition Robotic Car Voting Machine Weather Station Web-Monitored Thermostat Wireless Drawing Device Wireless Telemetry Wireless message Communicator Write a C program to display the code of the key pressed in 8051 Zigbee Wireless Relay Control and Power Monitoring System add two multibyte numbers in 8051 convert a decimal number to hex number in 8051 convert an 8bit Hex number to decimal number in 8051 convert hex number to ASCII number in 8051 eZ430-F2013 Development Tool use SD16_A ADC eZ430-RF2500 Development Tool use ADC10 else store 00 in the same location in 8051 find the GCF of two numbers in 8051 find the average of 10 numbers in 8051 generate Fibonacci series in 8051 metal detector project microcontroller using IAR Embedded Workbench program for Elevator Interface in 8051 program for Stepper motor interface in 8051 spectrum analyser square wave in 8051 triangle wave in 8051 voice recognition security system

Sites U missed

Hint

Open Pictures in new page by right click on it, if it is not shown full image.