This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Measuring Vehicle Speed using C167 microcontroller

Hi all, need some help here, as i'm new to uc i have a few problems of how to use it properly, i'm capturing speed sensor signal using uc C167, the signal operates between 0 to 135Hz max, how i can set the prescaler of the uc to match the capture signal so that i could take the measurement? the signal is a digital pulse (50-50 duty cycle), and what algorithm i need to convert the measurements to mph??
thanks to all.....

Parents
  • It is a known fact that a pocket calculator can be used for converting a speed from one measurement unit into another.

    Would a pocket calculator contain a huge number of huge lookup tables?

    The only thing to consider here, is the precision you need, i.e. how many bits there must be in the numbers when you compute an answer.

    Remember that you don't need floating point for everything. You can just as well use fixed-point arithmetic. You just define that the answer is 100 times larger than normal, and that the last two digits is decilams.

    The circumference of a circle is pi * d, where d is the diameter. Or in another writing pi*2*r, where r is the radius.
    Assume that the radius is 1

    With floating point, you could compute that the circumference is 2*1*3.1415926... = 6,283185307...

    With integers, you could compute:
    2*1*3 = 6
    This gives a big error.

    Using fixed point scaled with a factor 10, you could compute:
    2*1*31 = 62. The answer is 6.2, which has a smaller error.

    Using fixed point scaled with a factor 100, you could compute:
    2*1*314 = 628. The answer is 6.28. Getting closer.

    Using fixed point scaled with a factor 1000, you could compute:
    2*1*3141 = 6282. The answer is 6.282. Still better.

    Scale with 10000:
    2*1*31415 = 62830 => 6.2830.

    Scale with 100000:
    2*1*314159 = 628318 => 6.28318

    Now, back to the drawing board. How could you convert from RPM/s to km/h or miles/h?

Reply
  • It is a known fact that a pocket calculator can be used for converting a speed from one measurement unit into another.

    Would a pocket calculator contain a huge number of huge lookup tables?

    The only thing to consider here, is the precision you need, i.e. how many bits there must be in the numbers when you compute an answer.

    Remember that you don't need floating point for everything. You can just as well use fixed-point arithmetic. You just define that the answer is 100 times larger than normal, and that the last two digits is decilams.

    The circumference of a circle is pi * d, where d is the diameter. Or in another writing pi*2*r, where r is the radius.
    Assume that the radius is 1

    With floating point, you could compute that the circumference is 2*1*3.1415926... = 6,283185307...

    With integers, you could compute:
    2*1*3 = 6
    This gives a big error.

    Using fixed point scaled with a factor 10, you could compute:
    2*1*31 = 62. The answer is 6.2, which has a smaller error.

    Using fixed point scaled with a factor 100, you could compute:
    2*1*314 = 628. The answer is 6.28. Getting closer.

    Using fixed point scaled with a factor 1000, you could compute:
    2*1*3141 = 6282. The answer is 6.282. Still better.

    Scale with 10000:
    2*1*31415 = 62830 => 6.2830.

    Scale with 100000:
    2*1*314159 = 628318 => 6.28318

    Now, back to the drawing board. How could you convert from RPM/s to km/h or miles/h?

Children