Frequency
dchance
Posts: 6
I’m not sure any one can help me but I’m going to ask to see if I can understand how my project works and make it better. I have a project that I am working on where I look for the width of the first pulse from a 15 – 68 HZ signal. Note: there is other noise on the line also at times, that is why I’m trying to narrow it to a range. I do not know the frequency of the signal I am currently reading. (Be nice if I had a frequency counter, but it is between 15 – 68 HZ).
·
Currently I do the following.
·
_AUTO: ···
··· PULSIN RB.0, 1, pWidth,50
··· if pWidth < 94 goto _Auto
··· if pWidth > 96 goto _Auto
·
from what I understand
·
I could change this to measure the width of the high pulse then the low pulse and calculate the frequency from this? It doesn’t have to be exact I only need to know if it falls into the range of 15 – 68 hz. Any ideas? Examples?
·
·
·
I have a lack of knowledge when it comes to frequencies, and pulses. That’s where I hope you can come in to play.
I am using SX/B at 4MHZ
·
Currently I do the following.
·
_AUTO: ···
··· PULSIN RB.0, 1, pWidth,50
··· if pWidth < 94 goto _Auto
··· if pWidth > 96 goto _Auto
·
from what I understand
·
I could change this to measure the width of the high pulse then the low pulse and calculate the frequency from this? It doesn’t have to be exact I only need to know if it falls into the range of 15 – 68 hz. Any ideas? Examples?
·
·
·
I have a lack of knowledge when it comes to frequencies, and pulses. That’s where I hope you can come in to play.
I am using SX/B at 4MHZ
Comments
2. You may need to 'square-up' the input signal. A 74HCT14 schmitt-trigger will do this nicely.
3. A 15 Hz square wave cycles in 66 mSec. Thus it has a 33 mSec 'high' followed by a 33 mSec 'low'. If you wait for the 'low' to start, then do a PULSIN, you should get an accurate number for how long the 'high' pulse is.
4. A 68 Hz square wave cycles in 14.7 mSec (7.35 mSec high, then low). The middle of those two is 20 mSec (on a BS2, with 2 uSec per 'tick', that would be a PulseWidth of 10,000 -- You were trying to use 94 or 96).· (Math: (33 mSec + 7.35 mSec) / 2 == 20 mSec)
5. Is this signal a sine wave? Or is it some other (like a Servo control signal) pulse signal which repeats at a certain interval?
·
·
·········· That is what I was looking for. It is a sign wave, and yes I agree I need to square it up.
·
Let me see if I understand the math part of the pulsein on the SX/B
The pulsein on the SX/B has a resolution option at the end of it.
I has it set to 50. If I understand this correctly.
I had it set to 50 which is 50 times 0.01 ms. or 10 usec per tick
·
(50 X .01 = .5 ms resolution)
My pulsewidth that I am getting back is an average of 95.
·
So that would be 50 microseconds X 95 = 47.50 microseconds.
·
If my signal was square that would probably be a frequency of apx 21 HZ· (Right on target!)
Yes, you are entirely correct, as far as I can find.