CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Working with distance sensor

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
r.lopes32



Joined: 09 Sep 2010
Posts: 1
Location: Brazil

View user's profile Send private message

Working with distance sensor
PostPosted: Thu Sep 09, 2010 11:32 am     Reply with quote

Hi Guys,

I am using a distance sensor in my project and I need a little help on code.

Basically, the sensor works with two pins (PIN_1 trigger and PIN_2: Echo). when I put PIN_1 in logic level 1 the sensor sends a signal in a waveform when the wave find an object it will return and the PIN_2 echo will be logic level 1.

The question is: How can I measure the time between the trigger PIN_1 and receive the signal back on PIN_2

Data Project: PIC 16F877A, clock 4Mhz

Thanks in advanced,
_________________
Rodrigo Lopes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 09, 2010 11:08 pm     Reply with quote

You should admit that you're using the Parallax Ping sensor or the
Devantech SRF-04, or something similar.

You can use the CCS delay routines, delay_us() or delay_ms() to create
the trigger pulse. Read the sensor documentation to see what is the
required length of the trigger pulse.

Then you can use the Pulsin() routine in the following thread to read
the duration of the echo pulse.
http://www.ccsinfo.com/forum/viewtopic.php?t=42353&highlight=pulsin
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group