??? 03/03/05 17:01 Read: times |
#89009 - Clearing the display... |
Produced below is the coding for RPM display by the reciprocal method.
Only the main is given to keep the posting short. The RPM display is quite fine with an averaging of about 5 samples( that code not appearing here ) Problem is to clear the display when the RPM=0.The code gets stuck at any of the points [A] to [D]and the display holds the last value before the rpm became zero. Any ideas ? ( The MCU is 89v51rd2 and T2 is unused ) void main(void) { union merge {tChar hilo[4]; tLong regval;} t1val; ... ... while(1) { msDelay(100); // One update every 0.1sec while (RPMCLK == 0); // [A]wait to clear the partial low of clock while (RPMCLK == 1); // [B]wait to clear the partial high of clock TR1 = 1; // start timer_1 to count MCU clock pulses while (RPMCLK == 0); [C] start counting the 1micro pulses while (RPMCLK ==1); // [D] continue counting for 1 full period TR1 = 0 ; // stop counting. tmpResult = ovrfloCnt * 65536 ; // Get the total period of overflows t1val.hilo[3] = TL1; // (LSB) merge TL1 and TH1 into a long int... t1val.hilo[2] = TH1; // ... to get the residual count t1val.hilo[1] = 0; t1val.hilo[0] = 0; // (MSB) t1val.regval = t1val.regval + tmpResult; tmpResult = 2000000 / t1val.regval; // Transfer function to get RPM sprintf(dispBuffer, "%04lu", tmpResult ); // Display the value.. ... ... } } Thanks Raghu |
Topic | Author | Date |
Clearing the display... | 01/01/70 00:00 | |
Infinite loops | 01/01/70 00:00 | |
SLOWEST speed ? | 01/01/70 00:00 | |
Andy / Steve.. | 01/01/70 00:00 | |
But wait, there's more! | 01/01/70 00:00 | |
One method.. | 01/01/70 00:00 | |
A way to implement a simple ramp down![]() | 01/01/70 00:00 |