قسم الميكروكنترولر والروبوت ودوائر الاتصال بالحاسب الالي قسم المتحكمات الـ microcontroller و المعالجات microprocessor و التحكم الرقمي بالكمبيوتر CNC والانظمة الآلية والروبوت Robots

أدوات الموضوع

الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,894
نشاط [ F.Abdelaziz ]
قوة السمعة:332
قديم 11-04-2013, 10:04 PM المشاركة 1   
افتراضي قياس درجة الحرارة الموجبة والسالبة باستخدام الحساس DS18B20 والميكروكونترولر PIC والمي Twitter FaceBook Google+




قياس درجة الحرارة الموجبة والسالبة باستخدام الحساس DS18B20 والميكروكونترولر PIC والميكروسى :
البرنامج :


كود:
/*
 * Project name:
     Digital Room Thermometer using PIC16F877
     Onewire_Test (Interfacing the DS18B20 temperature sensor )
  * Description:
     After reset, PIC reads temperature from the sensor and prints it on the Lcd.
     The display format of the temperature is"000.0°C "  . 
, the 18B20 temperature resolution is 12-bit (default) ( 0.065 °C . step) 
* Test configuration:
     MCU:             PIC16F877A
     Oscillator:      HS, 08.0000 MHz
LCD 2x16 
     SW:              mikroC PRO for PIC
*/ 

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
// Define Messages
char message0[] = "LCD Initialized";   // string constant
char message1[] = "Room Temperature";  //string constant
// String array to store temperature value to display
char *tempC = "000.0"; // pointer to string 
// Variables to store temperature register values
unsigned int temp_whole, temp_fraction, temp_value;  // 2-byte => 0 .. 65535
signed int tempinC;     // 2-byte => -32768 .. 32767
unsigned short C_Neg=0, TempH, TempL;   // 1-byte => 0 .. 255

void Display_Temperature() {
    // check if temperature is negative
    if (temp_value & 0x8000) {
      C_Neg = 1;
      tempC[0] = '-';
      // Negative temp values are stored in 2's complement form
      temp_value = ~temp_value + 1;
      }
    else C_Neg = 0;
    // Get temp_whole
    temp_whole = temp_value >> 4 ;   // 12 bit >>4 (fraction)  => 8bit whole
    if (temp_value & 0x0001){     // LSB is 0.0625C
       temp_fraction = 5;
       }
    else temp_fraction = 0;
    tempinC = temp_whole*10+temp_fraction;
  
// convert Temp to characters
 if (!C_Neg) {
     if (tempinC/1000)
   // 48 is the decimal character code value for displaying 0 on LCD
     tempC[0] = tempinC/1000  + 48;
     else tempC[0] = ' '; // space 
  }
  tempC[1] = (tempinC/100)%10 + 48;             // Extract tens digit
  tempC[2] =  (tempinC/10)%10 + 48;             // Extract ones digit
  // convert temp_fraction to characters
  tempC[4] =  tempinC%10  + 48;         // Extract tens digit
  // print temperature on LCD
  Lcd_Out(2, 6, tempC);
}

void main() {
  ADCON1 = 0xFF;                                      // Configure AN pins as digital I/O
  Lcd_Init();                           // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);                 // CLEAR display
  Lcd_Cmd(_LCD_CURSOR_OFF);            // Cursor off
  Lcd_Out(1,1,message0);
  Delay_ms(1000);
  Lcd_Out(1,1,message1);                // Write message1 in 1st row
  // Print degree character "°C"
  Lcd_Chr(2,11,223);
 // different LCD displays have different char code for degree
 // if you see greek alpha letter try typing 178 instead of 223
  Lcd_Chr(2,12,'C');
  
    do {
  //--- perform temperature reading 
    Ow_Reset(&PORTA, 5);         // Onewire reset signal
    Ow_Write(&PORTA, 5, 0xCC);     // Issue command SKIP_ROM
    Ow_Write(&PORTA, 5, 0x44);     // Issue command CONVERT_T
    Delay_ms(600);
    Ow_Reset(&PORTA, 5);
    Ow_Write(&PORTA, 5, 0xCC);      // Issue command SKIP_ROM
    Ow_Write(&PORTA, 5, 0xBE);      // Issue command READ_SCRATCHPAD

    // Read Byte 0 from Scratchpad
    TempL =  Ow_Read(&PORTA, 5); // Read => low byte of 2-byte temperature register 
    // Then read Byte 1 from Scratchpad
    TempH = Ow_Read(&PORTA, 5); // Read => high byte of 2-byte temperature register 
    temp_value = (TempH << 8)+ TempL ; // forming 2-byte value 
//--- Format and display result on Lcd
    Display_Temperature();
  } while(1);
}
    




