Using QTR-8RC sensor as to measure velocity

Hi,

I am a mechanical engineering student and have next to no experience with writing code or dealing with microcontrollers so I could really use the help. For my sensor design project we have to develop a velocity sensor that can go inside of a printer. This sensor is being used to measure the velocity of paper while exiting through a set of rollers inside the printer. For the project we have decided to use the 2 array section of the QTR-8RC sensor that can be broken off of the circuit board. Essentially we want to be able to use this two sensor section to measure the leading edge velocity of the paper by using the paper to “trip” of “pick up” the leading edge of the white paper as it goes over the first then the second sensor on the QTR. We want to be able to measure the time that it takes for the second sensor to be tripped after the first sensor is tripped and then use this time along with the distance between the sensors (we have that) to find the velocity.

I have the code that I have modified from an example with the QTR-8RC but I don’t understand what to do with the output that I get from the Arduino microcontroller. I have attached the code and what I get for the output. I’m not an idiot, this is just not my area of expertise so PLEASE HELP.

From what I understand there are 3 numbers displayed after the calibration, x, y, and z.
[xy_z]
The x and y is some number(0-10) that displays the relative positioning between the two sensors, and the z is some number (0-1000) that is some percentage of light being reflected back or some distance away from the surface being reflected. I need help getting this into usable data or a better way to do it if I am on the wrong path completely.

Thanks
Brandon
------------------------------------CODE-------------------------------------
#include <QTRSensors.h>
#define NUM_SENSORS 2 // number of sensors used
#define TIMEOUT 2500 // waits for 2500 us for sensor outputs to go low
#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2

// sensors 0 through 7 are connected to digital pins 3 through 10, respectively
QTRSensorsRC qtrrc((unsigned char[]) {9, 10},
NUM_SENSORS, TIMEOUT, EMITTER_PIN);
unsigned int sensorValues[NUM_SENSORS];

void setup()
{
delay(500);
int i;
//-------no need to turn on calibration LED for the 2 sensor array-----------
//-- pinMode(13, OUTPUT);
//-- digitalWrite(13, HIGH); // turn on LED to indicate we are in calibration mode

for (i = 0; i < 400; i++) // make the calibration take about 10 seconds
{
qtrrc.calibrate(); // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call)
}
//-- digitalWrite(13, LOW); // turn off LED to indicate we are through with calibration

// print the calibration minimum values measured when emitters were on
Serial.begin(9600);
for (i = 0; i < NUM_SENSORS; i++)
{
Serial.print(qtrrc.calibratedMinimumOn[i]);
Serial.print(’ ');
}
Serial.println();

// print the calibration maximum values measured when emitters were on
for (i = 0; i < NUM_SENSORS; i++)
{
Serial.print(qtrrc.calibratedMaximumOn[i]);
Serial.print(’ ');
}
Serial.println();
Serial.println();
delay(1000);
}

void loop()
{
// read calibrated sensor values and obtain a measure of the line position
// from 0 to 5000, where 0 means directly under sensor 0 or the line was lost
// past sensor 0, 1000 means directly under sensor 1, 200 means directly under sensor 2, etc.
// Note: the values returned will be incorrect if the sensors have not been properly
// calibrated during the calibration phase. To get raw sensor values, call:
// qtra.read(sensorValues);
unsigned int position = qtrrc.readLine(sensorValues);

//qtrrc.read(sensorValues);

// print the sensor values as numbers from 0 to 9, where 0 means maximum reflectance and
// 9 means minimum reflectance, followed by the line position
unsigned char i;
for (i = 0; i < NUM_SENSORS; i++)
{
Serial.print(sensorValues[i] * 10 / 1001);
Serial.print(’ ');
}
Serial.print(" ");
Serial.println(position);

delay(250);
}

---------------------------OUTPUT FROM SERIAL MONITOR--------------------------
104 180
2500 2500

1 0 0
2 1 414
0 1 0
0 0 0
0 1 0
5 3 378
1 0 0
1 5 800
6 0 106
5 1 160
1 5 781
1 0 1000
9 1 148
0 3 809
1 0 1000
9 1 165
…etc.

Hi, Brandon.

I think that the way you are going about figuring this out seems more complicated than it needs to be. I suggest writing a program to:

Wait for the first sensor to detect the paper, then start a timer.

Wait for the second sensor to detect the paper, then stop and read the timer.

Divide the distance between the sensors by the time and print the result.

Trying to modify a much more complex program down to fit what you want is going to be difficult. I recommend doing each smaller part of the program individually first and then tying them together at the end.

-Derrill