That is reallly neat! Did you have to protect the smoke alarm peizos with any coating?
I have used 4046's to multiply up the frequency from a shaft encoder so that I could get good more resolution. I always found them a bit difficult to work with.
I just wrote a little routine for a PIC that does a good job of detecting frequecies around 3Khz. It can be changed for other freqs. It should be able to detect the change in 2 cycles or less.
It is running in a 40Mhz PIC, so the values would have to be changed if you ran it slower.
Code:
define PULSIN_MAX 400
Top:
pulsin PORTD.1,0,LowVal
Pulsin PortD.1,1,HighVal
Period = LowVal+HighVal ; just in case the duty cycle isn't 50% ; period in uSec
Select case Period
Case is > 350
Hserout [CR,LF,"Too Low"]
case is > 310
hserout[CR,LF,"Just Right"]
case 0
hserout[CR,LF,"No Signal"]
case else
hserout [CR,LF,"Too High"]
end select
goto top
Bookmarks