??? 02/25/09 02:41 Read: times |
#162791 - Rough estimation... Responding to: ???'s previous message |
You could use "Timer 0" in "Mode 1". Give the pulse train to the input of a 74HC74 flip/flop (divide/2) and connect the output of flip/flop to the /INT1 pin. In a standard 8052 "Timer 0" would then count, how often 12 micro's clock periods fit into the period of pulse train.
Example: Clock frequency is 12MHz. So, "Timer 0" counts in 1µsec steps. If your pulse train is 22Hz, for instance, then the /INT1 input goes low for 1/22Hz = 45.455msec. So, "Timer 0" will count 45455 ticks. By this, 255MPH (561Hz) would result in 1783 ticks and the minimum speed would be 7MPH corresponding to 1/65536µsec = 15.3Hz. By analysing the "Timer 0" overflow flag (you don't need an interrupt for this) you can see if the speed drops under 7MPH. (Connect a lower reference clock to T1 input if speeds less than 7MPH are of importance.) When the /INT1 goes low the measurement is started and when /INT1 input goes high afterwards the computation of speed can be done. The micro must check the status of /INT1 input to control the measurement, of course, by polling or interrupt routine. A simple look-up table should allow you to find the proper speed for each range of ticks. Of course, you can also do an averaging. And to update the display (3 times a second, or so) use another timer. Kai |