Saturday, November 10, 2018

LM35 interfacing with PIC16F877A

পারদ থার্মোমিটার এর দিন প্রায় শেষ, আর সেই জায়গা টি দখল করে নিচ্ছে ডিজিটাল থার্মোমিটার । বাজারে বিভিন্ন রকমের ডিজিটাল থার্মোমিটার পাওয়া যায়। কিন্তু নিজের বানানো থার্মোমিটার ড্রয়িঙের দেয়ালে ঝুলবে এর অনুভূতিটায় একটু আলাদা এমন চিন্তা থেকেই আজকের এই পোস্ট।
যা লাগবেঃ
১. মাইক্রকন্ট্রলার(PIC16F877A)
২. ডিসপ্লে(2x16)
৩. টেমপারেচার সেন্সর(LM35)
৪. ক্রিস্টাল(8MHz)
৫. ভেরিয়েবল রেসিস্টর

The MikroC code:
............................................................... ...........................................................................................
//pic46f877a
// temperature sensor LM35
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
void main()
{
  float reading;
  int temp;
  char dis[15];
  trisa.f0 = 1;
  ADC_Init();
  Lcd_Init();                                          // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  Lcd_Out(1,1," ..TEMPERATURE...");     // Write text in first row first column
  ADCON0 = 0b10000000;
while(1)
{
      reading = ADC_Read(0);               // at (0 to 5V).....>> (0 to 1025)
      temp = (reading/205)*100;           // reading converting to temperature
      IntToStr(temp,dis);                        //We can get text representation of numerical value
      Lcd_Out(2,3,dis);
      Lcd_Out_Cp(" C");
}
}
.................................................................................................................................................................

MikroC এবং Proteus file ডাউনলোড করে তাত্ক্ষণিক এই প্রজেক্টটি বানিয়ে ফেলার জন্যে নিচে লিঙ্ক দেওয়া হলো।
Source code for MikroC, Proteus file

No comments:

Post a Comment