Operácie

Acrob015: Rozdiel medzi revíziami

Zo stránky SensorWiki

Balogh (diskusia | príspevky)
Bez shrnutí editace
Balogh (diskusia | príspevky)
Bez shrnutí editace
 
(14 medziľahlých úprav od rovnakého používateľa nie je zobrazených.)
Riadok 1: Riadok 1:
[[Acrob010|< Previous]] | [[Acrob|Home]] | [[Acrob020|Next >]]
= Ultrasonic sensor for distance measurement =
= Ultrasonic sensor for distance measurement =


[[Obrázok:SensorPING.jpg|right|200px]]
[[Obrázok:SensorPING.jpg|right|200px]]
Riadok 7: Riadok 12:
* [http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/28015-PING-v1.6.pdf PING)))™ Documentation v1.6]  (.pdf)
* [http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/28015-PING-v1.6.pdf PING)))™ Documentation v1.6]  (.pdf)


'''Features:'''
* Provides precise, non-contact distance measurements within a 2 cm to 3 m range
* Simple pulse in/pulse out communication
* Burst indicator LED shows measurement in progress
* 20 mA power cosumption
* Narrow acceptance angle
'''Key Specifications:'''
* Power requirements: +5 VDC
* Communication:Positive TTL pulse
* Dimensions: 22 x 46 x 16 mm
* Operating temp range: 0 to +70 °C
=== Principle of operation ===
The Ping sensor measures distance using sonar; an ultrasonic (well above human hearing) pulse is transmitted from the unit and distance-to-target is determined by measuring the time required for the echo return. Output from the PING))) sensor is a variable-width pulse that corresponds to the distance to the target.
[[Obrázok:SensorPingOperation.png|center|450px]][[Obrázok:SensorPingUS_Cone.png|center|350px]]
The PING))) sensor detects objects by emitting a short ultrasonic burst and then "listening" for the echo.
Under control of a host microcontroller (trigger pulse), the sensor emits a short 40 kHz (ultrasonic) burst.
This burst travels through the air, hits an object and then bounces back to the sensor. The PING)))
sensor provides an output pulse to the host that will terminate when the echo is detected, hence the
width of this pulse corresponds to the distance to the target.
[[Obrázok:SensorPingTiming.png|right]]
== Example program ==
<source lang="c">
int pingPin = 11;
void setup()
{
  Serial.begin(9600);
}
void loop()
{
  long duration;
  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // We give a short LOW pulse beforehand to ensure a clean HIGH pulse.
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);
  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);
  Serial.print(duration);
  Serial.print("us");
  Serial.println();
  delay(100);
}
</source>
=== pulseIn() ===
'''Description'''
Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for
the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns
the length of the pulse in microseconds. Gives up and returns 0 if no pulse starts within a specified time out.
The timing of this function has been determined empirically and will probably show errors in longer pulses.
Works on pulses from 10 microseconds to 3 minutes in length.
'''Syntax'''
pulseIn(pin, value)
pulseIn(pin, value, timeout)
'''Parameters'''
pin: the number of the pin on which you want to read the pulse. (int)
value: type of pulse to read: either HIGH or LOW. (int)
timeout (optional): the number of microseconds to wait for the pulse to start; default is one second (unsigned long)
'''Returns'''
the length of the pulse (in microseconds) or 0 if no pulse started before the timeout (unsigned long)
== Connection ==
Interfacing to the microcontrollers is a snap: a single (shared) I/O pin is use to trigger the Ping sensor and "listen" for the echo return pulse.  An onboard three-pin header allows the PING))) to be plugged into a solderless breadboard (on an Acrob, for example), and to be connected to its host through a standard three-pin servo extension cable.
[[Obrázok:SensorPingConnection.png|center|600px]]
== Sources of errors ==
=== Air Temperature ===
Changing environmental conditions are the main source of the differences. Many quantities influences measurement
including temperature, humidity, turbulences, pressure and damping. Main source of error is air circulation and
temperature. Many equations appears in literature, two of them are mentioned here:<BR>
<math>
(1) \qquad    c = c_0 ( 1 + \gamma \vartheta )( 1 + A_V \eta ) 
</math>


