Obtaining Collector Current Vs lumens for photo transistor setup

Discussion in 'General Electronics Chat' started by guitardenver, Nov 14, 2014.

  1. guitardenver

    Thread Starter Active Member

    Jan 24, 2009
    30
    0
    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.
     
  2. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    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.
     
  3. guitardenver

    Thread Starter Active Member

    Jan 24, 2009
    30
    0
    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.
     
  4. Brevor

    Active Member

    Apr 9, 2011
    279
    54
    So are you saying that the only thing you can change is the software?
     
  5. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Ever heard of cutting a pcb trace with an XACTO knife?
     
  6. guitardenver

    Thread Starter Active Member

    Jan 24, 2009
    30
    0
    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.
     
  7. wayneh

    Expert

    Sep 9, 2010
    12,100
    3,034
    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.
     
  8. BobTPH

    Active Member

    Jun 5, 2013
    782
    114
    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
     
  9. guitardenver

    Thread Starter Active Member

    Jan 24, 2009
    30
    0
    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.


    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: Nov 17, 2014
  10. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,789
    1,103
    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.
     
  11. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,789
    1,103
    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?
     
  12. guitardenver

    Thread Starter Active Member

    Jan 24, 2009
    30
    0
    WP710A10MBD
    http://www.mouser.com/ds/2/216/WP710A10MBD(Ver 1)-200629.pdf
     
  13. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,789
    1,103
    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?
     
  14. guitardenver

    Thread Starter Active Member

    Jan 24, 2009
    30
    0

    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.
     
  15. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,769
    969
    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.
     
  16. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,789
    1,103
    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.
     
  17. BobTPH

    Active Member

    Jun 5, 2013
    782
    114
    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
     
Loading...