-2

LED blinks at frequency f.

Sensor is closed during waitingPeriod and opened during exposurePeriod to receive light from LED.

enter image description here

Assume that the LED is turned On from the start. How to calculate the effective exposure period of sensor, that is the period when sensor is open and LED is turned On.

(I use Matlab but pseudo code is OK).

Thanks!

opmfan
  • 191
  • 1
  • 3
  • 14
  • By the looks of that diagram, I would say the answer is: `effective_exposure_period_of_sensor = 1 / f`. Is that what you were asking? If not you may need to clarify the question. – Alan Jul 19 '15 at 08:24
  • Of course it's not. The frequency f of LED, waiting period and exposure period of sensor are variables, not constantsn. – opmfan Jul 19 '15 at 08:34
  • @Alan: what if I shorten the waiting period, or lengthen the exposure period, or increase the frequency (note that LED keeps blinking) – opmfan Jul 19 '15 at 09:16
  • I had guessed as much, but gave in to the temptation to play Socrates and ask the obvious foolish question in order to push for more information. In general being as clear and thorough as possible about the problem you have and providing some idea of what you have tried already will help make things easy for others to give you good answers. – Alan Jul 19 '15 at 18:12

2 Answers2

2

Let led(t) be a function which is 1 when the led is turned on and 0 otherwise. Let s(t) be a function which is 1 when the sensor is turned on and 0 otherwise. The product of both function ee(t) :=led(t) *s(t) defines the effects exposure periods. The integral of ee(t) is the total effective exposure time.

Some example code:

f=2
waiting=13
exposure=42
led=@(t)(mod(floor(t*f),2)==1);
s=@(t)(t>waiting&t<waiting+exposure);
ee=@(t)(s(t).*led(t));
q = integral(ee,0,inf);
Daniel
  • 36,610
  • 3
  • 36
  • 69
  • Thanks @Daniel, I found the answer which is related to range intersection by myself. I define the range that LED is turned on and intersect with the range of sensor exposure. The integral of the result range is the total exposure time. Your solution is interesting. But I wonder how can I define or create those function s(t) and ed(t) in Matlab. – opmfan Jul 19 '15 at 10:17
  • Thank you very much @Daniel ^.^ – opmfan Jul 19 '15 at 11:04
2

Here is an approach using built-in functions (Signal Processing Toolbox) to create the signals. T_eff is the result you're looking for.

f = 5;                          % Frequency of LED in Hz
T_init = 0.15;                  % initialization time (waiting) in s
T_exp  = 1;                     % exposure period in s

LED    = @(t) 0.5*square(2*pi*f*t)+0.5;
Sensor = @(t) rectpuls(t-T_init-T_exp/2,T_exp);

T_eff = integral(@(s)(LED(s).*Sensor(s)),0,T_init+T_exp)

To verify the result, we can plot the data and compare it:

t = linspace(0,1.5,1000);
figure; hold on;
plot(t,LED(t))
plot(t,Sensor(t))

result

Matt
  • 12,848
  • 2
  • 31
  • 53