blacksnow
Junior Member level 2
Hi, I am learning the 89c51 programming in keil C. Presently i want to read the clock (or pulse train of any frequency form 1 to 1100 Hz using proteus software). But there is some percentage error in the values that are displayed on LCD. e.g if feed 1kHz clock signal thr LCD shows 1001 or 1002, which is not a problem. The problems comes when i multiply these values by 60 to get rpm (rev/min) then it becomes 60060 or 60120. Presently i read the counter after every 1 sec.
Please give me some suggestion (not the c code) to minimize this error.
One other way will be to average the counter values e.g add last 5 counter values and multiply by 12 to get rpm but we will wait for 5 seconds to do so. Hence the pocess becomes slow.
Here is the portion of the code which calulates RPM,
Please give me some suggestion (not the c code) to minimize this error.
One other way will be to average the counter values e.g add last 5 counter values and multiply by 12 to get rpm but we will wait for 5 seconds to do so. Hence the pocess becomes slow.
Here is the portion of the code which calulates RPM,
while(1) {
delay();
TR1 = 0;
TR0 = 0;
value = 256*TH1+TL1;
rpm = 60*value ;
Conv2Dec(rpm);
TH1 = 0x00;
TL1 = 0x00;
TH0 = 0xd8;
TL0 = 0xf0;
TR1 = 1;
TR0 = 1;
i = 0;
}
}
void delay(void){
TR0 = 1; // Timer starts here
while(i!=100) { // repeat 100 times i.e 100 x 10,000usec = 1 sec
if(TF0==1) {
TF0 = 0;
TR0 = 0;
TH0 = 0xD8; // for 10000uSec
TL0 = 0xF0;
TR0 = 1;
i = i + 1;
}
}
}