Shop OBEX P1 Docs P2 Docs Learn Events
How fast, bright flashes can cause errors in the TSL230 Light to Frequency sensor — Parallax Forums

How fast, bright flashes can cause errors in the TSL230 Light to Frequency sensor

ElectricAyeElectricAye Posts: 4,561
edited 2011-08-10 17:18 in Accessories
This sensor saturation phenomenon is no doubt obvious to gurus, but it's the sort of thing that burns perpetual noobs like me.

The TSL230 is a very nice sensor. I use it for a lot of things. But I recently encountered a phenomenon that might be of interest to anyone using this chip to measure light intensity of anything involving brief, bright flashes of light, for example lasers, high intensity LEDs, lightning, etc. The moral of the story is to check the output values at different sensitivities so you can be on guard for this source of error.

To generate pulses, I used the PWM object from the OBEX, which allows me to generate brief pulses of light separated by relatively long periods of darkness.

I have an IR emitter in series with a 25 ohm resistor powered by a 5 volt power source. For an 8.2 usec pulse followed by 820 usecs of darkness, I get the following measurements when counting over a period of 1 second.

Sensitivity
1X = 126 Hz
10X = 1258
100X = 12453

Such readings are what you would expect.

But when I reduce the series resistor to 10 ohms (which makes the IR emitter brighter), here is what I measure:

Sensitivity
1X = 278 Hz
10X = 2768
100X = 20947

Although the 1X and 10X sensitivities are what you might expect, the 100X sensitivity does not match what is seen by the 1X and 10X ranges.

Similarly, here is what I see when I reduce the series resistance down to 3.3 ohms (which makes the IR emitter even brighter):

Sensitivity
1X = 683 Hz
10X = 6786
100X = 41078

Again, the 100X reading is out of agreement with the other sensitivity readings.

Of course, the TSL230 is capable of outputting Hz readings in excess of 1000000, so at first glance it might not seem like the sensor itself is reaching any kind of limitation. So what's going on?

I think the answer involves how the TSL230 "gives credit" for all the photons that strike it at any given moment. If you imagine photons are like BBs and there is a little BB counter inside the TSL230, then that BB counter under normal circumstances can give credit for every BB that the detectors "see". In a sense, the BB counter counts how many BBs are reported by the detectors in, let's say, a nanosecond, then outputs a frequency (in Hz) based on how many BBs it counted during that nanosecond. The problem is this: that inner BB counter can count only so many BBs per nanosecond, so if the number of BBs that are reported to it exceeds its ability to count that high, then the count gets "pegged out" on some upper limit, let's call it L counts.

So, when the BB counter is told about a huge pulse of BBs whose number exceeds that upper limit, it "gives credit" only for L counts and no more. Even if the pulse itself was "worth" 2L or 10L or 10000L, the BB counter is going to give credit only for L during that nanosecond. That is why lowering the sensitivity can give an accurate count but the higher sensitivity makes no sense at all.

In other words, the inner BB counter boggles at the thought of all those BBs the 100X detection tells it about when too many BBs come at one time. And it seems to take a little while for the BB counter to stop freaking out, too.

To test this theory, I performed the following little experiment using 2.75 ohms in series with the same IR emitter used above:

For an 8.2 usec pulse followed by 820 usec of darkness and counting TSL230 output pulses over a period of 1 second, I get the following readouts:

Sensitivity
1X = 712 Hz
10X = 7048
100X = 41292

Next, when I keep each pulse at 8.2 usec wide but reduce the period of darkness to 410 usec to effectively double the number of pulses seen by the TSL230 over a period of 1 second, the TSL230 outputs the following:

Sensitivity
1X = 1398 Hz
10X = 13843
100X = 81441

In other words, when the number of pulses per second doubles, the reading doubles per second, even for the "choked" 100X sensitivity. So far, so good.

But when I double the width of the light pulse to 16.4 usec and make the dark period at 820 usec, then I get the following readings:

Sensitivity
1X = 1396 Hz
10X = 13805
100X = 58606

While the 1X and 10X sensitivities turned out as expected, the 100X does not. So it seems to me that the 100X is being overwhelmed, even though the TSL230 reading is far below 1000000.

