Description
Distance Sensor with Pulse Width Output 50cm Max
This compact sensor makes it possible to measure the distance of objects up to about 50 cm (20″) away using a simple digital pulse width interface. It uses a short-range lidar module to precisely measure how long it takes for emitted pulses of infrared, eye-safe laser light to reach the nearest object and be reflected back, allowing for 3 mm resolution.
As long as the sensor is enabled, it takes continuous distance measurements and encodes the ranges as the widths of high pulses, which can then be timed by a microcontroller using a single digital input.
The relationship between measured distance d (in mm) and pulse width t (in µs) is shown below:
The timing uncertainty is approximately ±5%. As objects approach the sensor, the output pulse width will approach 1.0 ms, while an object detected at 50 cm will produce a 1.667 ms pulse width. The sensor uses a pulse width of 2.0 ms to indicate no detection. The pulse period T ranges from around 9 ms to 20 ms, depending on the proximity of the detected object.
The maximum detection range depends on object reflectivity and ambient lighting conditions. In tests, this sensor was able to reliably detect a white sheet of paper at an approximate distance of 50cm and a hand at approx. 30cm.
This graph shows the measured distances of five units versus their actual distances at several different ranges:
This sensor can detect objects almost up to the face of the sensor, however, the effective minimum distance it can measure is around 1 cm. This means that objects closer than 1 cm may still result in a measured distance of around 1 cm.
Using a camera with no IR filter, we can see the infrared light being emitted by the distance sensor as below:
Specifications:
- Operating voltage: 3.0 V to 5.5 V
- Current consumption: 30 mA (typical) when enabled, 0.4 mA when disabled
- Maximum range: approximately 50 cm (20″) (for high-reflectivity targets in good ambient conditions; lower-reflectivity targets or poor ambient conditions will reduce the maximum detection range)
- Update rate: 50 Hz to 110 Hz (20 ms to 9 ms period)
- Field of view (FOV): 15° typical; can vary with object reflectance and ambient conditions
- Output type: digital pulse width
Distance Sensor Dimensions:
- Board Length: 21.6mm (0.85″)
- Board Width: 8.9mm (0.35″)
- Overall Thickness: 3.1mm (0.122″)
- Weight: 0.4g
Configuration of the Sensor:
Using the PWM Distance Sensor with Arduino:
[code lang="arduino"]
// Example Arduino program for Distance Sensor with Pulse Width Output 50cm Max
// Change this to match the Arduino pin connected to the sensor's OUT pin.
const uint8_t sensorPin = 2;
void setup()
{
Serial.begin(115200);
}
void loop()
{
int16_t t = pulseIn(sensorPin, HIGH);
if (t == 0)
{
// pulseIn() did not detect the start of a pulse within 1 second.
Serial.println("timeout");
}
else if (t > 1850)
{
// No detection.
Serial.println(-1);
}
else
{
// Valid pulse width reading. Convert pulse width in microseconds to distance in millimeters.
int16_t d = (t - 1000) * 3 / 4;
// Limit minimum distance to 0.
if (d < 0) { d = 0; }
Serial.print(d);
Serial.println(" mm");
}
}
[/code]
Using the Distance Sensor with the BBC micro:bit:
We have also created a MakeCode example program for the BBC micro:bit single-board computer that demonstrates how to read and convert the output of the Pololu Distance Sensor with Pulse Width Output, 50cm Max. The program’s output can be viewed in the MakeCode device console, which also plots the readings on a graph. You can open this program directly in the MakeCode editor here or by re-creating from the image below:The Pololu Digital Distance Sensor Family:
Sensors with Digital Output (ie no distance measurement):
Sensor Variation | Max. Range | Min. Update Rate | Jumper Settings (4321) |
#4050: Digital output, 5cm | 5 cm | 145 Hz | 0 |
#4052: Digital output, 10cm | 10 cm | 115 Hz | 10 |
#4054: Digital output, 15cm | 15 cm | 95 Hz | 100 |
Sensors with Pulse Width (ie with distance measurement):
Sensor Variation | Max. Range | Min. Update Rate | Jumper Settings (4321) |
50 cm | 50 Hz | 1110 |