Paja

Icon

Rapid prototyping for music, art and design work

Pulse IO for Ping))) Ultrasonic Sensor

PBasic code for Ping))) Ultrasonic Sensor looks very simple.

BASIC Stamp PBasic code:

pPing PIN 7 ‘ 7 pin connects to SIG pin of the PING)))
wTime VAR WORD ‘ declaring wTime as a variable
cTrigger CON 5 ‘ trigger pulse = 10 uS for BS2

DO ‘ repeat between DO – LOOP
PULSOUT pPing, cTrigger ‘ send a command to Ping)))
PULSIN pPing, 1, wTime ‘ receive a value from Ping)))
DEBUG DEC5 wTime, CR ‘ send the value to computer
PAUSE 100 ‘ stop for 100 milliseconds
LOOP

If you are not familiar with BS, you can only look at Pulsin and Pulsout. Once BS sends a Pulse for a certain period. The period seems 50µs. The Ping))) sensor send back the value after that.
Pulseout command:

PULSOUT Pin, Period

  1. Pin is a variable/constant/expression (0 – 15) that specifies the I/O pin to use. This pin will be set to output mode.
  2. Period is a variable/constant/expression (0 – 65535) that specifies the duration of the pulse. The unit of time depends on the microcontroller. in my case, a unit is 10µs.

PULSIN Pin, State, Variable

  1. Pin is a variable/constant/expression (0 – 15) that specifies the I/O pin to use. This pin will be set to output mode.
  2. State is a variable/constant/expression (0 – 1) that specifies whether
    the pulse to be measured is low (0) or high (1). A low pulse begins
    with a 1-to-0 transition and a high pulse begins with a 0-to-1
    transition.
  3. Variable is a variable (usually a word) in which the measured pulse duration will be stored.

f you want to simulate this on Max/MSP via Maxduino by Marius Schebella and Arduino, You can download a PDF about the PING))) from Parallax site. Page 3 would be helpful to understand the pulse.

Facebook Twitter Email

Category: Snippets

Tagged:

Comments are closed.

Social links powered by Ecreative Internet Marketing