النتائج :






اعلانات

الطالب99
:: مهندس متواجد ::
تاريخ التسجيل: Oct 2005
المشاركات: 73
نشاط [ الطالب99 ]
قوة السمعة:0
قديم 12-04-2013, 01:16 PM المشاركة 2   
افتراضي


السلام عليكم ورحمة الله وبركاته
اسال الله ان يرزقك الجنه اخي الكريم
ولو سمحت عندي سوال واحد هل لي ان اربط حساسين على هذا الدائرة ؟؟؟؟
وكيف ؟؟؟؟
وجزاك الله خير .....

اعلانات اضافية ( قم بتسجيل الدخول لاخفائها )
  

الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,894
نشاط [ F.Abdelaziz ]
قوة السمعة:332
قديم 12-04-2013, 10:50 PM المشاركة 3   
افتراضي


السلام عليكم ورحمة الله وبركاته
اسال الله ان يرزقك الجنه اخي الكريم
ولو سمحت عندي سوال واحد هل لي ان اربط حساسين على هذا الدائرة ؟؟؟؟
وكيف ؟؟؟؟
وجزاك الله خير .....


أخى الكريم

شكرا جزيلا لك

نعن يمكن ربط حساسين على هذه الدائرة بطريقة تقليدية عن طريق استخدام خط لمدخل آخر مع استخدام النسح واللصق كما يلى :

البرنامج :

كود:
/*
 * Project name:
     Digital Room Thermometer using PIC16F628
     Onewire_Test (Interfacing the DS18B20 temperature sensor )
  * Description:
     After reset, PIC reads temperature from the sensor and prints it on the Lcd.
     The display format of the temperature is"000.0°C "  .
, the 18B20 temperature resolution is 12-bit (default) ( 0.065 °C . step)
* Test configuration:
     MCU:             PIC16F628
     Oscillator:      4.0000 MHz
LCD 2x16
     SW:              mikroC PRO for PIC
*/

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
// Define Messages
char message0[] = "LCD Initialized";   // string constant
char message1[] = "Temp1=";  //string constant
char message2[] = "Temp2=";  //string constant
// String array to store temperature value to display
char *tempC = "000.0"; // pointer to string
// Variables to store temperature register values
unsigned int temp_whole, temp_fraction, temp_value;  // 2-byte => 0 .. 65535
signed int tempinC;     // 2-byte => -32768 .. 32767
unsigned short C_Neg=0, TempH, TempL;   // 1-byte => 0 .. 255

void Display_Temperature1() {
    // check if temperature is negative
    if (temp_value & 0x8000) {
      C_Neg = 1;
      tempC[0] = '-';
      // Negative temp values are stored in 2's complement form
      temp_value = ~temp_value + 1;
      }
    else C_Neg = 0;
    // Get temp_whole
    temp_whole = temp_value >> 4 ; // 12 bit >>4 (fraction)  => 8bit whole

    if (temp_value & 0x0001){  // LSB is 0.0625C
       temp_fraction = 5;
       }
    else temp_fraction = 0;
    tempinC = temp_whole*10+temp_fraction;
  // convert Temp to characters
 if (!C_Neg) {
     if (tempinC/1000)
   // 48 is the decimal character code value for displaying 0 on LCD
     tempC[0] = tempinC/1000  + 48;
     else tempC[0] = ' '; // space
  }
  tempC[1] = (tempinC/100)%10 + 48;             // Extract tens digit
  tempC[2] =  (tempinC/10)%10 + 48;             // Extract ones digit
  // convert temp_fraction to characters
  tempC[4] =  tempinC%10  + 48;         // Extract tens digit
  // print temperature on LCD
  Lcd_Out(1, 7, tempC);
}
void Display_Temperature2() {
    // check if temperature is negative
    if (temp_value & 0x8000) {
      C_Neg = 1;
      tempC[0] = '-';
      // Negative temp values are stored in 2's complement form
      temp_value = ~temp_value + 1;
      }
    else C_Neg = 0;
    // Get temp_whole
    temp_whole = temp_value >> 4 ; // 12 bit >>4 (fraction)  => 8bit whole

    if (temp_value & 0x0001){  // LSB is 0.0625C
       temp_fraction = 5;
       }
    else temp_fraction = 0;
    tempinC = temp_whole*10+temp_fraction;
  // convert Temp to characters
 if (!C_Neg) {
     if (tempinC/1000)
   // 48 is the decimal character code value for displaying 0 on LCD
     tempC[0] = tempinC/1000  + 48;
     else tempC[0] = ' '; // space
  }
  tempC[1] = (tempinC/100)%10 + 48;             // Extract tens digit
  tempC[2] =  (tempinC/10)%10 + 48;             // Extract ones digit
  // convert temp_fraction to characters
  tempC[4] =  tempinC%10  + 48;         // Extract tens digit
  // print temperature on LCD
  Lcd_Out(2, 7, tempC);
}

