Hi Hank,
This may sound like a dumb question and you are doing an analog to digital conversion at some point? Also if you only wish to work with half wave, a simple diode will do this for you. Best, Ed
Hi Hank,
This may sound like a dumb question and you are doing an analog to digital conversion at some point? Also if you only wish to work with half wave, a simple diode will do this for you. Best, Ed
Firstly, I spoke to soon. Whilst this latest method mentioned in my last post has allowed me to detect higher frequencies....I'm still getting erratic results in & around the 450-700Hz audio frequency range!
Ramius - re Ato D'ng....no this is purely to detect frequency (although I do intend using the pic's AtoD as an envelope detect to actually trigger the frequency detection).
Last edited by HankMcSpank; - 10th June 2012 at 10:33.
Ok, it looks like interrupts are a big no-no here so I've established a way of doing this without an interrupt...
The above can detect up to 50khz audio inputCode:T1GCON.4 = 1 Loop1: pause 500 T1GCON.3 = 1 TMR1=0 while T1GCON.3 = 1 wend count1=tmr1 HSEROUT [dec count1,13,10] GOTO Loop1(can probably go higher...but the amount of timer1 counts between comparator edges gets less, so the 'percentage error' increases)
Basically I'm using a Timer gate single pulse mode (T1GCON.4 = 1), then forcing the other part of the single pulse mechanism to a 1 ( Single-Pulse Acquisition Status bit T1GCON.3 = 1), after the comparator2 output drops then T1GCON.3 is dropped to a zero automatically, I therefore use a wend to loop until T1GCON.3 = 1 is a 0 ....then I ouput the timer1 counts. My only problem is I'm getting a zero reading intermittently, but other than that, the counts are pretty solid.
here's the TMR counts for 1,000Hz....
1824
1824
1825
1825
1826
0
1824
just got to get to the bottom of why those readings of 0 are creeping in .....
Last edited by HankMcSpank; - 10th June 2012 at 18:06.
Hi Hank,
The only thing I can think of is the method you are using to couple the audio signal you wish to measure. Hopefully you are using a capacitor? To chose the best value would be with the formula Xc= .159/F*C "F" is in hertz "C" is in farads and in most audio work .047 mfd is common. Xc give the "resistive" value for a capacitor to AC. Again I am not sure how you would ever obtain great accuracy without conversion to a square wave with a consistant time duration. Again hope this helps. Best, Ed
Bookmarks