Hi
I am using keil to program my 89C51 using C language, and I am trying to work the following equation.
humidity = (0.6785 * (ADC_value)) - 27.1
note that ADC_value is giving correct values.
But when I build my program it will give me 8 warrnings and when I debug my program the humidity will remain empty, thus the equation is not being implimented within the program.
So I decided to eliminate the Point, at first by using the following equation.
humidity = ((6785 * (ADC_value))/10000) - 27
This time no warrnings were given but when debugging the program a pair of .. will always appear regardless the ADC value. thus again, the equation is not workling properly.
Again, I decided to manipulate the equation for testing and used the following:
humidity = ((6785 * 2)/10000) - 27, but again the value was not right. so I turning the -27 to + 27 and guess what, the equation worked.
I have no idea what I am doing wrong. Also the keil can work log10(x), sin(x) etc but the program will give some warrnings and will not exectute that part of the program.
I am using the <math.h> library.
Am I missing something important here ?
void sendhumidity_data()
{
char humidity;
//humidity = (((6785)*(150))/10000)-27;
humidity = ((6785*2)/10000) + 20;
bin=(humidity/10); //select first digit of value converted
bin1= bin + 0x30;
dec = (humidity % 10); //most significant digit
dec1 = dec + 0x30;
SBUF = bin1;
while(TI == 0); //Wait until the serial data is sent.
TI = 0;
SBUF = dec1;
while(TI == 0); //Wait until the serial data is sent.
TI = 0;
}
Note: bin and dec are both unsigned char.
The humidity value should be between 99 - 0 and since I am using hyperterminal I am spliting the hex result in two to display the right ASCII characters from 0 to 9 serially.
Any help would be great please
Regards
Uridan
I am using keil to program my 89C51 using C language, and I am trying to work the following equation.
humidity = (0.6785 * (ADC_value)) - 27.1
note that ADC_value is giving correct values.
But when I build my program it will give me 8 warrnings and when I debug my program the humidity will remain empty, thus the equation is not being implimented within the program.
So I decided to eliminate the Point, at first by using the following equation.
humidity = ((6785 * (ADC_value))/10000) - 27
This time no warrnings were given but when debugging the program a pair of .. will always appear regardless the ADC value. thus again, the equation is not workling properly.
Again, I decided to manipulate the equation for testing and used the following:
humidity = ((6785 * 2)/10000) - 27, but again the value was not right. so I turning the -27 to + 27 and guess what, the equation worked.
I have no idea what I am doing wrong. Also the keil can work log10(x), sin(x) etc but the program will give some warrnings and will not exectute that part of the program.
I am using the <math.h> library.
Am I missing something important here ?
void sendhumidity_data()
{
char humidity;
//humidity = (((6785)*(150))/10000)-27;
humidity = ((6785*2)/10000) + 20;
bin=(humidity/10); //select first digit of value converted
bin1= bin + 0x30;
dec = (humidity % 10); //most significant digit
dec1 = dec + 0x30;
SBUF = bin1;
while(TI == 0); //Wait until the serial data is sent.
TI = 0;
SBUF = dec1;
while(TI == 0); //Wait until the serial data is sent.
TI = 0;
}
Note: bin and dec are both unsigned char.
The humidity value should be between 99 - 0 and since I am using hyperterminal I am spliting the hex result in two to display the right ASCII characters from 0 to 9 serially.
Any help would be great please
Regards
Uridan