Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LM35 Code with c18 library (pic18f4550)

Status
Not open for further replies.

sosososo

Newbie level 3
Joined
Sep 24, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
:oops: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
 

heyy can i get that interfacing diagram of lm35 with pic18f4550
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top