By
This black & white ring will we attached to the wheel by fixing it on spokes and sensor will face this ring for sensing rotation. The black portion of this ring will absorb the IR light while white portion while white portion will reflect it, hence two regions will we detected. In this way we will detect the rotation of wheel.
S.No
1 2 3 4 5 6 7 8 9
Item
NE555N C1 & C2 POT IR LED R1 R2 TSOP1738 Capacitor Resistor
Value
10 nf 4.7 k 470 22 4.7 f 100
Quantity
1 2 1 1 1 1 1 1 1
Working of Sensor
When IR light of above frequency falls on TSOP1738 then its output becomes low and when it is not receiving any light then its output is high. So this transmission cause change from high to low which is sensed by microcontroller by using interrupt.
S.No 1 2 3 4
Value 100 f
Quantity 1 2 4
Program
/***************************************************** This program was produced by the CodeWizardAVR V2.05.0 Professional Automatic Program Generator Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com
Project : Speedometer Version : 1.0 Date : 2/29/2012 Author : Nitish Kumar Company : IIST
Comments: The Fuse bits must be set as follows HIGH=D9 LOW=E1 The above fuse setting is for 1MHz 1.Sensor used is IR 2.Interrupt 0 is used to sense one rotation 3.Timer 1 is used for 1s time base 4.PORTB is connected to LCD
: ATmega32L : Application
AVR Core Clock frequency: 1.000000 MHz Memory model External RAM size Data Stack size : Small :0 : 512
*****************************************************/
int count=0; int rpm=0; int rps=0; int speed=0; int distance=0; int dis_count=0; # define M_PI 3.14159265358979323846
void lcd_int( int val,unsigned int field_length) { /*************************************************************** This function writes a integer type value to LCD module
2)unsigned int field_length : total length of field in which the value is printed must be between 1-5 if it is -1 the field length is no of digits in the val
****************************************************************/
// External Interrupt 0 service routine interrupt [EXT_INT0] void ext_int0_isr(void) { // Place your code here count++; }
interrupt [TIM1_COMPA] void timer1_compa_isr(void) { // Place your code here rps=count; rpm=rps*60; speed = (int)((M_PI*0.7366*rpm*60)/1000); dis_count=dis_count+count; if(dis_count>44) { distance=distance+1; dis_count=0; } count=0; }
// Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00; DDRA=0x00;
// Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00;
// Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0x00;
// Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0x00; DDRD=0x00;
// Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=0xFF
// Timer/Counter 1 initialization // Clock source: System Clock // Clock value: 0.977 kHz // Mode: CTC top=OCR1A // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: On // Compare B Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x0D; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x03; OCR1AL=0xD0;
OCR1BH=0x00; OCR1BL=0x00;
// Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer2 Stopped // Mode: Normal top=0xFF // OC2 output: Disconnected ASSR=0x00; TCCR2=0x00; TCNT2=0x00; OCR2=0x00;
// External Interrupt(s) initialization // INT0: On // INT0 Mode: Falling Edge // INT1: Off // INT2: Off GICR|=0x40; MCUCR=0x02; MCUCSR=0x00; GIFR=0x40;
// Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00;
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // RS - PORTB Bit 0 // RD - PORTB Bit 1 // EN - PORTB Bit 2 // D4 - PORTB Bit 4 // D5 - PORTB Bit 5 // D6 - PORTB Bit 6 // D7 - PORTB Bit 7 // Characters/line: 16 lcd_init(16);
lcd_gotoxy(3,0) ; lcd_putsf("Speedometer"); lcd_gotoxy(0,1); lcd_putsf("- by Nitish IIST") ; delay_ms(1000); lcd_clear(); lcd_gotoxy(3,0) ; lcd_putsf("Speedometer"); lcd_gotoxy(12,1); lcd_putsf("kmph"); lcd_gotoxy(5,1); lcd_putsf("mt");
while (1) { // Place your code here lcd_gotoxy(1,1); lcd_int(distance,4); lcd_gotoxy(9,1); lcd_int(speed,3); } }