QTRX Sensors A vs. RC

I recently bought a handful of the QTRX digital (RC) sensors.I was playing with the code and there is a time set for the “die away” time. The sample code had this at 2500 ms - my test case I could get this down to about 200 ms and still detect the change in reflectance. My situation is this - we’re building a sumo robot that will be ramming orthogonal to a 2.5 cm line (black surface, 2.5cm white line) at about 50 cm/sec (I hope!). I worry that this sensor may not be quick enough to see the line before we’re off the board. I estimate there will be about 3 cm between the sensors and the wheels. My question is this - are the analog or digital sensors faster in this condition? The RC sensors need 200-300 ms to measure the die away. I don’t have any analog to play with the analog sample rate. And the change in reflectance should be quite strong (black to white). I’m thinking I probably should go with analog?? thoughts??

Are you running the emitters at full brightness? Brighter emitters will produce a quicker response time. Also, if you have the flexibility to mount the sensors closer to the surface, that would make the response time quicker.

The analog sample rate is going to depend mostly on the speed of the analog-to-digital converter (ADC) you are using. If you are using an Arduino board, you might be interested in this blog post I found that goes into some depth about the timing of the analogRead() function on a board that uses the ATmega328 microcontroller’s built in ADC.

That post lists that read time as 111us, so that would be much faster than the 200-300ms you mention in your post. By the way, it should be totally possible to replace the 2.2nF capacitor on the sensor board with a lower capacitance one to decrease the charge and discharge times, though replacing SMT components like that requires some soldering skills. Also, it seems like a circuit with a capacitor small enough to get the timing down to 111us might not produce very consistent results.



Thanks for the quick reply and the great suggestions. I’m trying to ensure that I have the maximum brightness. I wrote a little code to output the sensor readings as well as the DimmingLevel. I don’t see any difference when I change the setDimmingLevel between 0 and 30, so maybe I’m doing this wrong. This is about as simple as I can make the code, does it look correct? (I also drop the 2500 value down to 200 or 150 to speed up the reading):

#include <QTRSensors.h>

QTRDimmableRC qtrrc((unsigned char[]) {2}, 1, 2500, QTR_NO_EMITTER_PIN);
unsigned int sensorValues[1];
unsigned int dim;

void setup()
  Serial.begin(9600); // set the data rate in bits per second for serial data transmission

void loop()
  // read raw sensor values
  dim = qtrrc.getDimmingLevel();


Thanks in advance,

If you want to use dimming, you have to have the CTRL pin connected and specify the pin when you create the QTRDimmableRC object. If you do not connect that pin, the board will be at its brightest setting all of the time, which sounds OK for your application.


OK … thanks. I thought the CTRL pin just turned things on and off, but that makes sense. I’ll probably stick with this set up since a continuous scan with an analog sensor slows down the rest of the code (I read most of your article and maybe I’ll try RC sensors with an ADC interrupt after I get the rig built). I’ll just set a “search_speed” for the bot that keeps it under control to see the edge (that’s kind of what your Zumo code does) - but I’ll add a “ram_speed” for the right conditions to take advantage of our power and speed.
I love Pololu! the products and the support are really great!
Thanks again

1 Like