MPMC Project K&N
MPMC Project K&N
MPMC Project K&N
MEASUREMENT
PROJECT BY KULDEEP SINGH(B220974EE)
AND NAVNEET (B220430EE)
ACKNOWLEDGEMENT
if(PORTB.F4==0){
T1CON.TMR1ON = 0; // Stop timer1
pulse = ((TMR1H<<8)|(TMR1L));
TMR1H = 0;
TMR1L = 0;
}
CODE CONTI…
}
INTCON.RBIE = 1; // Enable the port change interrupt
INTCON.RBIF = 0;
}
void main() {
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,3,"Time Period");
Lcd_Out(2,3,"Measurement");
delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,3,"Developed by");
Lcd_Out(2,1,"KULDEEP NAVNEET");
delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
INTCON.RBIE = 1;
TRISB = 0X10;
PORTB = 0X00;
INTCON.GIE = 1; // Enable global interrupt
CODE CONTI…
INTCON.RBIF = 0; // Clear the port change interrupt flag
INTCON.RBIE = 1; // Enable port change interrupt
TMR1CS_bit = 0;
T1SYNC_bit = 1;
T1CKPS0_bit = 1;
T1CKPS1_bit = 1;
TMR1ON_bit = 1;
TMR1H = 0;
TMR1L = 0;
while(1){
period = pulse / 125.0;
if(period<0){
//Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Out of Range");
Lcd_Out(2,1,"Min T.Pri 250ms");
}
CODE CONTI…
else if(period>0){
//Lcd_Cmd(_LCD_CLEAR);
floatToStr(period,text);
text[5] = 0 ;
Lcd_Out(1,1,"Time Period:");
Lcd_Out(2,6,"ms ");
Lcd_Out(2,1,text);
}
delay_ms(500);
}
}
…
CALCULATION
Oscilator Frequency = 8MHz
Internal clock Frequency = 8MHz / 4 = 2MHz
Prescaler value = 1:8
Timer1 value = (TMR1H : TMR1L) = (TMR1H<<8) | (TMR1L)
thence,
Timer Period of Pulse Generator signal = pulses / 125 ms
THE PROJECT
WORKING
• After loading the PIC with the code, connect it in the breadboard in
the exact position as it was connected before.
• Properly connect terminals of the battery to the IC regulator to get
the required voltage input to the circuit.
• Now vary the pulse using 10k potentiometer connected to the IC555
to get different time periods for different pulses.
• Observe the time periods on the LCD display.
PRECAUTOINS
• Verify the circuit connections with the diagram again.
• Check in another circuit if the LCD is working.
• If the LCD doesn’t glow on connecting the battery, try checking the
circuit again for loose connections.
• After loading the PIC, verify to check if code has been read.
• If it still doesn’t work, try using another PIC or another circuit for
pulse generator.
CONCLUSION
The program initializes an LCD display, measures the time
period of a signal using Timer1 and interrupts, and displays
the result on the LCD. It includes error handling for out-of-
range periods. This project showcases the use of interrupts,
timers, and LCD interfacing in a PIC microcontroller
application.
BIBLIOGRAPHY
• PIC Microcontroller by M. Ali Mazidi
• https://www.electronicsforu.com/technology-trends/learn-
electronics/16x2-lcd-pinout-diagram
• https://www.microchip.com/en-us/product/pic18f452