ctrx neg/pos edge detect mode question..
RinksCustoms
Posts: 531
If a counter were setup in neg-edge mode to count a pulse, & frq = 1, would it count clocks from the first neg-edge to the next neg-edge?
Also, is there a definition of a neg-edge? Is it just below 3.3V? Is it at 1/2 VDD?, Is it somewhere between 1.65V & 3.3V?
Thanks in advance..
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
Also, is there a definition of a neg-edge? Is it just below 3.3V? Is it at 1/2 VDD?, Is it somewhere between 1.65V & 3.3V?
Thanks in advance..
pri get_freq(maf_pin) : frequency | pulse {measure next available pulse on MAF_pin, then convert to a frequency number} ctra[noparse][[/noparse]30..26] := %01110 ctra[noparse][[/noparse]5..0] := maf_pin frqa := 1 phsa~ dira[noparse][[/noparse]maf_pin]~ waitcnt(50_000 + cnt) pulse := phsa #> 0 frequency := (f.fround(f.fmul((f.div(1,clkfreq)), pulse))) return frequency
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
Comments
Maybe pos detect mode would work better?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
or something like this then. Thanks guys for pointing the way. I do enjoy a good puzzle with the occasional road signs
Best Regards,
Mike R. ( how many mikes does that make it now? )
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
Post Edited (RinksCustoms) : 4/9/2008 5:00:23 AM GMT
wait for a low,
snapshot the value counted and reset the count,
wait for the return to high
then wait for the next low?
this will give you the high time/time between pulses
did this both ways at the same time on a 250kpps peak signal in the n64 and gamecube controller drivers I wrote. only used one cog too, man I love this chip.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Parallax Forums - If you're ready to learn, we're ready to help.
Post Edited (CJ) : 4/9/2008 1:25:54 AM GMT
·~Brain wave~~
And instead of counting each of ten pulses and converting each one to a freq and passing it back as an avg·freq number, I can just wait until PHSA == 9 (since edge-detect mode will count edges instead of accumulating FRQx to PHSx) and stop the counting on CTRB and just divide all the accumulated clock ticks in PHSB by 10 and convert that into an averaged frequency to be passed back to the calling method!
I don't have the spin file on my tower, but i can give a quick summary of what i'm trying to do with these two counters:
Monitor output pulses from a Mass Airflow Sensor
measure ten pulses or so·then average them, use 1/x to convert to a freq
convert the average frequency into a grams/sec measurement using a data "table" lookdown/up search method·- ( two tables, 102 entries each)
and a linear interpolation formula to output the final grams/sec value
I know SPIN is probably not fast enough to do all this in under 100mS, but I dont know any PASM - or any other kind of ASM. And none of this object has been actually tested yet, but it does compile so far, so i am hopeful there wont be too many bugs to iron out, I should be ready for actual testing this weekend (when I put my trans back in my firebird).
I do love these forums so! A great place for inspiration, and of course REALLY good answers - no sarcasm intended.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Parallax Forums - If you're ready to learn, we're ready to help.
If you need to read faster, then you can measure the duration between pulses using POS (not POS EDGE) detect mode and doing a waitpin function to wait for the input to go negative. On each negative pulse you read PHSA and set it back to zero. Now PHSA would be proportional to the period, IOW inversely proportional to the frequency.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?