void main() {
CMCON |= 7;                          // Set AN pins to Digital I/O;
  
  Lcd_Init();                           // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);                 // CLEAR display
  Lcd_Cmd(_LCD_CURSOR_OFF);            // Cursor off
  Lcd_Out(1,1,message0);
  Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                 // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF);            // Cursor off
  Lcd_Out(1,1,message1);                // Write message1 in 1st row
Lcd_Out(2,1,message2);                // Write message2 in 2nd row
  // Print degree character "°C"
  Lcd_Chr(1,11,223);
Lcd_Chr(2,11,223);
 // different LCD displays have different char code for degree
 // if you see greek alpha letter try typing 178 instead of 223
  Lcd_Chr(1,12,'C');
Lcd_Chr(2,12,'C');

    do {
  //--- perform temperature reading
    Ow_Reset(&PORTA, 0);         // Onewire reset signal
    Ow_Write(&PORTA, 0, 0xCC);     // Issue command SKIP_ROM
    Ow_Write(&PORTA, 0, 0x44);     // Issue command CONVERT_T
    Delay_ms(600);
    Ow_Reset(&PORTA, 0);
    Ow_Write(&PORTA, 0, 0xCC);      // Issue command SKIP_ROM
    Ow_Write(&PORTA, 0, 0xBE);      // Issue command READ_SCRATCHPAD

    // Read Byte 0 from Scratchpad
    TempL =  Ow_Read(&PORTA, 0); // Read => low byte of 2-byte temperature register
    // Then read Byte 1 from Scratchpad
    TempH = Ow_Read(&PORTA, 0); // Read => high byte of 2-byte temperature register
    temp_value = (TempH<< 8)+ TempL ; // forming 2-byte value
//--- Format and display result on Lcd
    Display_Temperature1();

 Ow_Reset(&PORTA, 1);         // Onewire reset signal
    Ow_Write(&PORTA, 1, 0xCC);     // Issue command SKIP_ROM
    Ow_Write(&PORTA, 1, 0x44);     // Issue command CONVERT_T
    Delay_ms(600);
    Ow_Reset(&PORTA, 1);
    Ow_Write(&PORTA, 1, 0xCC);      // Issue command SKIP_ROM
    Ow_Write(&PORTA, 1, 0xBE);      // Issue command READ_SCRATCHPAD

    // Read Byte 0 from Scratchpad
    TempL =  Ow_Read(&PORTA, 1); // Read => low byte of 2-byte temperature register
    // Then read Byte 1 from Scratchpad
    TempH = Ow_Read(&PORTA, 1); // Read => high byte of 2-byte temperature register
    temp_value = (TempH << 8)+ TempL ; // forming 2-byte value
//--- Format and display result on Lcd
    Display_Temperature2();

  } while(1);
}


النتائج :



لكن عمليا يمكن توصيل عدة حساسات على خط واحد One Wire باعتبار أن الميكروكونترولر هو الجهاز الرئيسى (الماستر) والحساسات توابع مع تعيين عنوان لكل حساس وهذا ما سوف نتناوله بالتفصيل إن شاء الله .

مع تمنياتى بدوام التوفيق


الصورة الرمزية Abdw9
Abdw9
:: عضو فضي ::
تاريخ التسجيل: Nov 2011
الدولة: السودان
المشاركات: 557
نشاط [ Abdw9 ]
قوة السمعة:77
قديم 13-04-2013, 05:49 AM المشاركة 4   
افتراضي



قياس درجة الحرارة الموجبة والسالبة باستخدام الحساس DS18B20 والميكروكونترولر PIC والميكروسى :
البرنامج :


كود:
/*
 * Project name:
     Digital Room Thermometer using PIC16F877
     Onewire_Test (Interfacing the DS18B20 temperature sensor )
  * Description:
     After reset, PIC reads temperature from the sensor and prints it on the Lcd.
     The display format of the temperature is"000.0°C "  . 
, the 18B20 temperature resolution is 12-bit (default) ( 0.065 °C . step) 
* Test configuration:
     MCU:             PIC16F877A
     Oscillator:      HS, 08.0000 MHz
LCD 2x16 
     SW:              mikroC PRO for PIC
*/ 

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
// Define Messages
char message0[] = "LCD Initialized";   // string constant
char message1[] = "Room Temperature";  //string constant
// String array to store temperature value to display
char *tempC = "000.0"; // pointer to string 
// Variables to store temperature register values
unsigned int temp_whole, temp_fraction, temp_value;  // 2-byte => 0 .. 65535
signed int tempinC;     // 2-byte => -32768 .. 32767
unsigned short C_Neg=0, TempH, TempL;   // 1-byte => 0 .. 255

void Display_Temperature() {
    // check if temperature is negative
    if (temp_value & 0x8000) {
      C_Neg = 1;
      tempC[0] = '-';
      // Negative temp values are stored in 2's complement form
      temp_value = ~temp_value + 1;
      }
    else C_Neg = 0;
    // Get temp_whole
    temp_whole = temp_value >> 4 ;   // 12 bit >>4 (fraction)  => 8bit whole
    if (temp_value & 0x0001){     // LSB is 0.0625C
       temp_fraction = 5;
       }
    else temp_fraction = 0;
    tempinC = temp_whole*10+temp_fraction;
  
// convert Temp to characters
 if (!C_Neg) {
     if (tempinC/1000)
   // 48 is the decimal character code value for displaying 0 on LCD
     tempC[0] = tempinC/1000  + 48;
     else tempC[0] = ' '; // space 
  }
  tempC[1] = (tempinC/100)%10 + 48;             // Extract tens digit
  tempC[2] =  (tempinC/10)%10 + 48;             // Extract ones digit
  // convert temp_fraction to characters
  tempC[4] =  tempinC%10  + 48;         // Extract tens digit
  // print temperature on LCD
  Lcd_Out(2, 6, tempC);
}

void main() {
  ADCON1 = 0xFF;                                      // Configure AN pins as digital I/O
  Lcd_Init();                           // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);                 // CLEAR display
  Lcd_Cmd(_LCD_CURSOR_OFF);            // Cursor off
  Lcd_Out(1,1,message0);
  Delay_ms(1000);
  Lcd_Out(1,1,message1);                // Write message1 in 1st row
  // Print degree character "°C"
  Lcd_Chr(2,11,223);
 // different LCD displays have different char code for degree
 // if you see greek alpha letter try typing 178 instead of 223
  Lcd_Chr(2,12,'C');
  
    do {
  //--- perform temperature reading 
    Ow_Reset(&PORTA, 5);         // Onewire reset signal
    Ow_Write(&PORTA, 5, 0xCC);     // Issue command SKIP_ROM
    Ow_Write(&PORTA, 5, 0x44);     // Issue command CONVERT_T
    Delay_ms(600);
    Ow_Reset(&PORTA, 5);
    Ow_Write(&PORTA, 5, 0xCC);      // Issue command SKIP_ROM
    Ow_Write(&PORTA, 5, 0xBE);      // Issue command READ_SCRATCHPAD

    // Read Byte 0 from Scratchpad
    TempL =  Ow_Read(&PORTA, 5); // Read => low byte of 2-byte temperature register 
    // Then read Byte 1 from Scratchpad
    TempH = Ow_Read(&PORTA, 5); // Read => high byte of 2-byte temperature register 
    temp_value = (TempH << 8)+ TempL ; // forming 2-byte value 
//--- Format and display result on Lcd
    Display_Temperature();
  } while(1);
}
    




النتائج :






شكرا لك استاذ فتح الله
لدي سؤال لو سمحت
وبعد البرنامج والدائرة التي اعجبتني ما ميزة هذه الحساس عن LM35 وهل هو متوفر
شكرا لك


التعديل الأخير تم بواسطة : Abdw9 بتاريخ 13-04-2013 الساعة 05:53 AM

الطالب99
:: مهندس متواجد ::
تاريخ التسجيل: Oct 2005
المشاركات: 73
نشاط [ الطالب99 ]
قوة السمعة:0
قديم 13-04-2013, 10:30 AM المشاركة 5   
افتراضي



أخى الكريم

شكرا جزيلا لك

نعن يمكن ربط حساسين على هذه الدائرة بطريقة تقليدية عن طريق استخدام خط لمدخل آخر مع استخدام النسح واللصق كما يلى :

البرنامج :

كود:
/*
 * Project name:
     Digital Room Thermometer using PIC16F628
     Onewire_Test (Interfacing the DS18B20 temperature sensor )
  * Description:
     After reset, PIC reads temperature from the sensor and prints it on the Lcd.
     The display format of the temperature is"000.0°C "  .
, the 18B20 temperature resolution is 12-bit (default) ( 0.065 °C . step)
* Test configuration:
     MCU:             PIC16F628
     Oscillator:      4.0000 MHz
LCD 2x16
     SW:              mikroC PRO for PIC
*/

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
// Define Messages
char message0[] = "LCD Initialized";   // string constant
char message1[] = "Temp1=";  //string constant
char message2[] = "Temp2=";  //string constant
// String array to store temperature value to display
char *tempC = "000.0"; // pointer to string
// Variables to store temperature register values
unsigned int temp_whole, temp_fraction, temp_value;  // 2-byte => 0 .. 65535
signed int tempinC;     // 2-byte => -32768 .. 32767
unsigned short C_Neg=0, TempH, TempL;   // 1-byte => 0 .. 255

void Display_Temperature1() {
    // check if temperature is negative
    if (temp_value & 0x8000) {
      C_Neg = 1;
      tempC[0] = '-';
      // Negative temp values are stored in 2's complement form
      temp_value = ~temp_value + 1;
      }
    else C_Neg = 0;
    // Get temp_whole
    temp_whole = temp_value >> 4 ; // 12 bit >>4 (fraction)  => 8bit whole

    if (temp_value & 0x0001){  // LSB is 0.0625C
       temp_fraction = 5;
       }
    else temp_fraction = 0;
    tempinC = temp_whole*10+temp_fraction;
  // convert Temp to characters
 if (!C_Neg) {
     if (tempinC/1000)
   // 48 is the decimal character code value for displaying 0 on LCD
     tempC[0] = tempinC/1000  + 48;
     else tempC[0] = ' '; // space
  }
  tempC[1] = (tempinC/100)%10 + 48;             // Extract tens digit
  tempC[2] =  (tempinC/10)%10 + 48;             // Extract ones digit
  // convert temp_fraction to characters
  tempC[4] =  tempinC%10  + 48;         // Extract tens digit
  // print temperature on LCD
  Lcd_Out(1, 7, tempC);
}
void Display_Temperature2() {
    // check if temperature is negative
    if (temp_value & 0x8000) {
      C_Neg = 1;
      tempC[0] = '-';
      // Negative temp values are stored in 2's complement form
      temp_value = ~temp_value + 1;
      }
    else C_Neg = 0;
    // Get temp_whole
    temp_whole = temp_value >> 4 ; // 12 bit >>4 (fraction)  => 8bit whole

    if (temp_value & 0x0001){  // LSB is 0.0625C
       temp_fraction = 5;
       }
    else temp_fraction = 0;
    tempinC = temp_whole*10+temp_fraction;
  // convert Temp to characters
 if (!C_Neg) {
     if (tempinC/1000)
   // 48 is the decimal character code value for displaying 0 on LCD
     tempC[0] = tempinC/1000  + 48;
     else tempC[0] = ' '; // space
  }
  tempC[1] = (tempinC/100)%10 + 48;             // Extract tens digit
  tempC[2] =  (tempinC/10)%10 + 48;             // Extract ones digit
  // convert temp_fraction to characters
  tempC[4] =  tempinC%10  + 48;         // Extract tens digit
  // print temperature on LCD
  Lcd_Out(2, 7, tempC);
}

void main() {
CMCON |= 7;                          // Set AN pins to Digital I/O;
  
  Lcd_Init();                           // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);                 // CLEAR display
  Lcd_Cmd(_LCD_CURSOR_OFF);            // Cursor off
  Lcd_Out(1,1,message0);
  Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                 // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF);            // Cursor off
  Lcd_Out(1,1,message1);                // Write message1 in 1st row
Lcd_Out(2,1,message2);                // Write message2 in 2nd row
  // Print degree character "°C"
  Lcd_Chr(1,11,223);
Lcd_Chr(2,11,223);
 // different LCD displays have different char code for degree
 // if you see greek alpha letter try typing 178 instead of 223
  Lcd_Chr(1,12,'C');
Lcd_Chr(2,12,'C');

    do {
  //--- perform temperature reading
    Ow_Reset(&PORTA, 0);         // Onewire reset signal
    Ow_Write(&PORTA, 0, 0xCC);     // Issue command SKIP_ROM
    Ow_Write(&PORTA, 0, 0x44);     // Issue command CONVERT_T
    Delay_ms(600);
    Ow_Reset(&PORTA, 0);
    Ow_Write(&PORTA, 0, 0xCC);      // Issue command SKIP_ROM
    Ow_Write(&PORTA, 0, 0xBE);      // Issue command READ_SCRATCHPAD

    // Read Byte 0 from Scratchpad
    TempL =  Ow_Read(&PORTA, 0); // Read => low byte of 2-byte temperature register
    // Then read Byte 1 from Scratchpad
    TempH = Ow_Read(&PORTA, 0); // Read => high byte of 2-byte temperature register
    temp_value = (TempH<< 8)+ TempL ; // forming 2-byte value
//--- Format and display result on Lcd
    Display_Temperature1();

 Ow_Reset(&PORTA, 1);         // Onewire reset signal
    Ow_Write(&PORTA, 1, 0xCC);     // Issue command SKIP_ROM
    Ow_Write(&PORTA, 1, 0x44);     // Issue command CONVERT_T
    Delay_ms(600);
    Ow_Reset(&PORTA, 1);
    Ow_Write(&PORTA, 1, 0xCC);      // Issue command SKIP_ROM
    Ow_Write(&PORTA, 1, 0xBE);      // Issue command READ_SCRATCHPAD

    // Read Byte 0 from Scratchpad
    TempL =  Ow_Read(&PORTA, 1); // Read => low byte of 2-byte temperature register
    // Then read Byte 1 from Scratchpad
    TempH = Ow_Read(&PORTA, 1); // Read => high byte of 2-byte temperature register
    temp_value = (TempH << 8)+ TempL ; // forming 2-byte value
//--- Format and display result on Lcd
    Display_Temperature2();

  } while(1);
}


النتائج :



لكن عمليا يمكن توصيل عدة حساسات على خط واحد One Wire باعتبار أن الميكروكونترولر هو الجهاز الرئيسى (الماستر) والحساسات توابع مع تعيين عنوان لكل حساس وهذا ما سوف نتناوله بالتفصيل إن شاء الله .

مع تمنياتى بدوام التوفيق
وانا بنتظارك اخي الكريم واسال الله ان يسدد خطاك ويفتح عليك وعلينا من ابواب علمه
وجزاك الله خير .....


Tchoo
:: مهندس متواجد ::
تاريخ التسجيل: Jun 2010
الدولة: Algeria
المشاركات: 63
نشاط [ Tchoo ]
قوة السمعة:0
قديم 25-04-2013, 05:24 PM المشاركة 6   
افتراضي


هل يصل مقياس الحرارة الى 400 درجة ؟؟
اذا لاا فهل يمكنك ان تزودني بدارة تسمح بذالك

إضافة رد

العلامات المرجعية

«     الموضوع السابق       الموضوع التالي    »
أدوات الموضوع

الانتقال السريع إلى


الساعة معتمدة بتوقيت جرينتش +3 الساعة الآن: 08:34 AM
موقع القرية الالكترونية غير مسؤول عن أي اتفاق تجاري أو تعاوني بين الأعضاء
فعلى كل شخص تحمل مسئولية نفسه إتجاه مايقوم به من بيع وشراء وإتفاق وأعطاء معلومات موقعه
التعليقات المنشورة لا تعبر عن رأي موقع القرية الالكترونية ولايتحمل الموقع أي مسؤولية قانونية حيال ذلك (ويتحمل كاتبها مسؤولية النشر)

Powered by vBulletin® Version 3.8.6, Copyright ©2000 - 2025