Yes, of course it can.
It's only 3-4 khz. You can generate that in software easily.
But see if it drives your piezo first.
I was assumming your piezo has a resonant frequency of ~3.5khz.
Yes, of course it can.
It's only 3-4 khz. You can generate that in software easily.
But see if it drives your piezo first.
I was assumming your piezo has a resonant frequency of ~3.5khz.
Last edited by Darrel Taylor; - 8th August 2012 at 16:07.
DT
THANKS Darrel, it worked like a charm with HPWM. Any pointers as to how to do without it.
I tried FREQOUTbut the results were not the same, not even near enough, the pulsing sound is not that prominentCode:FOR Freq = 3000 TO 4000 STEP 10 FREQOUT PortC.2,1, Freq NEXT Freq
FREQOUT makes sine waves and must be filtered, which is not what you need.
Try this ...
Code:PiezoPIN VAR PORTC.2 TMR0IF VAR INTCON.2 Width VAR BYTE OPTION_REG = %11010011 ; TMR0 1:16 Alarm: FOR Width = 161 TO 120 STEP -1 WHILE !TMR0IF TOGGLE PiezoPIN PAUSEUS Width TOGGLE PiezoPIN PAUSEUS Width WEND TMR0IF = 0 NEXT Width GOTO Alarm
DT
Just out of curiosity, can this be achieved without using a microcontroller?
Commonly driven by a type 555 multi-function timer chip. Google '555 alarm schematic' and take your pick.
Also can be done using standard logic gates such as 2-NANDs in astable mode with another 2 providing the modulation therefore a single dual-input quad NAND package (4011 or 7400) will work. You can use NOR gates too.
You can also buy piezo devices that are already configured to output an alarm tone, aka piezo buzzers. Sonalert for one, comes to mind.
Tim Barr
Bookmarks