Well, I got a simple form of frequency detection going on with my 16f690 last night.
I fed a sine wave into one of the 16f690s comparator input pins & used DT's comparator interrupt routine - the associated handler incremented a count with every comparator flip (interrupt),
I then simply used timer1 set to overflow at 0.5s - at overflow the comparator count is multiplied by two (to get the equivalent count for 1 second - so the end result was in Hertz).
I was getting reasonable accurate frequency detection - the 'count' number danced about +/- 2 or 3 (therefore ultimately 2 or 3Hz) ...which I'm pretty sure could probably be averaged out to bring this error down a little).
I wasn't able to get the 16f690' internal VREF to work (I was using the external VREF pin set at 1/2 VCC)
This VREF issue aside (which I'll revist soon), what I now need is a 'rolling window' in code, which goes something like thus...
"If the comparator count hasn't changed - give or take - for the past 1.5 seconds (ie rolling window), then that must mean a note is presently being held, if so ...go & do stuff!"
Now there are only two timers on the 16f690....and I was really hoping to keep one of them in reserve for flashing LEDS (the LED 'flash rate' depending on the mode), so I'm looking for creative ideas that would allow me to apply the above 'condition' without wasting anther timer!
Grateful for any input here!




Bookmarks