hey friend i was going thru a tutorial for PIC16F877A programming when i had one doubt in the below program....
#include<pic.h>
#include<stdio.h>
#include<delay.c>
#include<lcd.c>
/* Function to wait */
void wait_a_second()
{
unsigned int j;
for (j=0; j<4;j++)
DelayMs(250);
}
/* Main Program */
main(void)
{
const float lsb = 5000.0/1024.0; (i have doubt in this line)
float mV,temp, templ, temph;
unsigned int tempc;
unsigned char disp[]=" TEMP = ";
TRISA=1;/* RA0 is input and others output */
TRISB=0;/* Port B is output */
RBPU=0; /* Trigger the internal pullup registers */
ADCON1 = 0X8E;/* RA0 is analog and RA2 and RA3 are digital */
ADCON0 = 0X41; /* Configure A/D clock and select channel 0 */
for(;
{
ADCON0 = 0X45;/* Start Analog to Digital convertion */
while (ADCON0 !=0);/* wait for convertion */
temph = ADRESH;/* Upper 2 bits */
templ = ADRESL;/* Lower 8 bits */
temp = 256.0*temph+templ;/* In digital mode */
mV = temp*lsb; /* Temperature in mV */
tempc = mV/10.0; /* Temperature in centigrade since Vo is 10 mV/C hence if temperature is 30degree it is represented as 300mV/C*/
sprintf (disp+7, "%d",tempc); /* Display temperature as string */
lcd_puts(tempc);
wait_a_second();
lcd_clear();/* clear display screen of LCD*/
}
}
/* End of Program */
Questions :
1. what is the line " const float lsb =5000.0/1024.0 " means?
2. why is he multiplying 256 * temph +templ to get digital code?
THis program is for interfacing LCD with PIC16F877.....
Source:
10 EMI 05 Programming PIC Micro Controllers in C
Page no.39 of that tutorial
So help me plz
#include<pic.h>
#include<stdio.h>
#include<delay.c>
#include<lcd.c>
/* Function to wait */
void wait_a_second()
{
unsigned int j;
for (j=0; j<4;j++)
DelayMs(250);
}
/* Main Program */
main(void)
{
const float lsb = 5000.0/1024.0; (i have doubt in this line)
float mV,temp, templ, temph;
unsigned int tempc;
unsigned char disp[]=" TEMP = ";
TRISA=1;/* RA0 is input and others output */
TRISB=0;/* Port B is output */
RBPU=0; /* Trigger the internal pullup registers */
ADCON1 = 0X8E;/* RA0 is analog and RA2 and RA3 are digital */
ADCON0 = 0X41; /* Configure A/D clock and select channel 0 */
for(;
{
ADCON0 = 0X45;/* Start Analog to Digital convertion */
while (ADCON0 !=0);/* wait for convertion */
temph = ADRESH;/* Upper 2 bits */
templ = ADRESL;/* Lower 8 bits */
temp = 256.0*temph+templ;/* In digital mode */
mV = temp*lsb; /* Temperature in mV */
tempc = mV/10.0; /* Temperature in centigrade since Vo is 10 mV/C hence if temperature is 30degree it is represented as 300mV/C*/
sprintf (disp+7, "%d",tempc); /* Display temperature as string */
lcd_puts(tempc);
wait_a_second();
lcd_clear();/* clear display screen of LCD*/
}
}
/* End of Program */
Questions :
1. what is the line " const float lsb =5000.0/1024.0 " means?
2. why is he multiplying 256 * temph +templ to get digital code?
THis program is for interfacing LCD with PIC16F877.....
Source:
10 EMI 05 Programming PIC Micro Controllers in C
Page no.39 of that tutorial
So help me plz