DESCRIPTION
The Saleng – Tracker module is a compact reflective
infrared sensor module designed for detecting the
presence or absence of an IR reflective surface (e.g.
light or dark line) in front of its optical elements. The
module uses the TCRT5000 IR pair while its output is fed
to a Schmitt triggered gate producing reliable digital
output. It has a Digital Output pin labeled DO and
another with an inverted output signal labeled ~DO. DO
is high when a reflective surface (e.g. white surface)
comes within range and thereby reflecting back the
emitter’s IR beam back to the IR receiver on the board.
DO is low when no reflective surface (e.g. dark surface)
is detected. ~DO’s output is the inverse of DO. The
absence of a sensitivity/calibration adjustment
potentiometer makes this module easy to use with its
digital outputs optimized for dark/light line detection in
robotic applications. An Analog Output pin named AO is
also available and is tied to the output of the photo
diode. This may be useful for distance or obstacle
sensing. The tracker module is part of Layad Circuits’
Saleng series of innovation-starter products.

  • FEATURES
  •  Detector Type: Phototransistor
  •  Input Voltage: 3.3V – 5V
  •  Typical Current Consumption: <40mA
  •  Peak Current (Vin=5V): 80mA
  •  Digital Output Effective Distance Range: ~10mm
  •  Analog Output Effective Distance Range:
  • ~100mm
  •  Emitter Wavelength: 950nm
  •  Daylight Blocking Filter
  •  Digital Output with Inverted Output
  •  Analog Output
  •  Small form factor, board dimensions: 15x38mm
  • TYPICAL APPLICATIONS
  •  Line Following Robot
  •  Limit Sensor
  •  Object Counter
  •  Speed Mater / Tachometer
  •  General Obstacle sensing
  •  Distance Sensing

APPLICATION NOTES
Line Tracing/Line Follower Robot
The Saleng – Tracker module may be used with a
microcontroller based mobile robot to quickly detect
light and dark surfaces. The module maybe installed
under the chassis at a distance of about 1cm from the
floor. Only the DO (or the ~DO if you need an inverted
logic e.g. low when reflections are detected) is needed
in this case. The AO may be left unconnected.

const byte salengTrackerDO = 2;   
const byte led= 13;    
void setup() 
{ 
Serial.begin(115200); 
pinMode(salengTrackerDO, INPUT);       
pinMode(led, OUTPUT);           
}
void loop() 
{ 
if(digitalRead(salengTrackerDO) == HIGH) 
{ 
digitalWrite(led,HIGH);      
// if a reflective surface is  
// detected then turn LED on 
Serial.println("Light!"); 
} 
else 
{ 
digitalWrite(led,LOW);       
// if no reflective surface is  
// detected then turn LED off 
Serial.println("Dark!"); 
} 
}

It goes without saying that if a mobile robot is involved,
the above sketch will need to include the motor control
algorithm.
Distance or Obstacle Sensing with the Analog Output
2
The Saleng-Tracker module has an analog output with a
voltage that is approximately proportional to the
distance of a reflector in front of the optical elements.
Typically, the sensor is effective when the reflective
surface is at around 100mm (10cm) of the optical
elements. In actual test using an ordinary white paper
as reflector and an Arduino, there are detectable
changes in voltage up to around 200mm (20cm).
Take note though that the analog output voltage does
not have a linear relationship with distance. It is advised
to perform actual experiments to obtain a calibration
curve or look up table.

In actual tests, the typical maximum useable distance
range is 15 to 20mm. To be on the safe side, a 10mm or
lower floor-to-optical sensor distance is advised.
Because the digital output come from Schmitt triggered
gates, DO and ~DO will readily work with a 5V or 3.3V
microcontroller.
Example Saleng Uno/ Arduino Code following figure 2
wiring to demonstrate line tracking ability:

Example Saleng Uno/Arduino Code following figure 3 – Upload and open serial monitor, set to 115200 baud rate.

const byte salengTrackerAO = A0;  // connect Saleng Tracker AO to pin A0 of the Arduino 
int trackerValue;                 
// store the analog output values here 
void setup() 
{ 
Serial.begin(115200); 
} 
} 
void loop() 
{ 
trackerValue = analogRead(salengTrackerAO); 
// The following approximates the distance of the object. Note that the 
// values in this code are approximate and may change with each 
// application. External factors like IR sources (e.g. sunlight) will affect these values. 
// Upload this code and test on your actual setup 
if(trackerValue <= 50) Serial.println("Object is around 1cm from sensor"); 
else if(trackerValue <= 650) Serial.println("Object is around 2cm from sensor"); 
else if(trackerValue <= 800) Serial.println("Object is around 4cm from sensor"); 
else if(trackerValue <= 845) Serial.println("Object is around 6cm from sensor"); 
else if(trackerValue <= 980) Serial.println("Object is around 8cm from sensor"); 
else if(trackerValue <= 1000) Serial.println("Object is around 9cm from sensor"); 
else Serial.println("Object is around 10cm or farther from sensor");

mple tachometer / speed meter using Digital Output
A basic tachometer can be implemented using an
external interrupt pin of the Saleng Uno/Arduino and
DO output of the Saleng Tracker. The installation must
be such that the Saleng Tracker comes in close contact
with the rotating obstacle (not dark in color) one or
more times per revolution. In the case of a fan for
example, if the blades are dark , a light colored
tape/paint may be placed on one of the blades. The
sensor module should be positioned to come in range of
the tape every revolution. See figure 4.

Example Saleng Uno/Arduino Code for a tachometer application.
Saleng – Tracker
User Guide
The wiring for this example follows figure 2 and the mechanical installation follows figure 4. If the blades of the fan are
able to reflect IR, leave it as it is without tape but remember to divide the RPM with the total number of pulses (blades)
per revolution. The code example only detects rising edges so the final RPM of a 3 bladed fan should be rpm = rpm/3; .
Care should be taken to ensure that exact number of pulses are produced per revolution. The following example
assumes one pulse per revolution. Upload and then open the serial monitor at 115200 baud rate to view the results

const byte salengTrackerDO = 2;
volatile unsigned long revCount; // this saves the number of revs detected.
unsigned long rpm;
// holds the computed speed in revolutions per minute
unsigned long totaltime;
unsigned long prevtime;
void revs()
{
revCount++;
// saves the time interval from last calculation
// saves last time we calculated
//increment this everytime an obstacle is detected
digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN)); // toggle the LED on board every rev.
}
void setup() {
Serial.begin(115200);
pinMode(salengTrackerDO, INPUT);
pinMode(LED_BUILTIN,OUTPUT);
// set pin 2 as an input
// enable external interrupt on pin 2.
// Set the ISR function (revs()) on every rising edge
attachInterrupt(digitalPinToInterrupt(salengTrackerDO), revs, RISING);
}
void loop() {
delay(1000);
// temporarily disable the interrupt to allow computation
detachInterrupt(digitalPinToInterrupt(salengTrackerDO));
totaltime = millis() – prevtime;
rpm = revCount*60000/totaltime;
revCount = 0;
prevtime = millis();
}
// set the LED on board as an output
// RPM = rev/1 minute. 1 min = 60000ms
// done computing so reset revs count
// save last time we did the calculations
attachInterrupt(digitalPinToInterrupt(salengTrackerDO), revs, RISING); // re-enable interrupt
Serial.print(“RPM=”);
// display results on screen
Serial.println(rpm);

Similar Posts