propeller calculate speed probelm
ggg558877
Posts: 40
hello everyone
now i diy a encoder and want to get the wind speed value
my encoder just like this video
http://www.youtube.com/watch?v=ytOfofCJjGg&feature=player_embedded
and i use
but the output always have value 0
ex:
0
551
0
196
0
229
0
147
0
190
0
176
0
90
and if the wind speed sensor no rotate
it dosen't have value transmitted
and i want is
if wind speed sensor rotate
it transmitte
ex
551
196
229
147
190
176
90
and on rotate
it transmitte
ex
0
0
0
0
0
0
how can i slove my problem
thanks
now i diy a encoder and want to get the wind speed value
my encoder just like this video
http://www.youtube.com/watch?v=ytOfofCJjGg&feature=player_embedded
and i use
waitpne(0, |< Pin, 0) cnt1 := cnt waitpeq(0, |< Pin, 0) cnt2 := cnt Microseconds := (||(cnt1 - cnt2) / (clkfreq / 1_000_000))to calculate microseconds
but the output always have value 0
ex:
0
551
0
196
0
229
0
147
0
190
0
176
0
90
and if the wind speed sensor no rotate
it dosen't have value transmitted
and i want is
if wind speed sensor rotate
it transmitte
ex
551
196
229
147
190
176
90
and on rotate
it transmitte
ex
0
0
0
0
0
0
how can i slove my problem
thanks
Comments
I think you would be better off to use the hardware counter to count the pulses.
Bean
so i must add something on my wind speed sensor ?
or only use software to solve this problem?
The example in #3 is only software, to solve the issue of no reading on static sensor.
It configures a counter to increment on every sensor _/= and then reads that at some slow but precise rate.
These number are 32 bit precision, so you can read every 100ms for example to get a rapid speed display of moderate precision, good for peak readings, but also do a every-100-seconds-update, to get a nicely averaged and high precision wind speed display.
If we guess a 500us sensor speed, then a 100ms sample/refresh rate [Period in #3] can display to 0.5%, and a 100 second sample/refresh could display to 1000 times better precision (but you may choose to limit the displayed digits, to something practical )
If you want highest precision, you could apply Reciprocal Frequency Counter techniques, but whether that was worth doing, would depend on the jitter on each pulse edge of your sensor..
Sensors are always the weakest link.
so i can use example in #3 to count the the number of pulses
and count the the number of pulses in 1s to convert rps?
As with any home-built sensor, you will have to calibrate it. I'm sure there are lots of YouTube videos on this process. It would be a good idea to have a calibrated device for comparison.
in your code in #3
if I want to count the the number of pulses in 1s the period must set in one second ?
and long[p_count] value is pulse/s ?
The array provides stack space for the Spin interpreter running the code. The other variable is what you will access in raw counts. Let's say that you want to count your inputs on P0 and accumualte every second. You would launch the Spin cog like this:
No, that line is updating the long at the address you specify in the call. I use "p_" to designate a pointer (address of a variable).
Easy-peazy.
so the value i want is counts is that right?
In my code, you'll see that I'm setting one of the Propeller's counters to use the same pin as I'm declaring as an input for the anemometer -- this lets the Propeller test itself without any hardware connected. Always a good idea to know code is working before connecting new hardware.
I added the code suggestions to my standard template, so there's lots of stuff there that you may want to save for other projects, even if they aren't used in this one.
I'll try to learn it
can you explain i can't understand these line
what #(-1),#0,#1,#8,#14 ,#1 doing?
thanks a lot
Please ... there are plenty of materials available that explain Spin programming basics -- you can find good material as close as the Help menu in the Propeller Tool. Toward the bottom of page 88 in the manual you'll find an explanation about changing an enumerated CON block.
I don't mean to seem impatient, but YOU have some responsibility for study beyond the forums if you really want to become a good Propeller programmer.
sorry i ask a stupid problem
and i found the answer in the manual
thanks for your help a lot