Obtaining Collector Current Vs lumens for photo transistor setup

Thread Starter

guitardenver

Joined Jan 24, 2009
31
If I have a photo-transistor, specifically this one WPT-1CL3H (Yes, it must be that one), I would like to obtain a graph of The collector current vs how much light the transistor is picking up.

The setup:
The emitter of that transistor is pulled down to ground with a 1k resistor and the collector is connected to +3.3V. Then a microcontrollers ADC is connected to the emitter to read the voltage across said resistor.

I need to vary the light going into the photo-transistor with an LED (WP710A10MBD) that is controlled by the MCU. I tried to use PWM to vary the light intensity but the photo-transistor responds to fast and the ADC values are all over the place.

Does anybody have any creative ideas of how I can vary the light with a continuous light intensity? Without the use of other physical objects like paper with different thickness/color to vary the light (That is how I do it already). What are the implications of doing PWM at a speed in which the LED nor the photo transistor can respond to fast enough? Make it more "analog". The MCU speed is limited to 4MHz. Also the LED is not on a hardware timer output on the MCU, so the pin state that controls the LED must be toggled in software. I'm dealing with old unchangeable hardware, which means I can not add a variable current source circuit or something like that.

Thanks for the brainstorm.
 

MikeML

Joined Oct 2, 2009
5,444
Can you add any components (R, C, Transistor) around the LED to make a low-pass filter? You can still use the duty cycle of the PWM to set the average LED current.
 

Thread Starter

guitardenver

Joined Jan 24, 2009
31
Can you add any components (R, C, Transistor) around the LED to make a low-pass filter? You can still use the duty cycle of the PWM to set the average LED current.
That would be a great idea. But unfortunately i'm stuck with the hardware I have. Which is MCU pin to a FET that drives the LED.

