Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

How Do I Calculate Resistor Value


  • Please log in to reply
13 replies to this topic

#1 Inquisitor

Inquisitor

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • LocationAtlanta, Georgia, USA

Posted 30 August 2011 - 01:23 AM

Software type needing training wheels… :unsure:

I’m playing around with a QRD1114 Optical Detector (Basically a combined Infrared LED and Photo Transistor). Here’s the demo, I started with… Tutorial and here’s the datasheet. All works as advertised.

Now, I’m trying to dissect how to do it without the cookbook.

On the LED side, I’ve got it figured out as a current limiting circuit and have calculated and tried it out at several supply voltages. I’ve got it instrumented up with voltage and current readings and I’ve matched the calculations and kept the smoke in the chip! B)

On the sensor side… I’m at a loss. I’ve Google searched and there are plenty of other examples like the one above, but no one is revealing the magic behind the curtain. I want to figure out how the 4.7k to 5.6k resistor is calculated from the data sheet. My request is twofold…

  • I want to be able to determine this for other similar sensors I might use in the future.
  • I also would like to figure the total range that the sensor can handle. The cookbook
above suggests that changing this can adjust the sensitivity. I would like to hook a potentiometer up to it with this calculated range and see how the sensitivity changes.

If you feel the question involves too much digging into the datasheet above, maybe you could help me with the key phrase (like “current limiting LED”) that might help me find the solution.

Thanks for any light you can shed.
Doing my best to keep the smoke in the little black boxes.
If my message helped you... how 'bout giving me a Posted Image
www.MessingWithReality.com

#2 Bill E.

Bill E.

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSilicon Valley, California

Posted 30 August 2011 - 02:06 AM

Hello Inquisitor! It seems that you have the LED figured out. The photo transistor only needs to be satisfied as to its minimum requirements. To tell you the truth, I haven't found a sensor that is not so sensitive that a 100K resistor (!) would not work with a microcontroller input. It's all in the betas and "transconductance" (ugghhh!), ... The LED is key. The higher the resistance value between the collector and power bus (+5v?) the lower the current needed. BUT the higher resistance will lower the response time. And vice versa. There is always the "transconductance" value - eyes rolling back into head! Just be sensitive to too high a resistance on the transistor collector - heck, you could get into the hundreds of Kohms or even megohms. For hackers & micro dudes, I would keep a stash of 1K, 10K, 100K, 220 & 350 ohm, resistors. That will do you very fine! Everything "digital" can be handled with these resistors. Regards.

#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 30 August 2011 - 06:02 AM

Bill is right.
For those situations where is much hard to describe the model than choosing the best resistor, no doubt for the second option!

I would give a suggestion about the sensivity. Many many years ago I made several experiments with an IR emitter-receiver, and it was not so easy to improve its sensivity.
Basically, you are driving the LED so that it will produce a continuous beam of light. That's really simple, but your detector has no chances to distinguish the light produced by the led, with your wife's iron!
Any strong IR emitter would get the detector "blind". It is much like when anyone is lighting you with a strong lamp (an actor on the scene), then you cannot see anything because your eyes are "saturated".
I had this kind of problem when my detector was lighted by the sun. My emitter was totally insignificant.

So, if you need a good improvement of sensivity, you should:
  • drive the emitter (led) using a square wave (e.g. PWM with freq=10KHz);
  • on the detector side, apply a bandpass filter, so that *ONLY* the frequencies around 10KHz may pass.
It's a bit harder than your basic solution, but the improvement is huge.
However, it depends on what you are doing.
Cheers
Biggest fault of Netduino? It runs by electricity.

#4 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 30 August 2011 - 07:17 AM

I want to figure out how the 4.7k to 5.6k resistor is calculated from the data sheet.

Basically, the value of the resistor determines whether the transistor operates in "active" (i.e. amplifier) or "switch" mode, it is also used to calculate the load current, which for example application is about 1 mA (IC = VCC/RL, where Vcc = 5V, RL = ~5kΩ). For more detailed information, you may want to check out Design Fundamentals for Phototransistor Circuits (pdf), Using the Transistor as a Switch, Transistor Circuits, Common collector and Common emitter.

#5 Inquisitor

Inquisitor

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • LocationAtlanta, Georgia, USA

Posted 30 August 2011 - 11:01 AM

Hello Inquisitor!

For hackers & micro dudes, I would keep a stash of 1K, 10K, 100K, 220 & 350 ohm, resistors. That will do you very fine! Everything "digital" can be handled with these resistors.

Regards.


