Capability:Line Sensing

From Bespoke Robot Society
Jump to navigation Jump to search
Line Sensing
Type Sensing
Measures/Controls Light vs dark surface contrast using infrared reflectance
Common Hardware Infrared Line Detector modules, QTR sensor arrays (Pololu), TCRT5000 sensors
Enables Activities Activity:Line Following, edge detection, contrast-based navigation
Used In SimpleBot
Status Fully Documented


Line Sensing is a capability that enables robots to detect and distinguish between light and dark surfaces using infrared (IR) reflectance sensors. This fundamental sensing technique allows robots to follow lines, detect edges, and navigate based on surface contrast patterns.

How IR Reflectance Sensing Works

Line sensing relies on the principle that different colored surfaces reflect infrared light differently:

  1. An IR LED (typically 940nm wavelength) emits infrared light toward the surface below the sensor
  2. The light reflects off the surface back toward the sensor
  3. An IR phototransistor or photodiode detects the intensity of the reflected light
  4. Dark surfaces (especially black) absorb more IR light and reflect less back to the sensor
  5. Light surfaces (especially white) reflect more IR light back to the sensor
  6. The sensor circuit converts this difference in reflected light intensity into an electrical signal

The greater the contrast between the line and the background surface, the easier it is for the sensor to distinguish between them. Black electrical tape on a white surface provides excellent contrast for line following applications.

Hardware Options

Single IR Modules

Pre-assembled modules containing an IR LED and phototransistor pair with onboard signal conditioning:

  • Typical sensing distance: 2-10mm from surface
  • Often include adjustable potentiometer for threshold calibration
  • Output: Digital (HIGH/LOW) or analog voltage
  • Examples: TCRT5000 modules, generic IR line detector modules
  • Advantages: Simple to use, low cost, good for basic line following
  • Best for: Simple robots like SimpleBot that need 2-3 sensors

QTR Sensor Arrays

Multiple IR sensors arranged in a single module (Pololu QTR series):

  • Available in 1-16 sensor configurations
  • Closer sensor spacing for precise line tracking
  • Often use RC (resistor-capacitor) timing method for analog readings
  • Examples: QTR-8RC, QTR-3A, QTR-1A
  • Advantages: Compact, consistent calibration, interpolation between sensors
  • Best for: Advanced line following, position estimation, maze solving

Custom Designs with Discrete Components

Building sensors from individual components:

  • IR LED (940nm wavelength most common)
  • IR phototransistor (e.g., LTR-301) or photodiode
  • Current-limiting resistor for LED (typically 100-330Ω)
  • Pull-up or pull-down resistor for phototransistor
  • Optional comparator IC (e.g., LM393) for digital output
  • Advantages: Complete control over specifications, lowest cost at scale
  • Challenges: Requires PCB design, component selection, testing

Common Components

IR LEDs

  • Wavelength: 940nm (standard for line sensing applications)
  • Forward voltage: ~1.2-1.5V
  • Forward current: 20-50mA typical
  • Viewing angle: 20-40° (narrower beam focuses light better)

IR Phototransistors

  • Peak sensitivity: 850-950nm (matches IR LED emission)
  • Response time: Fast enough for mobile robots (<100μs)
  • Dark resistance: Very high (MΩ range)
  • Light resistance: Low (kΩ range when illuminated)

Comparator ICs

  • LM393: Dual comparator, common in digital output modules
  • LM339: Quad comparator, for multi-sensor arrays
  • Provides clean digital switching between HIGH/LOW states
  • Adjustable threshold via potentiometer voltage divider

Output Types

Digital Output

Threshold-based detection:

  • Output is HIGH when sensor detects light surface (above threshold)
  • Output is LOW when sensor detects dark surface (below threshold)
  • Threshold adjusted via potentiometer on sensor module
  • Simple to read with digital input pins
  • Binary decision: on line or off line
  • No gradual information about line position

Analog Output

