(→PicoBat : a PIC-based simple and cheap ultrasonic detector) |
|||
| (11 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | An ultrasonic bat detector with only 3 components ! | + | [[File:PicoBat.jpg|thumb|PicoBat running on a bread board]] |
| + | An ultrasonic [[wikipedia:Bat detector|bat detector]] with only 3 components ! | ||
==PicoBat : a PIC-based simple and cheap ultrasonic detector== | ==PicoBat : a PIC-based simple and cheap ultrasonic detector== | ||
| − | + | A short video clip is sometimes better than a long explanation : | |
{{#ev:youtube|EjEkXlET0CM}} | {{#ev:youtube|EjEkXlET0CM}} | ||
| − | The idea of this circuit is to hack PIC oscillator circuit, by replacing the crystal by a piezo sensor : the frequency of the oscillator | + | The idea of this circuit is to hack the PIC oscillator circuit, by replacing the crystal by a piezo sensor : the frequency of the oscillator then depends on [[wikipedia:Ultrasound|ultrasounds]]. |
| − | Oscillator frequency is then divided and pushed | + | Oscillator frequency is then divided by 4 by the PIC, and pushed into a piezo speaker. |
It shares the same idea as [[PicoDetector]], the metal detector. | It shares the same idea as [[PicoDetector]], the metal detector. | ||
==Circuit Schematic== | ==Circuit Schematic== | ||
| − | [[File: | + | [[File:PicoBat-circuit-schematic.png]] |
| − | * | + | * The ultrasonic piezo receiver replaces resistor in PIC oscillator circuit |
| − | * | + | * SP1 is any piezo speaker you have |
==C Source code== | ==C Source code== | ||
| Line 20: | Line 21: | ||
/* | /* | ||
******************************************************************************* | ******************************************************************************* | ||
| − | * | + | * picoBAT : an ultra simple ultrasonic bat detector |
******************************************************************************* | ******************************************************************************* | ||
* | * | ||
| − | * Author : Bruno Gavand, | + | * Author : Bruno Gavand, February 2009 |
* see more details on http://www.micro-examples.com/ | * see more details on http://www.micro-examples.com/ | ||
* | * | ||
| − | * source code for | + | * source code for mikro C compiler V8.2 |
* feel free to use this code at your own risks | * feel free to use this code at your own risks | ||
* | * | ||
| − | * target : PIC12 | + | * target : PIC12 |
* | * | ||
* PIC PIN Assignemnt : | * PIC PIN Assignemnt : | ||
* | * | ||
| − | * GP0 | + | * GP0 GP1 : piezo speaker |
| − | + | * GP5 : ultrasonic transducer receiver | |
| − | + | ||
| − | + | ||
| − | * | + | |
* | * | ||
******************************************************************************* | ******************************************************************************* | ||
*/ | */ | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
void main() | void main() | ||
{ | { | ||
| − | |||
| − | |||
| − | |||
/* | /* | ||
* configure GPIO as digital port | * configure GPIO as digital port | ||
| Line 63: | Line 47: | ||
CMCON0 = 7 ; | CMCON0 = 7 ; | ||
ANSEL = 0 ; | ANSEL = 0 ; | ||
| + | |||
TRISIO = 0 ; | TRISIO = 0 ; | ||
| − | GPIO = | + | GPIO = 0b01 ; |
| − | + | for(;;) | |
| − | + | ||
| − | + | ||
| − | + | ||
{ | { | ||
/* | /* | ||
| − | * | + | * toggles speaker outputs |
*/ | */ | ||
| − | + | GPIO ^= 0b11 ; | |
| − | + | ||
} | } | ||
| + | } | ||
| − | + | </pre> | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | No, there is no mistake, full source code is above ! | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
==Download project== | ==Download project== | ||
| − | Download | + | Download PicoBat-project.zip file for mikroC : [[File:PicoBat-project.zip]] |
Includes : | Includes : | ||
* [[mikroC PRO]] project files for [[PIC12F683]], should work also with most of PIC | * [[mikroC PRO]] project files for [[PIC12F683]], should work also with most of PIC | ||
| − | * | + | * picoBat C source code |
| − | * | + | * picoBat .HEX files |
[[Category:Projects]] | [[Category:Projects]] | ||
[[Category:PIC12]] | [[Category:PIC12]] | ||
| + | |||
| + | ==Discussion and comments== | ||
| + | {{#w4grb_rate:}} | ||
| + | <discussion /> | ||
An ultrasonic bat detector with only 3 components !
Contents |
A short video clip is sometimes better than a long explanation :
The idea of this circuit is to hack the PIC oscillator circuit, by replacing the crystal by a piezo sensor : the frequency of the oscillator then depends on ultrasounds.
Oscillator frequency is then divided by 4 by the PIC, and pushed into a piezo speaker.
It shares the same idea as PicoDetector, the metal detector.
/*
*******************************************************************************
* picoBAT : an ultra simple ultrasonic bat detector
*******************************************************************************
*
* Author : Bruno Gavand, February 2009
* see more details on http://www.micro-examples.com/
*
* source code for mikro C compiler V8.2
* feel free to use this code at your own risks
*
* target : PIC12
*
* PIC PIN Assignemnt :
*
* GP0 GP1 : piezo speaker
* GP5 : ultrasonic transducer receiver
*
*******************************************************************************
*/
void main()
{
/*
* configure GPIO as digital port
*/
CMCON0 = 7 ;
ANSEL = 0 ;
TRISIO = 0 ;
GPIO = 0b01 ;
for(;;)
{
/*
* toggles speaker outputs
*/
GPIO ^= 0b11 ;
}
}
No, there is no mistake, full source code is above !
Download PicoBat-project.zip file for mikroC : File:PicoBat-project.zip
Includes :
Current user rating: 75/100 (60 votes)
| powered by commenterra | Recent comments |