| ??? 08/26/00 01:38 Read: times |
#4714 - RE: Making speedometer with 8051: |
Brian,
The problem is the non-linearity of the curve between counter value and speed. For example going from 1mph to 2mph should half the count but it would be 4mph before its halfed again. The difference between 98mph and 99mph would be very small. Its always a good idea to test algorithms out in a spreadsheet before coding to see if there are hidden problems. For my bicycle and a 12Mhz 8051 with its divide by 12 clock divisor and no prescaler, the counter ticks per revolution at various speeds are shown below. You can see the non-linearity and how the numbers are so big that you need to deal with either slowing the clock down (saves battery power) or extend the count with an overflow and then scale down for table lookup. I think 12Mhz 8051 would be a poor choice. MS Excel generated: 1 mph = 4819489 counter ticks 2 mph = 2409744 counter ticks 3 mph = 1606496 counter ticks 4 mph = 1204872 counter ticks 5 mph = 963898 counter ticks 6 mph = 803248 counter ticks 7 mph = 688498 counter ticks 8 mph = 602436 counter ticks ...etc... 94 mph = 51271 counter ticks 95 mph = 50731 counter ticks 96 mph = 50203 counter ticks 97 mph = 49685 counter ticks 98 mph = 49178 counter ticks 99 mph = 48682 counter ticks -Jay C. Box |



