lm35

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

lm35

Postby pingubrow2 » Sat Dec 17, 2011 2:37 am

hey guys i am doing a project on lm35 but i am having problems with the value . can someone tell me for example what i need to do. thx
pingubrow2
Newbie
 
Posts: 15
Joined: Sat Sep 03, 2011 4:18 am

Re: lm35

Postby pingubrow2 » Sat Dec 17, 2011 2:42 am

CODE: SELECT_ALL_CODE
#include <p18f4455.h>
#include <stdio.h>
#include <stdlib.h>
#include <adc.h>


long int i=0;
int samples[8];
int tempc;
int a;
void delay ();

void main()
{   
   ADCON0=0b00000011;
   ADCON1=0b00001111;
   ADCON2=0b00000110;
   
   LATD=0b00000000;
    TRISD=0b00000000;
 
TRISA=0b00000000;
   

     


     // LATA=ADCRead(0);   //Read Channel 0
     LATA=0b11111111;
 for(a=0;a<=7;a++){
samples[i]  =(5.0*LATA*100.0)/1024.0;
 tempc=tempc+ samples[i];
delay();

}

printf("%d",tempc);
 printf("\n");
   



delay();
}
void delay() {
for (i=0; i<=10000; i++){

}

}
pingubrow2
Newbie
 
Posts: 15
Joined: Sat Sep 03, 2011 4:18 am

Re: lm35

Postby shahrul » Sat Dec 17, 2011 12:03 pm

pingubrow2 WROTE: // LATA=ADCRead(0); //Read Channel 0
LATA=0b11111111;
for(a=0;a<=7;a++){
samples[i] =(5.0*LATA*100.0)/1024.0;
tempc=tempc+ samples[i];
delay();
}

You not divide tempc by 8 to take average.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 3 guests