I have a feeling that the solution (If there is one, and I'm willing to accept that) is going to be real complex. Maybe if I sample the voltage as fast as I can and vary the frequency enough I can relate a frequency response of the photo-transistor to something useful. The idea is to calibrate the sensor so that even with age, a little dirt, manufacturing impurities, etc, each sensor will read about the same value as the rest at any given light intensity. That way if a piece of material such as paper goes in between the LED and sensor I can determine what it is based on a known set of data. Ex: Material A has a value of 1.2V when in the sensor so I can say that if I get a reading of about 1.2V I know what material it is. If each sensor is a little different I can not correlate the data to what is being read by the ADC. Right now I calibrate the sensor by putting sample pieces of material like paper to vary the light and adjusting the gain (on an op-amp) based off of that. But I have a need to automate this process in software instead of a physical insertion of calibration papers.

Keep the brainstorm coming.
 

Thread Starter

guitardenver

Joined Jan 24, 2009
31
Correct, as I said "I'm dealing with old unchangeable hardware," I can not modify production boards. Cutting a PCB trace and hacking into a board is not a suitable option for 1000's of boards going to customers. Redesigning the board is not cost effective at the moment and does not help with the 1000s of boards I have in stock. I just thought I would throw this problem out to the public to see if anybody had any creative ideas.
 

wayneh

Joined Sep 9, 2010
17,498
Can't you look at the average intensity? I know "average peak" is an oxymoron but I mean to sample for, say, one second and compute a value for the mean and standard deviation. That sort of average should vary in proportion to the peak while the pulse is on.

A large standard deviation is not a problem as long as you have enough samples. Imagine determining the height difference between men and women. The six inch "signal" is buried in a lot of noise since the standard deviation in human height is probably about the same. But with enough samples, you can have a high confidence in the difference between the mean heights.
 

BobTPH

Joined Jun 5, 2013
8,938
Correct, as I said "I'm dealing with old unchangeable hardware," I can not modify production boards. Cutting a PCB trace and hacking into a board is not a suitable option for 1000's of boards going to customers. Redesigning the board is not cost effective at the moment and does not help with the 1000s of boards I have in stock. I just thought I would throw this problem out to the public to see if anybody had any creative ideas.
I do not understand. You said you need to get a graph of the response of the phototransistor. Surely you do not mean that the customers need to get this graph, do you? So why do you think you would need to modify the customer's boards? You would modify one board, get the graph, and it would apply to all of the other boards.

Unless what you really mean is that you want to be able to control the intensity of the LED, in an analog way, not by PWM on the customer board. Is that what you are trying to do?

Bob
 

Thread Starter

guitardenver

Joined Jan 24, 2009
31
I do not understand. You said you need to get a graph of the response of the phototransistor. Surely you do not mean that the customers need to get this graph, do you? So why do you think you would need to modify the customer's boards? You would modify one board, get the graph, and it would apply to all of the other boards.

Unless what you really mean is that you want to be able to control the intensity of the LED, in an analog way, not by PWM on the customer board. Is that what you are trying to do?

Bob
If each board does not have the ability to obtain it's own data, it has no way of adjusting it's sensors to the one graph that was collected. One graph (data) will go with all the boards as a master graph, that is correct. But, each board needs to obtain it's own data for it's own sensor and calibrate itself to the master graph. Remember the point is to have all the sensors read the same value (or as close as possible) to a known set of data, the master graph. The sensors over time drift and will need to obtain the data again for it's sensors and adjust itself to match the master graph again.


Can't you look at the average intensity? I know "average peak" is an oxymoron but I mean to sample for, say, one second and compute a value for the mean and standard deviation. That sort of average should vary in proportion to the peak while the pulse is on.

A large standard deviation is not a problem as long as you have enough samples. Imagine determining the height difference between men and women. The six inch "signal" is buried in a lot of noise since the standard deviation in human height is probably about the same. But with enough samples, you can have a high confidence in the difference between the mean heights.
weyneh, I think your on the right track. Manipulating the data like that and trying to get a useful reading is probably the way to go. If I can't get smooth data, i'm gonna have to fish it out of all the noise myself with some math and DSP. I'll see how many samples I can take for each PWM duty cycle. Time is not really a limiting factor, so the MCU can work for a while to do this. I'll put a low pass filter on the data in software and see what that puts out as well.
 
Last edited:

Alec_t

Joined Sep 17, 2013
14,312
The light output of the LED will also vary with age, dirt etc, so what you need to calibrate is the combination of LED + photransistor.
 

Alec_t

Joined Sep 17, 2013
14,312
Maybe if I sample the voltage as fast as I can and vary the frequency enough I can relate a frequency response of the photo-transistor to something useful.
That looks possible. According to the datasheet, the combined rise and fall time of the reponse is typically 6.3uS. So if you could pulse the LED at >100kHz, even at a fixed PWM duty cycle you should be able to vary the effective sensitivity of the phototransistor.
Can you post a link to the LED spec?
 

Alec_t

Joined Sep 17, 2013
14,312
Unfortunately the datasheet gives no spec for the response time of that LED, but datsheets of other LEDs give times <1uS. How fast can your PWM run?
 

Thread Starter

guitardenver

Joined Jan 24, 2009
31
Unfortunately the datasheet gives no spec for the response time of that LED, but datsheets of other LEDs give times <1uS. How fast can your PWM run?

The MCU is running at 4MHz. For 8 bit PWM it will have about a 63 us period. If I need a period of 1 us I can only do a 4 bit PWM. That's at minimum. Since I can not toggle the pin in hardware we can add a couple instruction cycle times to toggle the pin in software.
 

mcgyvr

Joined Oct 15, 2009
5,394
Why aren't you simply calibrating in software vs attempting a hardware calibration?.. (I assume thats what you are doing anyways.)
Put a known sample and adjust the software scaling.
 

Alec_t

Joined Sep 17, 2013
14,312
The MCU is running at 4MHz. For 8 bit PWM it will have about a 63 us period. If I need a period of 1 us I can only do a 4 bit PWM.
Then I don't see much scope for 'smoothing' the LED output. Without a low-pass filter added it will still be distinct on/off full-brightness switching. But with a 1uS pulse period the phototransistor should in theory have a modified response which may give you something to go work from. Let us know if practice confirms the theory.
 

BobTPH

Joined Jun 5, 2013
8,938
Try pulsing it at 1 uSec and measure the current through it on the oscilloscope (voltage across the current limiting resistor.) If it does not get anywhere near the full current, this might be a way of controlling the brightness.

Bob
 
Top