Pages: [1]   Go Down
Author Topic: Measuring tiny intervals  (Read 1047 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Sorry for my first post in this forum being stupid questions ;-)
I also hope that there is not already a thread covering this topic. I searched but the results seemed not to suit my intentions.

My problem is as follows.

I want to check the shutter speed of my 'analog' cameras. Therefore I decided to use a photo diode as sensor together with a pull down resistor. The circuit seems to work well.

The corresponding program checks whether the status of a digital input pin has changed. When it has changed to HIGH, it stores the value returned by micros(). When it falls back to LOW, it calculates the diference between the current result of micros() and the previous value.

The time in micro seconds is then output via serial console.

At first I was very happy as everything worked as planned. However, when intervals get shorter there is no more linear correlation and the values returned seem to level off around 3000-4000 microseconds. That corresponds to a shutter speed of 1/250s.
 
First I thought that this might account to that fact that for focal plane shutters the time the "slit" is moving across the film plane is usually longer than the exposure time. However, I observed the same result for central shutters.

My questions:

Is it possible that the time the code needs to run is too long to measure intervals shorter than 4000 microseconds? How can I improve this?

Is it possibile that my circuit is too slow. e.g. not producing steep signals? Maybe I need a photo sensor which automatically integrates the light intensity like those used in light meters?
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11197
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it possible that the time the code needs to run is too long to measure intervals shorter than 4000 microseconds? How can I improve this?

Is it possibile that my circuit is too slow. e.g. not producing steep signals? Maybe I need a photo sensor which automatically integrates the light intensity like those used in light meters?

Both possibilities seem feasible. It's impossible to tell whether your code is capable of measuring short intervals without seeing the code, though.

Do you know what the response characteristics of the photodiode are? Is it actually capable of responding to changes fast enough to detect the shutter opening and closing at your required speeds?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 21
Posts: 1670
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
    With regards to the smallest interval that Arduino can measure, I saw that at the hardware level timer1 has an 'input capture' facility that I would expect to be much faster and more accurate than calling micros().

    I have not used it myself but I have had it at the back of my mind to experiment with it, so if no-one else comes up with anything, I will have a go at using this to measure very short intervals and post my code/experience over the weekend.

If you want to have a go for yourself, its in the ATMega328 datasheet in the 16 bit timer section and I am sure there are examples for using it if you search around.

Duane B

rcarduino.blogspot.com
« Last Edit: February 21, 2012, 10:57:18 am by DuaneB » Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Both possibilities seem feasible. It's impossible to tell whether your code is capable of measuring short intervals without seeing the code, though.
I will provide the code later today when I have access to my other PC. However it seems really simple to me only consisting of a digitalread() and some if/else branches.

Quote
Do you know what the response characteristics of the photodiode are? Is it actually capable of responding to changes fast enough to detect the shutter opening and closing at your required speeds?

It is a BPW40 type if I am not mistaken. In the meantime, I figured out that the circuit used is probably limited to a frequency of about 8000 Hz which could be too slow.
For higher frequencies people use the photodiode in a quasi short circuit and use a transimpedance amplifier to convert the current into a proportional voltage.
The latter would take a little longer to test because I do not have a circuit diagram or the necessary parts at hand.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31543
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I will provide the code later today
Good, can you provide a schematic as well.

The point is that depending on how long it is between looks at the sensor, you might miss some time. It could be that you need to use the interrupts to do the timing.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the code

Code:
int receiverPin = 12; // input from the ir receiver.
int value = 0 ; // status of digital input
int prevvalue = 0; // previous state of the digital input

unsigned long duration = 0; // time shutter is open
unsigned long starttime = 0; // for counting the time
unsigned long endtime = 0;

void setup()
{
  pinMode(receiverPin, INPUT);
  Serial.begin(9600);
}

void loop()
{
 
  value = digitalRead(receiverPin);
  if (value != prevvalue)
  {
      if(value==LOW)
      {
       // Serial.println("LOW");
        starttime = micros();
      }
      else
     {
      // Serial.println("HIGH");
       endtime = micros();
       if( endtime > starttime)
       {
      duration = endtime - starttime;
      Serial.println(duration);
       }
     }
      prevvalue = value;
  }
}
 

Now that I think of it, the circuit must actually have been using a pull-up resistor. Otherwise it would not work with a LOW signal when light hits the photo diode.

The circuit was similar to this one. Only the resistor was different.

Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried your exact code, feeding in a 50 kHz signal (20 uS period) which would give 10 uS as the interval between low and high. It output:

Code:
8
12
8
12
12

So, slightly out for 20 uS (10 would be the correct answer as there are two pulses per interval).

So your code is OK - interrupts might improve it slightly, but probably not by much. Indeed, interrupts take 3.5 uS or so to service, and the error amount is less than that.

Therefore the problem is hardware, probably the time taken for the sensor to react.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 4036
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You -could- use the light detector to charge a small R-C and time the bleed over a much longer period than the shutter open and close. It would need to be calibrated, say keep the shutter open while you blink the light source (a led for instance) for a known time (1/100th of a second?). After all, what does the film get? Light and duration.

Logged

Examples can be found in your IDE.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Therefore the problem is hardware, probably the time taken for the sensor to react.

Thank you very much for testing.

After reading a little bit about the mode of operation of photo diodes I am pretty sure, that the circuit is too simple.

I think I will try the method using a transimpedance amplifier.

I also thought that a photo transistor which has an additional base connector might work better. But that would be my second choice.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You -could- use the light detector to charge a small R-C and time the bleed over a much longer period than the shutter open and close.

Just for my understanding:

When light hits the photo diode, the current flowing is used to charge a condensator.
The condensator then discharges through a resistor which takes longer due to the lower current.
For me it seems that I still need something like an IU-converter because Arduino measures voltages and not currents, am I mistaken?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Me stupid...

The BPW40 is a photo transistor, not a photo diode. I think I should get myself a real photo diode before I think about improving the circuit.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 4036
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You -could- use the light detector to charge a small R-C and time the bleed over a much longer period than the shutter open and close.

Just for my understanding:

When light hits the photo diode, the current flowing is used to charge a condensator.
The condensator then discharges through a resistor which takes longer due to the lower current.
For me it seems that I still need something like an IU-converter because Arduino measures voltages and not currents, am I mistaken?

You are close. While the discharge is happening, the circuit is read digital in a loop that only increments a counter (how many cycles, read-branch?) and when the voltage drops below, I think, 1.1V the loop is terminated and the count says how long.

Normally I see it used with very small R-C values leading to very short intervals, the ability to time < 4 usecs in some topics. Always for short and precise the interrupts are turned off while measuring.

The thing is that you don't need to match the interval of shutter operation in the process of digitizing. You can use an R-C combination that takes longer to bleed than the shutter took to blink. The capacitor is going to take as long to bleed as it does. The charge came controlled by how much light got through. You can to a large degree create your own precision by controlling how much current goes to the R-C (transistor circuit) and what you used in the R-C. The thing there is you don't want interrupts off so long and still rely on counters and some other things, it's frowned on but I think possible.
Logged

Examples can be found in your IDE.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I just want you let you know that I tried using a real photo diode (BPW 34) instead of the photo transistor.
It really makes a difference! Measuring down to about 500 µs opening time is possible. That's more than sufficient for my purposes.
Logged

Pages: [1]   Go Up
Jump to: