 |
:: عضو فضي ::
تاريخ التسجيل: Nov 2011
الدولة: السودان
المشاركات: 557
|
|
نشاط [ Abdw9 ]
قوة السمعة:78
|
|
25-04-2012, 08:00 AM
المشاركة 4
|
|
مهمه للغاية حساس lm35
كود:
/*
Digital Thermometer using PIC16F877A and LM35
Oscillator * 4MHz, MCLR Enabled, PWRT Enabled, WDT OFF
Eng.F.Abdelaziz
http://www.eeecb.com/vb/index.php
*/
// LCD module connections
sbit LCD_RS at RD0_bit;
sbit LCD_EN at RD1_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
// Define Messages
char message0[] = "LCD Initialized";
char message1[] = "Room Temperature";
// String array to store temperature value to display
char *tempC = "000.0";
// Variables to store temperature values
unsigned int tempinC;
unsigned long temp_value;
void Display_Temperature( ) {
// convert Temp to characters
if (tempinC/10000)
// 48 is the decimal character code value for displaying 0 on LCD
tempC[0] = tempinC/10000 + 48;
else tempC[0] = ' ';
tempC[1] = (tempinC/1000)%10 + 48; // Extract tens digit
tempC[2] = (tempinC/100)%10 + 48; // Extract ones digit
// convert temp_fraction to characters
tempC[4] = (tempinC/10)%10 + 48; // Extract tens digit
// print temperature on LCD
Lcd_Out(2, 1, tempC);
}
void main() {
ADCON1 = 0b00000001; // Connect AN3 , select Vref=1.2V
TRISD = 0b00000000; // PORTD All Outputs
TRISA = 0xFF; // PORTA All Inputs
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
Lcd_Chr(2,6,223);
// Different LCD displays have different char code for degree symbol
// if you see greek alpha letter try typing 178 instead of 223
Lcd_Chr(2,7,'C');
while(1) {
temp_value = ADC_Read(0);
temp_value = temp_value*1168;
tempinC = temp_value/100;
Display_Temperature();
Delay_ms(1000); // Temperature sampling at 1 sec interval
}
}
|
أخي العزيز ف عبدالعزيز جزاك الله الف خير وبركة وأنعم عليك الله بمحض كرمه وجزيل فضله وجودة مبذول بالجد رائع جدا قمة في الروعوة والإبداع , نفعنا الله بعلومكم اجمعين مشكورين .
وبعد :
انا والحمدلله قمت بتصميم هذا المشروع ونفذ معاي ويرجع هذا الفضل من بعد الله لك أخي الكريم ,,,, ولكن ...:
ولأهمية الموضوع انا عايز منك مساعة بسيطة او اي حد بيقدر يساعدني في هذا المشروع ,,,,,
عايز أصمم وبالفعل مشروع طبقا لهذا المشروع ولكن توجب علي بتغير بعض الأشياء مثل الـ . pic16f877 بـ.ATMEGA16 وقمة حقيقة بتعديل بعض التعليمات لتتوافق مع الـ. ATMEGA16 ...
ولكن المشكلة التي ظهرة لي بعد التعديل :
وجود رسالة خطأ فقط في الموضع التالي :
>>>
ADCON1 = 0b00000001;
والذي علمته ان هذا التعليمة خاصة بالبن الخاص بجهد المرجع الموجب AN3 في الـ. Pic16f877 وهذا البن أو الرجل غير متوفر في الـ. ATMEGA16 هل يرجع تلك المشكلة لهذا السبب ؟ ام ماذا ؟ .... ام ما هو الحلل ؟
افيدوني أعانكم الله وبارك الله فيكم أجمعين
|