User Manual
16. QTR Reflectance Sensors
The PololuQTRSensors class and the C functions in this section provide an interface for using Pololu’s QTR
reflectance sensors [https://www.pololu.com/product/961] together with the Orangutan. The library provides access
to the raw sensors values as well as to high level functions including calibration and line-tracking.
We recommend not using this part of the library directly on the 3pi. Instead, we have provided an
initialization function and convenient access functions through the Pololu3pi class. See Section
19 for details.
This section of the library defines an object for each of the two QTR sensor types, with the
PololuQTRSensorsAnalog class intended for use with QTR-xA sensors and the PololuQTRSensorsRC class
intended for use with QTR-xRC sensors. This library takes care of the differences between the QTR-xA
and QTR-xRC sensors internally, providing you with a common interface to both sensors. The only external
difference is in the constructors. This is achieved by having both of these classes derive from the abstract base
class PololuQTRSensors. This base class cannot be instantiated.
The PololuQTRSensorsAnalog and PololuQTRSensorsRC classes are the only classes in the Pololu AVR
library that must be instantiated before they are used. This allows multiple QTR sensor arrays to be controlled
independently as separate PololuQTRSensors objects. The multiple independent array support is not available
within the C environment, but multiple arrays can still be configured as a single array, as long as the total number
of sensors does not exceed 8.
For calibration, memory is allocated using the malloc() command. This conserves RAM: if all eight sensors are
calibrated with the emitters both on an off, a total of 64 bytes would be dedicated to storing calibration values.
However, for an application where only three sensors are used, and the emitters are always on during reads, only
6 bytes are required.
Note that the PololuQTRSensorsRC class uses Timer2 during sensor reads to time the sensor pulses, so it might
not work with code that uses Timer2 for other purposes. Once the sensor read is complete, Timer2 is restored
to its original state; there are no restrictions on its use between sensor reads. The PololuQTRSensorsAnalog
class does not use Timer2 at all, and all of the PololuQTRSensors code is compatible with the other Pololu AVR
libraries.
Note: This library is implemented differently for use on Arduinos. Please install the Arduino-
specific version [https://www.pololu.com/docs/0J19] if you want to use QTR sensors with the Arduino.
For a higher level overview of this library and example programs that show how this library can be used, please
see Section 3.k of the Pololu AVR C/C++ Library User’s Guide [https://www.pololu.com/docs/0J20].
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
16. QTR Reflectance Sensors Page 53 of 65