So when dealing with bright, short flashes, be sure to take a look at the various sensitivities to see that they are in agreement with each other. I think this is one of those cases where it helps to understand the inner workings of your sensor rather than treat it like a "tiny black box".

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-10 09:24
    The S0 and S1 sensitivity inputs to the TSL230 control the analog gain of the detector, before its output voltage is converted to pulses. A bright flash of light, however brief, will saturate this analog stage if the gain is set too high, and the output during this brief interval will top out at the maximum 1 MHz rate, instead of something higher that's proportional to the light intensity. The number of pulses that your program counts in one second will include the brief 1 MHz bursts mixed in with lower frequencies between flashes of light.

    -Phil
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-08-10 09:44
    ... The number of pulses that your program counts in one second will include the brief 1 MHz bursts mixed in with lower frequencies between flashes of light.

    -Phil

    So the "BB counter" gives a max rate of only 106 Hz. So an individual 8.2 x 10-6 sec pulse would add an average of 8.2 Hz to the total count in a time frame of one second. Is that correct?

    I guess instead of picturing it as a "BB counter," it's better to see it as an amplifier that drives an oscillator. And the amplifier can provide only so many volts to the oscillator. Better?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-10 10:15
    Yes, theoretically, it would add approximately 8 counts for each 8.2 usec flash. However, your data suggests that there's a lag time, after the flash goes away, during which the output frequency is still at maximum or coming down from maximum. The datasheet specifies the reaction for a low-to-high step response, which is nearly instantaneous, but does not provide a spec for going the other way. What this boils down to is that you're probably getting more than 8 counts per 8.2 usec flash

    -Phil
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-08-10 10:45
    ...The datasheet specifies the reaction for a low-to-high step response, which is nearly instantaneous, but does not provide a spec for going the other way. What this boils down to is that you're probably getting more than 8 counts per 8.2 usec flash...

    Ahhh, hey, now that's very interesting! I hadn't looked at it that way before. I suppose that discrepancy could get significant for integrating pulses over time, especially "long" periods of time. I'm very glad you brought that to my attention. I knew there was an enlightened self-interest in my posting this thing. Thanks for pointing that out. :-)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-10 11:14
    An alternate explanation may be that your emitter continues to provide light after you switch it off. Obviously, this won't happen if you drive it directly from a Propeller pin. But if you're going through a transistor or driver IC, you have to consider the additional switching time, which may be asymmetrical.

    -Phil
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-08-10 11:47
    An alternate explanation may be that your emitter continues to provide light after you switch it off....

    Good point. The emitter is being driven by an IRF3708 and I checked the emitter's output with a PIN photodiode connected directly to an O-scope without an amp, etc. and the emitter output signal looks very square.

    I was looking at the TSL230 data sheet and it says "Sensitivity is adjusted using an electronic iris technique
    — effectively an aperture control — to change the response of the device to a given amount of light.... Changing of sensitivity also changes the effective photodiode area by the same factor."

    So I had presumed that the sensitivity was adjusted by a process of enabling/disabling photodiode "pixels" that altered the effective area of detection. That's why I had hypothesized an internal "BB counter" that was doing some kind of high speed integration.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-10 12:25
    ...the emitter output signal looks very square.
    But how long is it, compared to the pulse from the Prop?

    -Phil
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-08-10 13:33
    But how long is it, compared to the pulse from the Prop?...

    I see your point. I'll have to re-check it and see. At the time it looked "good enough" but I confess I didn't write down anything about it. Since it was wired on a breadboard with lots of overly long wires, I figured the squareness of it was a good enough sign I didn't have any weirdness going on. I'm waiting on the PCB to do any "serious" testing, but maybe I can re-check the kluge tonight.

    Thanks for the insights.
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2011-08-10 14:03
    I'm not very familiar with the TSL230. What is the residual count rate in the "dark", and would there be any point to gating the counter with the pulse that activates the light source?

    At 8.2 µS duration pulse per every 820 µS, the total ON time each second would be about 9.9 ms, so an average frequency of 712 Hz would translate to an instantaneous frequency of 72.5 kHz, if the "dark" count is zero.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-08-10 14:14
    I'm not very familiar with the TSL230. What is the residual count rate in the "dark", and would there be any point to gating the counter with the pulse that activates the light source?....

    Hi Tracy,
    my notes show dark counts of about what's shown below. I say "about" because they were done on a bench top in a dark room but there were plenty of stray lights on in the room - VGA, Oscope, etc so it would change a little as time moved on. Not to mention the presence of my brilliant personality, no doubt adding something there to that 1 Hz count.

    Sensitivity
    1X = 1 Hz
    10X = 1
    100X = 12

    I'm not sure how gating would help anything. I was just trying to get a read on the emitter's light intensity at various current levels. Everything seems to make sense until the emitters get beyond a certain brilliance, at which point the 100X count starts to asymptotically flatline while the other two remain in agreement. At the limit of their brilliance, then I start to see the 1X and 10X go out of agreement, too. So I figured it was some sort of sensor saturation phenomena.
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2011-08-10 14:40
    The dark levels are practically negligible then and there would be no point in gating unless it gave some insight into residual pulses that occur for outside of the window due to light source turning off slowly or due to delays in the TSL230 signal chain.

    Photodiodes do reach a saturation point at high light levels, due to the onslaught of "BBs" of light, when no additional electron-hole pairs can be produced. I doubt if your experiment is anywhere near that situation. You can point a 3mW laser at a 1mm square photodiode and still be in the linear region, but increase that to 30mW and it may not give the expected 10x increase. Similarly, focusing on a tiny spot instead of the whole area of the photodiode should produce the same current as focussing it on the entire area (on the order of 0.5 A / W) but if the spot is small enough it will locally be in saturation. In your test, non-linearity due to the silicon itself would be felt on all the electronic sensitivity settings.

    I am not clear on the statement you brought up from the data sheet, "Sensitivity is adjusted using an electronic iris technique— effectively an aperture control — to change the response of the device to a given amount of light.... Changing of sensitivity also changes the effective photodiode area by the same factor.", how that is accomplished, I wonder?
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-08-10 15:06
    ... I doubt if your experiment is anywhere near that situation. You can point a 3mW laser at a 1mm square photodiode and still be in the linear region, but increase that to 30mW and it may not give the expected 10x increase....

    I don't know how to compare what the data sheet says the TSL230 can read vs. what this IR emitter cranks out: the geometric conversion (steradians vs. cm2 etc) isn't something I've taken a look at since I was only looking at the overall output. The 8.2 usec pulses shoot about 1 amp through the emitter and drop about 2.3 volts, which, according to the emitter's data sheet, should output an instantaneous value of about 1000 mW/sr. I have the TSL230 placed about 7 inches from the emitter. You think that might be comparable to a laser? Maybe the detection area of the TSL230 is very small compared to what you mentioned above about the laser+photodiode???

    http://www.vishay.com/docs/81090/tsff5210.pdf

    http://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/27924-tsl230r.pdf
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2011-08-10 16:05
    I don't know the active area of the TSL230, but supposing it is 1 mm^2, then at 7 inches distance it would subtend a solid angle of about 0.000032 sr, and at 1000 mW/sr, that is 0.032 mW hitting the silicon. No danger of saturation.

    Again, Phil's assessment applies to what you were seeing I think. Any effects from nonlinearity in the silicon might only be evident if you bring the sensor right up against the emitter. All channels including the lowest would probably be saturated electronically by then. It is hard to find data on the maximum power where a Si photodiode becomes non-linear. It depends on wavelength, (i.e., most sensitive at 940nm for example), and it is a gradual departure from linearity.

    I've used the Osram SFH4550 IR led for smoke detection. A 1A pulse it puts 5000mW/sr at the beam center into a cone 3 degrees to half-power points.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-10 16:07
    I was on the phone with a TAOS engineer, so I asked about the TSL230. Here's what I found out:
    1. The sensor is actually a 10x10 array of photodiodes. The S0 and S1 sensitivity settings gate either 100, 10, or 1 photodiode into the current-to-voltagefrequency converter.

    2. The saturation condition is a hard limit on the current that can be sourced to the current-to-frequency converter from the aggregate of the gated photodiodes.

    -Phil
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-08-10 17:18
    ....

    I've used the Osram SFH4550 IR led for smoke detection. A 1A pulse it puts 5000mW/sr at the beam center into a cone 3 degrees to half-power points.

    Wow. I need to look at those. And if you know of anything even more powerful, let me know. :-)



    I was on the phone with a TAOS, so I asked about the TSL230. Here's what I found out:
    1. The sensor is actually a 10x10 array of photodiodes. The S0 and S1 sensitivity settings gate either 100, 10, or 1 photodiode into the current-to-voltage converter.

    2. The saturation condition is a hard limit on the current that can be sourced to the current-to-frequency converter from the aggregate of the gated photodiodes.

    -Phil

    That's excellent - makes it clear now what's happening. I'm always nervous when my little black boxes start acting up and I don't know why. But this nails it. I guess that explains what they meant by electronic aperture.

    But I think I'll run some more rigorous tests on all of this once I get the PCB put together. That much current is bound to make something strange start to happen.

    Thanks, you guys.
Sign In or Register to comment.