QRE1113 sensor works in analog mode but not digital mode.

Thread Starter

spinnaker

Joined Oct 29, 2009
7,837
I am trying to build an RPM meter for my CNC machine. I have chosen the QRE1113 sensor to hopefully detect a line painted on my spindle.

Sparkfun has the break out boards but I have the senors so I am attempting to build one based on their design.

They have two configurations. Analog and digital. I can get the analog configuration working but not the "digital" configuration.

In the analog configuration, I am reading OV on out. If I put a 10k resistor in parallel with C1 (basically making it the analog configuration) the device works fine. Any idea what I could be doing wrong in the digital version?

upload_2017-1-13_17-49-28.png


I am wondering if I want analog configuration anyway since I will want a fast response from the sensor.


Edit: My supply is 5VDC. I went with a 180 ohm resistor for the current limiting resistor for the diode..
 

Attachments

Last edited:

crutschow

Joined Mar 14, 2008
23,810
The device is simply a photo diode with a photo transistor.
What is the difference between the "analog version" and the "digital version"?
What makes you think the "digital version" doesn't require a bias resistor?
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,837
Ahh! The secret is in the code.


I don't know Arduino but it looks to me like they are setting the output high then reading it. This might not work for me since I need a very fast response.


int readQD(){
//Returns value from the QRE1113
//Lower numbers mean more refleacive
//More than 3000 means nothing was reflected.
pinMode( QRE1113_Pin, OUTPUT );
digitalWrite( QRE1113_Pin, HIGH );
delayMicroseconds(10);
pinMode( QRE1113_Pin, INPUT );

long time = micros();

//time how long the input is HIGH, but quit after 3ms as nothing happens after that
while (digitalRead(QRE1113_Pin) == HIGH && micros() - time < 3000);
int diff = micros() - time;

return diff;
}
 

crutschow

Joined Mar 14, 2008
23,810
I never said anything about a bias resistor.
No, but you showed a bias resistor with the analog version and only a capacitor with the digital.
But yes, in the "digital" version they are apparently applying a voltage to the circuit through a resistor and then reading the voltage value to see if it's high or low.
The same can be achieved with the "analog" version if the resistor value is large enough so that the reflected signal saturates the phototransistor.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,837
Are they connecting it to the ADC on Arduino board? Is that how they are converting analog signal to digital?

They do it two ways. "Analog version" they use the analog port to read a value. "Digital version" they apply a high to the output then read the value.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,837
I got it to work sort of. I replaced R2 with a 20K instead of a 10K resistor.


I have a pattern that I printed out.

upload_2017-1-13_21-13-35.png

I am not sure how these things are supposed to work. I need to make contact with the paper or the transistor remains on. Ambient light is keeping it on, is my assumption.
If I run the sensor over the paper, I see a low where the while region is and high for black. Sort of counter what I am seeing with the ambient light.

I might try searching on youtube as these things are pretty popular with line following robots. I can't imagine the sensor needs to come in contact with the lien.
 

djsfantasi

Joined Apr 11, 2010
5,848
After the code sets the pin high, the code times how long the capacitor has a charge that is greater than or equal to a high. If the digital version does not charge the capacitor, due to insufficient current or too high a resistance - then it won't work.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,837
After the code sets the pin high, the code times how long the capacitor has a charge that is greater than or equal to a high. If the digital version does not charge the capacitor, due to insufficient current or too high a resistance - then it won't work.

Yes I am aware. I don't want to have to charge the cap and wait.

I am trying to figure out how to make the analog version work as digital. I can get it to work but I need to make contact with the paper to get full transition. Without contact I only get a difference of a few tenths of a volt from 4.4 volts low to 4.8 volts high.

I will need 0 to 5V.
 

crutschow

Joined Mar 14, 2008
23,810
As can be seen from this graph taken from the data sheet, the transistor output falls rapidly as the distance from the reflective object increases.

upload_2017-1-13_19-31-59.png
I suggest you try increasing the value of resistor R2 until you get a better response.
Ambient light will, of course, also turn on the transistor so you have to allow for that.
A deep red (IR) light filter in front of the transistor sensor can help minimize the effect of ambient light.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,837
A deep red (IR) light filter in front of the transistor sensor can help minimize the effect of ambient light.
Any idea where I would get such a thing other than a camera shop?


I know I have seen plastic sheets of the stuff but trying to remember where. A kids toy comes to mind for some reason.
 

crutschow

Joined Mar 14, 2008
23,810
Any idea where I would get such a thing other than a camera shop?
Not offhand.
It's not easy to find.
I heard that developed, unexposed color slide film will work, but that's kind of hard to come by these days. :rolleyes:
Otherwise, all I can suggest is a Google search.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,837
Not offhand.
It's not easy to find.
I heard that developed, unexposed color slide film will work, but that's kind of hard to come by these days. :rolleyes:
Otherwise, all I can suggest is a Google search.

Damn and I think I just threw an old roll out. :(


I think we are getting some where now. I increased R2 to 560K. I am now getting a 0 to 2.4 v when I wave my had over the device (2.4v when my hand is above the device) . This is closer to what I was seeing to when the device passed over the white area.

I am getting about 320mv of ripple when my hand is not over the device so I am not at exactly zero. I assume noise from ambient light.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,837
I have used these for a digital tach with a pic, just white paint or 3M retro reflective tape.
This is the one that @THE_RB used on his marketed unit, the SuperPID router controller.
http://www.vhipe.com/product-private/SuperPID-Home.htm
Max.

Used what? The QRE113? If so you are the one that recommended it to me a while back. I am finally starting on the project.

Can you share your circuit for the sensor?

This is what I have so far. Instead of the 10k, I am using 560K. I get 0 to about 2.4v on out with about 320 mv of ripple off of zero. Can I do better? My supply is 5v. And I went with 180 ohms for the current limiter. Seemed a better value according to what I found in the datasheet. The design below is from sparkfun.

 
Top