Continuous voltage values:

  • Output voltage varies continuously with reflected light intensity
  • Requires analog input (ADC) on microcontroller
  • Provides gradual information about line position
  • Enables interpolation between sensors for smoother tracking
  • More processing required but better position estimation
  • Allows adaptive threshold adjustment in software

Calibration Requirements

Proper calibration is essential for reliable line detection:

Hardware Calibration

For sensors with onboard potentiometers:

  1. Place sensor over white (light) surface
  2. Adjust potentiometer until output LED turns ON (or output goes HIGH)
  3. Place sensor over black (dark) line
  4. Verify output LED turns OFF (or output goes LOW)
  5. Fine-tune threshold to trigger reliably between surfaces
  6. Test at expected operating height above surface

Software Calibration

For analog sensors or adaptive systems:

  1. Sample sensor values over white surface (maximum reading)
  2. Sample sensor values over black line (minimum reading)
  3. Calculate threshold: typically (max + min) / 2
  4. Store calibration values in EEPROM or configuration
  5. Periodically re-calibrate if ambient conditions change
  6. Consider dynamic calibration during operation

Sensor Placement Considerations

Height Above Surface

Critical distance parameter:

  • Too close: Small surface imperfections cause false readings
  • Too far: Reduced contrast sensitivity, wider sensing spot
  • Optimal range: 2-5mm for most modules
  • TCRT5000: 2.5mm optimal distance
  • QTR sensors: 3mm typical mounting height
  • Use adjustable mounting for fine-tuning during testing

Spacing Between Sensors

For multiple sensor configurations:

  • Line width considerations: Sensors should span expected line width
  • Narrow spacing: Better position resolution, more complex logic
  • Wide spacing: Covers more area, simpler edge detection
  • Common spacing: 8-10mm for standard black tape (19mm width)
  • Two-sensor configuration: Space wider than line width for edge detection
  • Array configuration: Sensors spaced to keep line under multiple sensors

Physical Mounting

  • Mount sensors perpendicular to surface (avoid angle skew)
  • Rigid mounting prevents vibration-induced noise
  • Shield sensors from ambient light (side walls or recessed mounting)
  • Keep mounting structure away from IR LED/phototransistor optical path
  • Consider adjustable mounting brackets for height calibration

Environmental Factors

Ambient IR Light

External IR sources can interfere:

  • Sunlight contains significant IR radiation
  • Incandescent bulbs emit IR
  • Other robots' IR sensors in close proximity
  • Solutions: Modulate IR LED at specific frequency, use shielding, filter ambient light

Surface Texture

Physical properties affect reflectance:

  • Smooth surfaces reflect more consistently
  • Rough/textured surfaces scatter light
  • Fabric or carpet may require closer sensor placement
  • Test on actual surface where robot will operate

Glossy vs Matte Surfaces

Surface finish affects readings:

  • Glossy surfaces: Specular reflection (angle-dependent)
  • Matte surfaces: Diffuse reflection (more consistent)
  • Glossy black tape may reflect more than matte white paper
  • Use matte black tape for most predictable line following

Color Considerations

IR reflectance differs from visible light reflectance:

  • Some colors that appear different to humans reflect IR similarly
  • Red surfaces often reflect IR strongly despite appearing dark
  • Blue surfaces may reflect less IR than their visible brightness suggests
  • Always test with actual materials, not assumptions based on color

Used in SimpleBot

The SimpleBot implements line sensing with the following configuration:

  • Hardware: Two Infrared Line Detector modules
  • Mounting: Adjustable bracket allows height calibration
  • Spacing: Sensors positioned to straddle standard line width
  • Output type: Digital (threshold-based detection)
  • Calibration: Onboard potentiometers for threshold adjustment
  • Application: Activity:Line Following with edge detection strategy

The two-sensor configuration enables SimpleBot to:

  • Detect when left sensor is over the line
  • Detect when right sensor is over the line
  • Determine robot position relative to line
  • Make steering corrections to stay on course
  • Detect sharp turns and line intersections

This simple but effective arrangement demonstrates core line sensing principles while remaining accessible for educational and maker applications.

See Also