# How is the integration time set for a camera?

I using the TSL1401R-LF Linescan Camera Module, which reads in a 1 X 128 line of pixels, and I'm having trouble understanding how the integration time is set for this device.

I understand from page 9 that the minimum integration time is a constent that results from a function of the clock speed, but I don't fully understand when this integration period takes place.

According to the timing waveform (Figure 1 on Page 5) the integration period appears to be set after the first 18 clock cycles. Does this mean that the integration period is set while the camera is outputting pixels?

How is that even possible? Also does this mean that in order to achive the minimum delay time I would have to take that time and divide it across those remaining 110 clock cycles (i.e. 307 ns for a total of 33.75 us)?

UPDATE:

This is how I am currently programming the camera. I'm using `delayMicrosecond()` after the HIGH and LOW clock impulses as well as at the end. I have enough delays to achieve the minimum 33.75 microsecond delay, but I'm still having sensitivity problems.

``````int delayTime = 20;

{
digitalWriteFast(SI, HIGH);
delayMicroseconds(delayTime/2);
digitalWriteFast(CLK, HIGH);
delayMicroseconds(delayTime/2);
digitalWriteFast(SI, LOW);
delayMicroseconds(delayTime/2);
digitalWriteFast(CLK, LOW);
delayMicroseconds(delayTime);

for(int i = 0; i < 128; i++)
{
digitalWriteFast(CLK, HIGH);
delayMicroseconds(delayTime);
digitalWriteFast(CLK, LOW);
delayMicroseconds(delayTime);
}

digitalWriteFast(CLK, HIGH);
delayMicroseconds(delayTime);
digitalWriteFast(CLK, LOW);
delayMicroseconds(delayTime);

delayMicroseconds(20);

}
``````

It is quite a difficult system to get your head around, as you have noticed. I'll try and break it down more logically for you...

An important thing to note is that there are two capacitors in each pixel - the integrating capacitor and the sampling capacitor. It's these two capacitors that lead to a certain amount of confusion, and it's vital to understand the role of each one.

Under normal sampling operation light falling on the photodiode of a pixel generates charge through the internal amplifier which is stored in the integrating capacitor. Simultaneously that stored voltage level is mirrored in the sampling capacitor.

When you send the pulse on SI a signal called `HOLD` is generated internally. This signal is sent to all of the pixels and tells them to disconnect their sampling capacitors. They do that through the switch S2. At the same time the integrating capacitor is emptied by S1 causing a short circuit across it. That is held there for 18 clock cycles to make sure that it's completely empty. All this time the sampled voltage is still there in the sampling capacitor.

Then as you continue clocking the pulse you sent in through the SI pin is walked down a 128 bit shift register. As it pops out of each output in turn it connects the sampling capacitor of that pixel to the output buffer so you can read the voltage. It's then flushed out and re-connected to the integrating circuit again to sample the pixel again.

So there is actually multiple things happening during your 129 clocks. Reading and integrating are both happening at the same time. But you're not reading this set of clock's integration, but the last set of clocks integration.

So you have:

• SI pulse - HOLD generated, samples frozen
• 18 clocks of clearing the integrators and reading nothing much.
• 110 clocks of reading nothing much (nothing is sampled yet) and integrating.
• 1 clock to terminate
• SI pulse - HOLD generated, samples frozen
• 10 clocks of clearing the integrators and reading the previously integrated samples 1-18
• 110 clocks of reading the previously integrated samples 19-128 and integrating new ones
• 1 clock to terminate
• ... etc ...

So clocks 130 to 258 are reading the light that was sampled during clocks 19 to 128.

The upshot of all this is that your integrating period is the total time taken for the 110 clocks that occur between the end of the 18 clocks that clear the integrators and the next SI pulse that creates a new HOLD signal.

• Thank you so much, you've made this whole process so clear. But I have a follow up question; why am I still having such poor sensitivity if my integration time is so long? When my delay is set to 170 us I get some really good readings, but when I reduce it to 20 us I suddenly lose all of it. But I'm still above the 33.75 us minimum delay. – sgmm Jul 5 '16 at 14:45
• You still don't understand what happens during integration do you? The longer you integrate for the more sensitive the pixels are. The minimum integration time is the absolute minimum amount of time you have to run for to get a result. That will only be a usable result in a very very bright environment. Sahara at midday bright. The darker your environment the longer you have to integrate for to get any real difference in your values. As I have said before it's like the shutter of a camera. Take a picture with 1/3200s shutter in a dark room and you get nothing. Take a picture with ..... – Majenko Jul 5 '16 at 14:48
• ... 5s shutter in full daylight and you get just white. It is up to you to get the optimal shutter speed (integrating time) that allows enough light in to see the image whilst not letting in too much light so you lose detail. – Majenko Jul 5 '16 at 14:49
• I didn't understand what the minimum delay meant, but I understand what you're saying now. So I have to just deal with the low sensitivity if I want my program to run faster. – sgmm Jul 5 '16 at 14:51