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 .
To develop a RPM meter using microcontroller & to display the speed on LCD Display PIC Microcontroller 16F877.
- Pulses from speed sensor connected to TMR1 clock input-RC2
- 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.
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
Figure4: Functional Flow Chart for RPM Meter
CLRF TMR1H ; Clear Timer1 High byte
CLRF TMR1L ; Clear Timer1 Low byte
CLRF INTCON ; Disable interrupts and clear T0IF
BSF STATUS, RP0 ; Bank1
BSF TRISC, 2 ; Make CCP pin input
CLRF PIE1 ; Disable peripheral interrupts
BCF STATUS, RP0; Bank0
CLRF PIR1 ; Clear peripheral interrupts Flags
MOVLW 07 ; Capture mode, every 4th rising edge
BSF STATUS, RP0
BSF PIE1, CCP1IE
BCF STATUS, RP0
MOVWF T1CON ; Timer1 starts to increment 1:8 PRESCALAR MODE
; The CCP1 interrupt is disabled,
; do polling on the CCP Interrupt flag bit
BCF T1CON, TMR1ON; off the timer after capturing the 4th pulse
BCF PIR1, CCP1IF ; This need to be done before next compare
MOVF CCPR1L, 0
MOVF CCPR1H, 0
BCF STATUS, C ; for performing right shift
RRF HEX2 ; dividing the period by 2 i,e right shift
CALL DIVIDE ; converting the period into frequency i,e RPS=Fclk / (capture period)
For more detail: PIC 16f877 microcontroller based RPM Meter