Principle of operation
where
* <math>c_0</math> - speed of the sound at 0° C and 0% RH (c0 = 331,5 [m/s]),
* <math>\gamma</math> - temperature coefficient of the speed (@ 0° C), γ = 1.83 10-3 [°C-1],
* <math>A_V</math> - humidity constatnt (AV = 2,2 . 10^-4, for 50 ÷ 200 kHz),
* <math>\eta</math> - relative humidity of air [%],
* <math>\vartheta</math> - air temperature [°C].


[[Obrázok:SensorPingOperation.png|center]]
For practical purposes we can abandon humidity influences and then simplified formula applies:<BR>
<math>
(2)  \qquad  c = c_0 + 0,6 \vartheta  [m/s]
</math>


[[Obrázok:SensorPingTiming.png|center]]
The percent error over the sensor’s operating range of 0 to 70 ° C is significant, in the magnitude of 11
to 12 percent. The use of conversion constants to account for air temperature may be incorporated into
your program.


[[Obrázok:SensorPingConnection.png|center]]






Example program
[[Acrob010|< Previous]] | [[Acrob|Home]] | [[Acrob020|Next >]]

Aktuálna revízia z 09:54, 19. apríl 2011

< Previous | Home | Next >


Ultrasonic sensor for distance measurement

In following application we will use the Parallax PING))) Ultrasonic sensor.

Features:

  • Provides precise, non-contact distance measurements within a 2 cm to 3 m range
  • Simple pulse in/pulse out communication
  • Burst indicator LED shows measurement in progress
  • 20 mA power cosumption
  • Narrow acceptance angle

Key Specifications:

  • Power requirements: +5 VDC
  • Communication:Positive TTL pulse
  • Dimensions: 22 x 46 x 16 mm
  • Operating temp range: 0 to +70 °C


Principle of operation

The Ping sensor measures distance using sonar; an ultrasonic (well above human hearing) pulse is transmitted from the unit and distance-to-target is determined by measuring the time required for the echo return. Output from the PING))) sensor is a variable-width pulse that corresponds to the distance to the target.

The PING))) sensor detects objects by emitting a short ultrasonic burst and then "listening" for the echo. Under control of a host microcontroller (trigger pulse), the sensor emits a short 40 kHz (ultrasonic) burst. This burst travels through the air, hits an object and then bounces back to the sensor. The PING))) sensor provides an output pulse to the host that will terminate when the echo is detected, hence the width of this pulse corresponds to the distance to the target.

Example program

int pingPin = 11;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  long duration;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // We give a short LOW pulse beforehand to ensure a clean HIGH pulse.

  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.

  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  Serial.print(duration);
  Serial.print("us");
  Serial.println();

  delay(100);
}


pulseIn()

Description

Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. Gives up and returns 0 if no pulse starts within a specified time out.

The timing of this function has been determined empirically and will probably show errors in longer pulses. Works on pulses from 10 microseconds to 3 minutes in length.

Syntax

pulseIn(pin, value) pulseIn(pin, value, timeout)

Parameters

pin: the number of the pin on which you want to read the pulse. (int)

value: type of pulse to read: either HIGH or LOW. (int)

timeout (optional): the number of microseconds to wait for the pulse to start; default is one second (unsigned long)

Returns

the length of the pulse (in microseconds) or 0 if no pulse started before the timeout (unsigned long)

Connection

Interfacing to the microcontrollers is a snap: a single (shared) I/O pin is use to trigger the Ping sensor and "listen" for the echo return pulse. An onboard three-pin header allows the PING))) to be plugged into a solderless breadboard (on an Acrob, for example), and to be connected to its host through a standard three-pin servo extension cable.


Sources of errors

Air Temperature

Changing environmental conditions are the main source of the differences. Many quantities influences measurement including temperature, humidity, turbulences, pressure and damping. Main source of error is air circulation and temperature. Many equations appears in literature, two of them are mentioned here:

where

  • - speed of the sound at 0° C and 0% RH (c0 = 331,5 [m/s]),
  • - temperature coefficient of the speed (@ 0° C), γ = 1.83 10-3 [°C-1],
  • - humidity constatnt (AV = 2,2 . 10^-4, for 50 ÷ 200 kHz),
  • - relative humidity of air [%],
  • - air temperature [°C].

For practical purposes we can abandon humidity influences and then simplified formula applies:

The percent error over the sensor’s operating range of 0 to 70 ° C is significant, in the magnitude of 11 to 12 percent. The use of conversion constants to account for air temperature may be incorporated into your program.



< Previous | Home | Next >