Demand Peripherals     Robotics and Automation Made Easy

QTR: Quad/Octal Pololu QTR Interface

The QTR4/QTR8 peripherals provide an interface to the Pololu digital QTR sensors.



The qtr4 and qtr8 provides four and eight channels of input from a Pololu QTR-RC sensor. The sensors work by charging a capacitor to Vcc (3.3 volts in our case) and monitoring the capacitor discharge. The discharge rate depends on the amount of IR light reflected off a surface and onto a phototransistor. A sensor is considered light if the capacitor has discharged below the logic 1 level of the FPGA and is considered dark if the voltage is still above the logic 1 level. Sensitivity is controlled by a delay in reading the inputs. The longer the delay, the longer the cap can discharge. Sensitiviy is in units of 10us but since the discharge of a capacitor is exponential the sensitivity is very non-linear. Sensitivity in the range of 5 to 25 seems to work fairly well. Wire each output of the QTR sensor directly to an FPGA pin. Be sure to wire the sensor for 3.3 volt operation.



The QTR peripheral lets you select the update period as well as the sensitivity of the sensor. Sensor output is available using dpcat.

qtrval : A one or two hex digits followed by a newline to indicate the state of the QTR sensors. A set bit indicated a dark sensor and a cleared bit indicates a lighted sensor.

update_period : Update period for the qtrval resource in tens of milliseconds. That is, the dpcat command can select() on qtrval will give a readable file descriptor every update_period milliseconds. Setting this to zero turns off all output from the sensor. The update period must be between 0 and 150 milliseconds in steps of 10 milliseconds. That is, valid values are 0, 10, 20, 30, 40, ... 140, or 150.

sensitivity : The light sensitivity as a number between 1 and 250. Higher values give the sensor capacitor more time od discharge down to a logic 0 level. Sensitivity specified the number of 10 microsecond intervals to wait before reading the sensor outputs. The discharge curve of a capacitor is very non-linear so the sensitivity has no meaningful units of measure.



Set the sample rate to 50 milliseconds and the sensitivity to mid-range.

  dpset qtr8 update_period 50
  dpset qtr8 sensitivity 20
  dpcat qtr8 qtrval


Hardware Tips:

The octal QTR sensor and the BB4 connectors are almost compatible. Of the sixteen pins four are in conflict. If you mount a sixteen pin male header onto the QTR sensor horizontally you may be able to remove the four conflicting pins prior to attaching the connector. The table below shows the four pins in conflict.

1 Gnd * LED
2 D0 D0
3 V3.3 Vcc
4 D1 D1
5 Gnd Gnd
6 D2 D2
7 V5.0 * Gnd
8 D3 D3
9 Gnd Gnd
10 D4 D4
11 V3.3 * Gnd
12 D5 D5
13 Gnd Gnd
14 D6 D6
15 V5.0 * Gnd
16 D7 D7
* Remove these pins


FPGA Defined Peripherals
User Interface
FPGA Configuration
FPGA Buttons & LEDs
AVR Interface
Stereo Audio Amplifier
Text LCD and Keypad
Quad WS2812 Interface
Quad Slide Pot
IR Recv/Xmit
6 Digit LCD
RC Decoder
Keyfob RF Decoder
Rotary Encoder Interface
Quad Touch Interface
Motion Control
Dual DC Motor Controller
Dual Quadrature Decoder
Quad 13 Bit Servo
Bipolar Stepper Controller
Unipolar Stepper Controller
Simple Input / Output
Quad Binary Output
Quad Binary Input
Octal Input/Output
32 Channel Binary Output
32 Channel Binary Input
Octal 12-bit ADC
Quad Ping))) Interface
Pololu QTR Interface
Octal SRF04 Interface
Generic I2C
Generic SPI
Octal 8-Bit DAC
Quad Digital Potentiometer
Quad PWM Output
Quad PWM Input
Quad Event Counter
Real Time Clock

Interface Cards
Control Cards
User Interface
Stereo Audio Amplifier
IR Recv/xmit
Six Digit LCD Display
Keyfob RF Receiver
Rotary Encoder
Quad Switch Card
Text LCD / keypad
Quad Slide Pot
Quad Touch Interface
Motion Control
Dual 7-amp H-bridge
Quad Open Drain Driver
Quad 10 Amp Relay Card
Input / Output
Octal 8-Bit DAC
Quad Digital Potentiometer
Octal 12-bit ADC
Octal SRF04
I2C Prototyping
SPI Prototyping
USB 2.0 Hub
Real Time Clock
Octal Input/Output
32 Channel Input
32 Channel Output
Power Distribution Card
15 Amp Power Distribution
5 Volt Switching Regulator
ATX Power Break-Out Card
Disk Drive Power Break-Out
MP43 Aluminum Mounting Plate
WW4 Large Prototyping Card
WW2 Prototyping Card
WW1 Small Prototyping Card
SMP SMD Prototyping Card