Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to use the PIC capture mode to capture time? (ultrasonic sensor)

Status
Not open for further replies.

sysysy

Member level 3
Joined
Nov 11, 2010
Messages
56
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Activity points
1,801
Hi,

I'm doing a project and have been built up the ultrasonic receiver circuit.
Also, i use my PIC to transmit the 40Khz signal go out through the ultrasonic transmitter. If there is a obstacle, the 40Khz sound wave will be reflect back.
The reflected 40khz signal will be received by the ultrasonic receiver sensor and then amplified by 1000 times, then will pass through the peak detector circuit. Finally, comparator used to recognize whether there is a 40khz signal come in or not, and then the output of the comparator will direct connect to the micro-controller (PIC 16F877A).

But, i have face some problem here.
To calculate the how much the distance between the obstacle and my sensor, i need time in the calculation (since speed of sound is around 340m/s)

So, once i transmit out the 40khz from my PIC, i should immediately start the timer and once the PIC pin trigger that the signal come in, the timer also should immediately stop. So that this period of time can be used in the calculation.

But the problem is how to capture this period of time? some ppl ask me to use ccp mode to do this. But i even dunno how to start. can anyone give me details step. Instead of setup the ccp, i really wish to know what is the concept to capture this period of time.

Thanks a lot.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top