I guess I am a wannabe dude... Not knowing ahead of time what I would need over time and picturing myself spending hundreds of dollars in gas to buy 1's and 2's at radio shack, I just got the 73 Values Set. I'll probably never use 90% of them. But... My little one liked sorting out the colors and categorizing them into a plastic drawer case. Also, I've been playing around with serializing and paralleling them to get exact values calculated by the equations. It appeals to my anal-retentive side. :D
Doing my best to keep the smoke in the little black boxes.
If my message helped you... how 'bout giving me a Posted Image
www.MessingWithReality.com

#6 Inquisitor

Inquisitor

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • LocationAtlanta, Georgia, USA

Posted 30 August 2011 - 11:25 AM

Thank you all three of you! I look forward tonight to digging into your references (Bill’s transconductance and CW2’s links).

Mario,

Your sensitivity suggestions are definitely something I would like to explore. The tutorial above hints that the sensor should be good reading out to about 3 cm. In my last science project with the Tachometer, I didn’t have any luck beyond 5 mm. Unfortunately, for the tachometer, I was in the realm of sensing 2100 Hz changes, so 10 KHz strobing of the emitter, would really whack-out my software algorithm… probably get some kind of harmonic artifacts. (re-reading... maybe that's what the band pass thing you mention does… Note to self: research “band pass” circuit)

HOWEVER, for what I’m after now… I want to get the analog readings to measure distance. I’m hoping to see their 0 to 3 cm on the 10 bit A/D input.
Doing my best to keep the smoke in the little black boxes.
If my message helped you... how 'bout giving me a Posted Image
www.MessingWithReality.com

#7 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 30 August 2011 - 01:14 PM

Inquisitor, the sun problems were at distance of about 15-20 meters between the emitters and the detector. The experiments were about a car recognizing system for an access gate. Unfortunately it was not simple enough to realize ad it was dead. For the tacho I would not use any modulation, because it interferes with the useful pulses. My suggestion was about the proxy detector. Cheers
Biggest fault of Netduino? It runs by electricity.

#8 Inquisitor

Inquisitor

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • LocationAtlanta, Georgia, USA

Posted 30 August 2011 - 05:06 PM

Basically, the value of the resistor determines whether the transistor operates in "active" (i.e. amplifier) or "switch" mode, it is also used to calculate the load current, which for example application is about 1 mA (IC = VCC/RL, where Vcc = 5V, RL = ~5kΩ). For more detailed information, you may want to check out Design Fundamentals for Phototransistor Circuits (pdf), Using the Transistor as a Switch, Transistor Circuits, Common collector and Common emitter.


OK... I couldn't wait. This first document was exactly what I needed!

If I reading the datasheet correctly, the Icc in the article is Collector Current Ic(ON) that is on the datasheet and is 1 mA. If I want to use the Netduino’s 5V output, this gives me the crossover point from Active to Switch mode at 5kΩ. So for the tachometer (just counting off/on cycles) I should use resistors higher than 5kΩ (for Switch mode) and for measuring distance, I should use values less than 5kΩ (for Active / proportional response). I’m good so far?????

What about the other extremes… I’m guessing at real high values of resistance their won’t be enough current to do anything. Likewise, at real low values of resistance, I’ll either be pulling too much current from the Netduino board (200 mA) or pushing too much through the phototransistor. Is there something on the datasheet that will keep me safe at both ends?

In my best Dalai Lama pose… Ummmmmmmmm… keep the smoke in the chip…. Ummmmmmm!
Doing my best to keep the smoke in the little black boxes.
If my message helped you... how 'bout giving me a Posted Image
www.MessingWithReality.com

#9 Inquisitor

Inquisitor

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • LocationAtlanta, Georgia, USA

Posted 30 August 2011 - 10:49 PM

Just FYI. I don't know if this will be useful to anyone...

I'm not sure what I've got going wrong. My data seems to be opposite what "Design Fundamentals for Phototransistor Circuits" said should happen. 5.63kΩ is the calculated resistance for the cross over from Active Mode to Switch mode. However, using 9.52kΩ seems to be the most proportional (but not really very), while the low resistance 1kΩ acted closer to a switch. I also tried 1MΩ and nothing changed.

Basically, I don't think its going to be usable for determining distance.

Posted Image
Posted Image
Posted Image
Doing my best to keep the smoke in the little black boxes.
If my message helped you... how 'bout giving me a Posted Image
www.MessingWithReality.com

#10 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 31 August 2011 - 04:48 AM

Why, if your power is +5V, the output can reach +5.5V?

I tend to suggest the experimental way for the resistor. Here's why...

Normal transistor (NPN).
If you make a current flowing FROM the base TO the emitter, say it Ib, then the current flowing FROM the collector TO the emitter, say it Ic, is:
Ic <= Ib * hFE
where hFE is a (pretty constant) parameter specific to any transistor model. Typically is around 200.
Now, notice the above formula:
  • WHEN happens the EQUAL sign, the transistor is working in the ACTIVE area;
  • WHEN happens the LESS-THAN sign, the transistor is saturated;
  • WHEN Ib is zero, Ic is also zero, and the transistor is off.
I apologize for the correct terminology in English: in Italian we're using certain terms.

Photo-transistor (NPN).
Since *ANY* bipolar junction is also photo-sensitive, a photo-transistor is not much different from a normal one. It only provides a larger silicon exposure area to the irradiation, and/or others features we don't mind.
Typically there's *NO* Ib (i.e. the base lead is left open), so -apparently- the transistor should be always off.
When the light (stream of photons) is hitting the silicon surface, it acts as it was a current Ib. The stronger is the light energy, the higher is the equivalent current Ib, and the formula can be applied. The actual problem is HOW to calculate the Ib from the light radiance.
Of course there are formulas on it, but I would avoid ton of theory and missing parameters, side-effects, and whatever else. I'd prefer to choose a certain emitter, avoid (or establish) the surrounding lighting, then choose the best resistor by picking among a range.

Using a photo-transistor as on/off (sat/off) will require a very good exposition to the emitter, and a good isolation from any other (spurious) irradiation. A typical usage like this is in the old floppy-disk drives, to detect whether the read-only hole is open or not.
In such a circuit:
  • the emitter and the detector are totally closed into the drive box (so no spurious irradiation);
  • they are very close each other (no more the thickness of the diskette);
  • they are perfectly aligned, so the rays hit the silicon with the maximum efficiency.
In other situations where you cannot rely on these models, you must use the photo-transistor *ALWAYS* working in the active area, consider very small output variations (e.g. millivolts), then amplify, maybe filter as well.

Not long ago I built a circuit using a led and a photo-transistor to "read" the blood pressure heartbeat within a finger. May this circuit be useful for you?
Cheers
Biggest fault of Netduino? It runs by electricity.

#11 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 31 August 2011 - 07:08 AM

Basically, I don't think its going to be usable for determining distance.

No, it's not, because as you can see in Normalized Collector Current vs. Distance chart in the datasheet, the device peak sensitivity is around 20 - 30 mils (0.5 - 0.76 mm) and decreases significantly, at 200 mils (5 mm) is is only 10%. You'd need to choose different sensor to measure larger distance, such as Sharp IR proximity sensors, or you can make your own - just use IR LED and phototransistor (very cheap) that has matching wavelength (850 nm, 940 nm etc.).

Another option is to use IR photodiode instead of phototransistor - the photodiode has faster response time than the phototransistor (orders of magnitude), but produces significantly lower current (typically tens of µA), so an amplifier circuit (OPAMP) is needed for interfacing with a microcontroller.

Also, for IR distance measurement in noisy environment (the sun is a strong source of background IR noise), you'd need to use modulated signal (e.g. driving the IR LED with 36 - 40 kHz PWM signal) and either demodulate the received signal or use IR receiver module that has it built-in (e.g. TSOP382).

#12 Inquisitor

Inquisitor

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • LocationAtlanta, Georgia, USA

Posted 31 August 2011 - 01:57 PM

No, it's not, because as you can see in Normalized Collector Current vs. Distance chart in the datasheet, the device peak sensitivity is around 20 - 30 mils (0.5 - 0.76 mm) and decreases significantly, at 200 mils (5 mm) is is only 10%. You'd need to choose different sensor to measure larger distance, such as Sharp IR proximity sensors, or you can make your own - just use IR LED and phototransistor (very cheap) that has matching wavelength (850 nm, 940 nm etc.).

Another option is to use IR photodiode instead of phototransistor - the photodiode has faster response time than the phototransistor (orders of magnitude), but produces significantly lower current (typically tens of µA), so an amplifier circuit (OPAMP) is needed for interfacing with a microcontroller.

Also, for IR distance measurement in noisy environment (the sun is a strong source of background IR noise), you'd need to use modulated signal (e.g. driving the IR LED with 36 - 40 kHz PWM signal) and either demodulate the received signal or use IR receiver module that has it built-in (e.g. TSOP382).


I’ve always been comfortable with graphs in my former profession… material stress/strain curves, damped vibration and stuff and I should be at home with these curves. But when I look on page 2 and see the first line item: Forward voltage @20 mA, Max value is 1.7 volts… THEN I look at the first graph Fig 1 on page 3, I have a major disconnect… I see at 20 mA… maybe 1.22 (mA sic - should be Volts) and as far as I can see, it’s never going to make it to 1.7 Volts. Either way… they just don’t jive. I guess... I didn’t go any further in the curves because I didn’t have any trust in my ability to interpret what they meant to me in the real world (since I couldn’t get past that first one).

Also, I guess I was trying to achieve something usable at 3 cm since the “bildr” tutorial above said I could (should). But now that you point out Fig 5, I see your point and won’t keep trying to make it do things outside its intended function.

Thanks for the help!
Doing my best to keep the smoke in the little black boxes.
If my message helped you... how 'bout giving me a Posted Image
www.MessingWithReality.com

#13 Inquisitor

Inquisitor

    Advanced Member

  • Members
  • PipPipPip
  • 91 posts
  • LocationAtlanta, Georgia, USA

Posted 31 August 2011 - 02:13 PM

I apologize for the correct terminology in English: in Italian we're using certain terms.

Sometimes (and very rarely) I have to pause and concentrate on what you are trying to say. But… your English is orders of magnitude better than my Italian! Hell! I understand you better than most Yankees! :D


Why, if your power is +5V, the output can reach +5.5V?

5.63V – I’m not quite as secure in my circuitry as you hardware types. (Just because I’m paranoid doesn’t mean the smoke isn’t trying to get out :unsure: ). I have my little test rig hooked up to volt and current meters and a 5 Volt power supply that reads 5.63 V all the time.


I tend to suggest the experimental way for the resistor. Here's why...

Normal transistor (NPN).
If you make a current flowing FROM the base TO the emitter, say it Ib, then the current flowing FROM the collector TO the emitter, say it Ic, is:
Ic <= Ib * hFE
where hFE is a (pretty constant) parameter specific to any transistor model. Typically is around 200.
Now, notice the above formula:

  • WHEN happens the EQUAL sign, the transistor is working in the ACTIVE area;
  • WHEN happens the LESS-THAN sign, the transistor is saturated;
  • WHEN Ib is zero, Ic is also zero, and the transistor is off.
I apologize for the correct terminology in English: in Italian we're using certain terms.

Photo-transistor (NPN).
Since *ANY* bipolar junction is also photo-sensitive, a photo-transistor is not much different from a normal one. It only provides a larger silicon exposure area to the irradiation, and/or others features we don't mind.
Typically there's *NO* Ib (i.e. the base lead is left open), so -apparently- the transistor should be always off.
When the light (stream of photons) is hitting the silicon surface, it acts as it was a current Ib. The stronger is the light energy, the higher is the equivalent current Ib, and the formula can be applied. The actual problem is HOW to calculate the Ib from the light radiance.
Of course there are formulas on it, but I would avoid ton of theory and missing parameters, side-effects, and whatever else. I'd prefer to choose a certain emitter, avoid (or establish) the surrounding lighting, then choose the best resistor by picking among a range.

Using a photo-transistor as on/off (sat/off) will require a very good exposition to the emitter, and a good isolation from any other (spurious) irradiation. A typical usage like this is in the old floppy-disk drives, to detect whether the read-only hole is open or not.
In such a circuit:
  • the emitter and the detector are totally closed into the drive box (so no spurious irradiation);
  • they are very close each other (no more the thickness of the diskette);
  • they are perfectly aligned, so the rays hit the silicon with the maximum efficiency.
In other situations where you cannot rely on these models, you must use the photo-transistor *ALWAYS* working in the active area, consider very small output variations (e.g. millivolts), then amplify, maybe filter as well.


Your suggestion of using the experimental way is a very good one (and certainly for me). I think I need to get “dirty” just trying things so I can start to get a feel for what can and can’t be done. I think that is why I rigged up the above equipment. I was pleasantly surprised that my test rig gave me such smooth data and rational data. I was expecting to have more outliers. Way cool! I’m liking this hardware stuff!

Not long ago I built a circuit using a led and a photo-transistor to "read" the blood pressure heartbeat within a finger. May this circuit be useful for you?
Cheers


I would be very interested in your heartbeat sensor. I just not sure, I’m up to understanding how it works… yet.

Thanks for your help.
Doing my best to keep the smoke in the little black boxes.
If my message helped you... how 'bout giving me a Posted Image
www.MessingWithReality.com

#14 Phillip Brooks

Phillip Brooks

    New Member

  • Members
  • Pip
  • 1 posts

Posted 31 August 2011 - 05:27 PM

I guess I am a wannabe dude... Not knowing ahead of time what I would need over time and picturing myself spending hundreds of dollars in gas to buy 1's and 2's at radio shack, I just got the 73 Values Set. I'll probably never use 90% of them. But... My little one liked sorting out the colors and categorizing them into a plastic drawer case. Also, I've been playing around with serializing and paralleling them to get exact values calculated by the equations. It appeals to my anal-retentive side. :D


The key word for you would be "decade box". You can find them starting around $100. You can "dial in" the resistance you want without stacking in series and parallel.

here is one on Amazon...

http://www.amazon.co...x/dp/B00023RTZO

If you do this professionally, then there are higher end devices such as this...

http://www.amazon.co...x/dp/B001M1WIM4

(Note: I used to work for IET Labs. They've been making these forever...)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.