26mV is only 2.6 degrees C... Is it freezing in India??? The number 15 represents 1.5 degrees C... YOU need to implement the decimal point!!
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sorry it is..26mV is only 2.6 degrees C...
#include <htc.h>
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000
unsigned char digits[] = { 0b00010000,0b01111101,0b00100010,0b00101000,0b01001101,0b10001000,
0b10000000, 0b00111101,0X00,0b00001000};
void main(){
TRISD=0X00;
TRISB=0X00;
PORTB=0X00;
TRISA = 0xff ;
ADCON1=0b00000000;
ADCON0=0b10000001;//000 = channel 0, (RA0/AN0)
ADIF=0;
ADIE=1;
PEIE=1;
while(1){
__delay_us(10);
GO_DONE=1;
__delay_us(10);
unsigned int x=0;
unsigned char y=0;
unsigned char z=0;
y=0b10110111;
z=0b11000000;
ADRESH=y;
ADRESL=z;
//x = (unsigned int) ADRESH << 8 + ADRESL; //Right!
x = (( unsigned int) ADRESH << 2) + (ADRESL >>6); // Left!
x=(ADRESH*500)/1024;
PORTD = 8;
x=x%10;
PORTB=digits[x];
__delay_ms(5);
PORTB=0X00;
x=ADRESH;
PORTD = 4;
x=(x/10)%10;
PORTB=digits[x];
__delay_ms(5);
PORTB=0X00;
x=ADRESH;
PORTD = 2;
x=x/100;
PORTB=digits[x];
__delay_ms(5);
PORTB=0X00;
x=ADRESL;
x=x%10;
PORTD = 1;
PORTB=digits[ADRESL]; // just for test on display working or not
__delay_ms(5);
PORTB=0X00;
}
}
x=(ADRESH*500)/1024;
long ADCresult;
ADCresult = ( unsigned int) ADRESH << 2) + (ADRESL >>6);
ADCresult *= 500;
ADCresult /=1024;
PORTD = 4;
PORTB = digits[ADCresult /100];
PORTD = 2;
PORTB = (digits[ADCresult % 100 /10] ) +DP; // the decimal place
PORTD = 1;
PORTB = digits[ADCresult % 10];
Hello,ADCresult =(unsignedint) ADRESH <<2)+(ADRESL >>6);
ADCresult *=500
It is called a cast!! ADRESH is a byte.... 0~255... Multiplying this with 500 wont do yo much good!Hello,
unsigned int from where this come?
and what is the need of 500 here?
logic behind it?
what is the reason of multiplying it with 500?Multiplying this with 500 wont do yo much good
getting hot now, before it was fine.Try this, post what you measure.
Hello,
Now it is 7805 with Capacitor of 22 uF on both side.
Please tell how to solve the problem of lm35 it is getting hot and after this the ADC at 0v giving 000 and 5v it i s 484 irregular number..
ADCresult *=500;
ADCresult /=1024;
The ADC is 10 bit result ok
then we multiply it by 500 and divide by 1024, what this mean?
logic behind it?
From where 1.023 comes here?If you want to measure 0 ~ 5v.... With a 10 bit ADC... 0 = 0 and 5 = 1.023 Okay!