Let's Make Robots!

QRD1114 Resistor Values

Hi all,

I'm using a QRD1114 sensor for a line-follower. Datasheet: http://www.fairchildsemi.com/ds/QR/QRD1114.pdf

Im hooking it up with this schematic:

However, I'm unsure how the value for the 10K resistor was calculated? It's acting as a potential divider, right?

For the LED im guessing that the value of 220 was taken from doing:

R=(Input Voltage - Max Forward Voltage)/(Optimum forward current)

so: R = (5-1.7)/0.020 = 165

and 220 is closeish to this?

I'd appreciate any help!

Thanks in advance!

Michael 

http://hirobotblog.blogspot.co.uk/

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The 10k resistor acts as a pull up resistor so the microcontroller definetely detects only when the phototransistor pulls the µC pin low. When doing this type of level detection (especially using interrupts) it is a good idea to place a pull up or pull down resistor on that pin.

The 220 Ohm resistor gives 4.3V / 220Ohms = 19.5 mA. They have probably chosen this one because 165 Ohms is a resistor of the E96 series and 220 Ohms is the closest E12 series resistor because the E12 series is easier available, not every supplier stocks resistors from the E96 series.

With a 5V LED a 220Ω resistor is common practise.

Ah OK -

can you elaborate a a bit on how that pull up resistor works? (electronics newbie here)

Thanks in advance,

Michael

http://hirobotblog.blogspot.co.uk/

It's actually pretty easy. As mogul has said you can replace the 10k resistor by the internal pull up resistor in the AVR (on your Arduino).

To activate the internal pull up resistor is connected between the pin and the supply voltage internally, hence the name pull up, when the pin is declared as an input (pinMode(sensorPin, INPUT)) and then writing a logical '1' into the PORT register, in Arduino this would mean digitalWrite(sensorPin, HIGH).

Pull up or pull down (resistor between pin and ground) resitors are generally used to prevent false triggering of an external interrupt (special event that will interrupt the current program when one of the interrupt pins changes state) or to prevent a false reading from your pin via digitalRead(sensorPin). The false readings / triggerings can occur because the pin is left 'floating', meaning that it doesn't have a defined state.

Depending on how noisy (in terms of electromagnetic fields) your environment is, it's pretty random if you read a 0 or 1, because of the inductance of the traces and pins etc. (the longer the wire you connect to that pin, the more noise you will pick up, especially the 50/60Hz mains frequency).

First off, thanks for all your help. The LMR community is fantastic.

I've hooked up all the circuitry according to the schematic and finally thought i understood how it all worked...

However, I'm getting readings between about 300 and 700! This leaves out a huge margin between the 0 to 1023 that my arduino is capable of reading to. Coiuld it be a problem with the 10K resistor value? I was also powering an LCD display (you can see in the image) off of the 5V power line, so I thought that could mean i wasn't supplying enough voltage to the sensor. However, even after switching to an individual power line from a separate battery for the sensor, no luck.

Any ideas? Also, how would I go about powering an array of 7 of these sensors? Will they get enough voltage from sharing a single 5V power line?

Any help would be really appreciated - my deadline is coming up fast! :P

Michael

http://hirobotblog.blogspot.co.uk/

There shouldn't be a problem with the current actually. The Arduino is capable of supplying enough current to the LCD and the LEDs when using a battery pack. If you put the sensors closer to the ground you can get away with less than 20mA per LED, depending on how much intensity you need.

You can compensate for the values in software. So you're saying a light surface is 700 and a black surface is 300, right? Then just use the value in between, 400, as a threshold to determine if the sensor is on the line (700) or off the line.

Another thing you could do is solve this problem in hardware, you could use the 74HC14 inverting schmitt trigger, it is more sensitive than the schmitt triggers inside the AVR and therefore it can tell the difference better, even if the signal levels are not 5 or 0V.

The values are far enough apart so that the schmitt trigger will give you a 1 when the sensor is off the line (remember it's inverting)  and a 0 if you are on the line. Just connect the schmitt triggers outputs to your digital pins and you're good to go.

 

To solve the problem of ambient light you can just slip a bit of heatshrink tubing around each sensor. This also ensures that there is no crosstalk between the sensors.

Thanks again everyone who helped me out. Here's the story of the working system! Now I cant wait to get my motors! :P

http://hirobotblog.blogspot.co.uk/2012/07/ok.html