We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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.....
Thanks Michael, cos i m new to uc and not really familiar with C lanugage, i m using DAvE to initalise all settings with C167, so i need to set the timer to certain time using the prescaler in order to match the capture signal? and how wud i convert those counts into relative speed in C language? i was thinking to use a look-up table but i dont think this method is accurate........
you can't really do this without basic knowledge of C, sorry. you must start there first.
Converting from pulses/second to km/h or miles/h is a trivial conversion of units. How would you convert from one speed unit to another in real life?
Don't ask questions for everything you don't have an immediate answer for. Spend some time thinking yourself. You will not learn unless you are willing to exercise your brain.
thanks...i've been trying to derive an algorithm for the conversion but i kept circulating of look-up table
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?
Thanks again, i'm getting to your point, so sth to do with the wheel size in which i can determine the distance convered in one revolution and from this, I know how many pulses represent the amount of revolution and from that i can determine the speed??
That's the idea: it's all just basic arithmetic - nothing specifically to do with 'C' or microcontrollers!
is sounds simple but wen i try to implement those into C......i m blanked again....but still i try to hack it....thanks
I don't know where you have your sensor, but if it generates one pulse for each wheel revolution, then each pulse represents a traveled distance wich follows from the circumference of the wheel.
And speed is the amount of traveled distance in a specific time space.
That means that your speed is a constant multiplied by the number of pulses you get every second. Your initial formula may contain a number of constants - one for wheel diameter or wheel radius or wheel circumference. Another for number of pulses/second. Yet another to convert from speed/second to speed/hour. But all these constants can be combined.
Your job is to calibrate your system by finding out how the value of that constant. The next step is to express this in a way your processor can handle. It will be trivial if you can afford to use floating point numbers. But it can be solved just as well (or normally better as in smaller and faster) with integer arithmetic.
yer the speed sensor is attached to the rear wheel, the wheel size is 10inch. I measured its operating frequency which is 0 to 135Hz representing 0 to 60mph. I think I'm getting closer just to work out the basic maths
The sentence "Another for number of pulses/second." should have been "Another for the number of pulses/wheel rotation".
ok....so i can also obtain the rpm as well as speed, i just checked the speed sensor results i had obtained. It seems to be depending on frequency rather than number of pulses. It generates a duty cycle and from that, 10Hz may represent 4mph....along that line..
Obviously, you can't get anywhere until you understand precisely what the output from your sensor actually means!
What does its Datasheet say?
Number of pulses = Distance. Number of pulses/second = Frequency = Speed
Number of pulses/second => RPM of wheel, not RPM of engine