EasyManuals Logo

Parallax PING))) 28015 User Manual

Default Icon
10 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #8 background imageLoading...
Page #8 background image
Copyright © Parallax Inc. PING))) Ultrasonic Distance Sensor (#28015) v2.0 2/4/2013 Page 8 of 9
Propeller Microcontroller
{{
***************************************
* Ping))) Object V1.1 *
* (C) 2006 Parallax, Inc. *
* Author: Chris Savage & Jeff Martin *
* Started: 05-08-2006 *
***************************************
Interface to Ping))) sensor and measure its ultrasonic travel time. Measurements can be in
units of time or distance. Each method requires one parameter, Pin, that is the I/O pin that
is connected to the Ping)))'s signal line.
┌───────────────────┐
│┌───┐ ┌───┐│ Connection To Propeller
││ PING))) ││ Remember PING))) Requires
│└───┘ └───┘│ +5V Power Supply
GND +5V SIG
└─────┬───┬───┬─────┘
│ 1K
└┘ └ Pin
--------------------------REVISION HISTORY--------------------------
v1.1 - Updated 03/20/2007 to change SIG resistor from 10K to 1K
}}
CON
TO_IN = 73_746 ' Inches
TO_CM = 29_034 ' Centimeters
PUB Ticks(Pin) : Microseconds | cnt1, cnt2
''Return Ping)))'s one-way ultrasonic travel time in microseconds
outa[Pin]~ ' Clear I/O Pin
dira[Pin]~~ ' Make Pin Output
outa[Pin]~~ ' Set I/O Pin
outa[Pin]~ ' Clear I/O Pin (> 2 μs pulse)
dira[Pin]~ ' Make I/O Pin Input
waitpne(0, |< Pin, 0) ' Wait For Pin To Go HIGH
cnt1 := cnt ' Store Current Counter Value
waitpeq(0, |< Pin, 0) ' Wait For Pin To Go LOW
cnt2 := cnt ' Store New Counter Value
Microseconds := (||(cnt1 - cnt2) / (clkfreq / 1_000_000)) >> 1 ' Return Time in μs
PUB Inches(Pin) : Distance
''Measure object distance in inches
Distance := Ticks(Pin) * 1_000 / TO_IN ' Distance In Inches
PUB Centimeters(Pin) : Distance
''Measure object distance in centimeters
Distance := Millimeters(Pin) / 10 ' Distance In Centimeters
PUB Millimeters(Pin) : Distance
''Measure object distance in millimeters
Distance := Ticks(Pin) * 10_000 / TO_CM ' Distance In Millimeters

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Parallax PING))) 28015 and is the answer not in the manual?

Parallax PING))) 28015 Specifications

General IconGeneral
BrandParallax
ModelPING))) 28015
CategoryAccessories
LanguageEnglish

Related product manuals