You are on page 1of 17

1

INSTRUMENTATION AND MEASUREMENTS PROJECT REPORT

INSTRUCTOR

Table of contents
1. Rpm counter 4 2. Circuit description 5 3. Sensor. 7 4. signal Conditioning. 8 5. microcontroller 9 6. software 10 7. display unit 15 8. applications 16

Rpm counter:
Rpm stands for ROTATION PER MINUTE. This project is basically an instrument capable of measuring(counting) the rotation of any shaft during the period of one minute, so called rotation per minute counter.

Working Principle:
The principle used is that a disc fixed at a rotating shaft is used to produce interrupts with the help of IR sensor (infra-red sensor).These interrupts are actually pulses which act like a digital input. These pulses are fed to microcontroller after conditioning. These pulses are counted for a certain period of time.in our project we are counting pulses for 1 second. Then counted amount of pulses can be multiplied by 60 to get RPMs. mathematically

Rpm= (Number of counted pulses) 60

This gives the speed at which the shaft is rotating. Hence we can measure the speed of any rotating body.

Circuit description:
The basic circuit diagram is shown below. The sensor part is not shown here.

Block Diagram

Description:
There is circuit for driving the DC motor of which the RPMs are to be counted. This drives the motor, and an interrupt is given to the IR sensor. A pulse generated by IR sensor is then fed to RC2 pin of microcontroller unit(MCU) PIC16F877. Output is being observed at an LCD display unit which is connected to PORT C(through RC0 to RC7). A run/hold switch is also used. RUN: Speed is measured for every second.

HOLD: Previous value of the speed is displayed.

SENSOR
We are using infra-red sensor for detecting interrupts. The output of the sensor is pulse fed to microcontroller as explained above. The IR sensor pair contains of a transmitter and receiver LEDs as shown below

The infra-red rays emitting from transmitter are received by detector. If there is an interrupt, the voltage at output changes. Hence a pulse is produced to be fed to MCU.

SIGNAL CONDITIONING
The output from IR receiver is of low voltage. We are using a voltage regulator 7805 which gives an output of 5 volts which is appropriate as input signal to microcontroller unit.

Along with 7805,some capacitors and resistors are used for filtering purposes.

MICROCONTROLLER UNIT(MCU)
The back bone of this project is microcontroller. We used PIC16F877,a 40 pin MCU as shown below.

The input signal is fed to RC2 (pin 17). LCD is connected as DATA OUTPUT: RC0 to RC7

10

CONTROLS: RD0 to RD2 A run/hold switch is also connected at RC4. A 4MHz crystal is used as an external clock source, at pins OSC1 and OSC2.

SOFTWARE
FOLLOWING IS THE PROGRAM CODE USED TO COUNT PULSES AND HENCE MEASURE RPMs.

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

11 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

12 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 D1RETURN HEXDEC CLRF DEC1 CLRF DEC2 CLRF DEC 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, 0BZ CO3

13 GOTO P100 DIG2 MOVF HEX2, 1 BZ P10 DECF HEX2, 1GOTO 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

14 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, 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

15 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

DISPLAY UNIT:
A 162 LCD display is used for displaying rpms. The pin description is below

16

Applications
This is a digital rpm counter which can be used to measure speed of any rotating body. With proper assembly it can be used in vehicles to measure the speed of wheels.

17

It may also be used to measure speed of fans, motors etc. This instrument can be fitted in laboratory equipment to display speed of rotating machines. It is a contactless rpm counter so it is portable and can be applied easily ignoring space considerations.

You might also like