|
:: مهندس ::
تاريخ التسجيل: Feb 2012
المشاركات: 18
|
|
نشاط [ جهاد يحيى ]
قوة السمعة:
|
|
13-11-2013, 06:48 PM
المشاركة 228
|
|
لقد قمت بتوصيل الحساس LM35 اخي باسم
لكن درجة الحرارة التي يعطيها الحساس هي 16 او 17 و لا تتغير مع اني قمت بتقريب جسم حار من الحساس لا تتغير تبقى 16 او 17
ما هو حل هذه المشكلة؟؟
هل المشكلة في انه لم يستخدم ADCON1 و ADCON0
اذا كانت هي المشكلة ارجو مساعدتي و شكرا
وهذا هو الكود الذي استخدمته
int temp_res;
char temp[12];
unsigned int rtemp=10;
char ntemp[10];
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;
Lcd_Cmd(_LCD_FIRST_ROW);
void adc()
{
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
temp_res = (temp_res *5)/10;
IntToStr(temp_res,temp);
asm CLRWDT;
}
void print()
{
Lcd_Cmd(_LCD_CLEAR);
lcd_out(1,1,"Now temp") ;
lcd_out(2,1,"Ref temp") ;
asm CLRWDT;
}
void test()
{
if(temp_res>rtemp)
{
PORTC=0b11010101; //cool
}
if(temp_res<rtemp)
{
PORTC=0b11001011;//hot
}
if(temp_res==rtemp)
{
PORTC=0b11000001;
}
asm CLRWDT;
}
void main()
{
TRISA =0b10;
TRISD =0x11;
TRISC =0x00;
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
////////////////////////////////
lcd_out(1,3,"Temperature") ;
lcd_out(2,2,"Control System") ;
delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
lcd_out(1,3,"Designed By") ;
lcd_out(2,1,"Jehad & Mohammad") ;
delay_ms(2500);
print();
do
{
IntToStr(rtemp,ntemp);
lcd_out(2,10,ntemp);
delay_ms(200);
lcd_out(1,10,temp) ;
delay_ms(200);
test();
if(portd.f1==0 && rtemp>0)
{
rtemp--;
delay_ms(200);
}
else if(portd.f0==0&&rtemp<=100)
{
rtemp++;
delay_ms(200);
}
adc();
}
while(1);
asm CLRWDT;
return;
}
التعديل الأخير تم بواسطة : جهاد يحيى بتاريخ 13-11-2013 الساعة 08:47 PM
|