sosososo
Newbie level 3
hi all,
i need to help me quickly i will deliver my project in few days,
i am connect temprature sensor LM35 to pic18f4550 iam using c18 library
configration that i am used as following : F=8Mhz , so iam using FOSC/16 , and 2 TAD ,.. output test by LED ---------> My code :
#include<p18f4550.h>
#include<delays.h>
#include<adc.h>
#pragma config WDT=OFF
#pragma config LVP=OFF
#pragma config FOSC=INTOSC_HS
void main(void){
float temp,t ;
int t_val;
OSCCON=0b01110001;
PORTD=0;
PORTA=0;
TRISD= 255;
TRISA=255;
OpenADC(ADC_FOSC_16 & ADC_RIGHT_JUST & ADC_2_TAD ,ADC_INT_OFF &
ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS , 14);
SetChanADC(ADC_CH0);
while(1){
//////// Configration for ADC
Delay10TCYx(50);
ConvertADC();
while(BusyADC());
t_val= ReadADC();
t = t_val*1.0;
CloseADC();
// equation special for LM35 Sensor
temp = ((t* 500) /1023);
if ( temp < 35.0){ //high temp
PORTDbits.RD0=1;
}
else
PORTDbits.RD0=0;
}
}
please if any one can help me
i need to help me quickly i will deliver my project in few days,
i am connect temprature sensor LM35 to pic18f4550 iam using c18 library
configration that i am used as following : F=8Mhz , so iam using FOSC/16 , and 2 TAD ,.. output test by LED ---------> My code :
#include<p18f4550.h>
#include<delays.h>
#include<adc.h>
#pragma config WDT=OFF
#pragma config LVP=OFF
#pragma config FOSC=INTOSC_HS
void main(void){
float temp,t ;
int t_val;
OSCCON=0b01110001;
PORTD=0;
PORTA=0;
TRISD= 255;
TRISA=255;
OpenADC(ADC_FOSC_16 & ADC_RIGHT_JUST & ADC_2_TAD ,ADC_INT_OFF &
ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS , 14);
SetChanADC(ADC_CH0);
while(1){
//////// Configration for ADC
Delay10TCYx(50);
ConvertADC();
while(BusyADC());
t_val= ReadADC();
t = t_val*1.0;
CloseADC();
// equation special for LM35 Sensor
temp = ((t* 500) /1023);
if ( temp < 35.0){ //high temp
PORTDbits.RD0=1;
}
else
PORTDbits.RD0=0;
}
}
please if any one can help me