Loading ...
Sorry, an error occurred while loading the content.

Re: [beam] Led's as light and motion sensors

Expand Messages
  • wilf
    Hi Adi, Sorry I can t reply this evening to all the fine ideas being proposed but I will have more time tomorrow to participate. Mean time here is a short
    Message 1 of 23 , Mar 1, 2006
    • 0 Attachment
       
      Hi Adi,
       
      Sorry I can't reply this evening to all the fine ideas being proposed but I will have more time tomorrow to participate. Mean time here is a short description of how the very low photo current of the LED photosensor can be measured and some limitations in muxing LED sensors.
       
      I'm sure that everyone understands the principle of operation of the LED photo sensor/indicator using a uController with the LED/resistor connected across two outputs but let me try to summarize it anyway.
       
      The circuit measures light by measuring the time for discharging a small cap through photo leakage current. 
       
      Note how the LED is reversed biased and the parallel junction and stray capacitance is charge up to Vcc in step 3) but the actual light sensing measurement occurs in step 4) to 6).
        
      1)The LED is connected with the anode to output1 and the cathode to output2.
      2)The LED, as an indicator, is turned on by making output1=Vcc and output2=0V.
      3)The LED, as a sensor, is first reverse biased with output1=0V and output2=Vcc.
      4)Then output2 is switched to become input2 and a timer is started.
      5)Then the voltage at input2 starts to decay from Vcc to 0V with a time constant set by C(LEDjunction)/I(LEDleakage)
      6)When the voltage at input2 crosses the switching threhold the timer is stopped.
      7)The timer value is converted being inversely proportional to the light level.
       
      For a more predictable discharge duration, the time constant can be controlled with a real capacitor instead of using unknown stray capacitances. With a 22pf capacitor across the LED, the TC is less than 1ms in moderate light.   
       
      Since the TC measurement involves very small leakage current there are a number of subtle problems. The LED dark current increases with junction temperature, and temperature changes from self heating  in the display mode, so there can be an interaction between sensing and indication.
       
      The term LED array implies a x/y matrix like the commercial 5x7 type arrays, however such a matrix cannot be used for this application as the input measured side of each LED must be completely isolated from the other LEDs during the TC measurements to avoid other leakage paths from changing the TC.
       
      With a 8x8 array scanned 8 LEDs at a time, you would need 65 uController I/O bits but you could read all bits at one time!  Alternatively you can measure 32 LEDs at a time but you would still need 64 individual inputs. The solution is to use eight 74HC4051 and a comparator.      
       
      wilf
      ----- Original Message -----
      Sent: Tuesday, February 28, 2006 12:45 AM
      Subject: Re: [beam] Led's as light and motion sensors

      Yes,alternating switching (sorry for the clumsy description).
      Adi

      On 2/28/06, wilf <wrigter@...> wrote:
      >I'm wondering if there is any advantage to have the LEDs flash at some offsets, say in 2 cycles.
       
      Do you mean half of the LEDs are in the display mode while the other half is in the sensor mode and then they swap mode, etc?
       
      wilf
    • Adi Shavit
      Hi Wilf, Thanks for the great explanation. The term LED array implies a x/y matrix like the commercial 5x7 type arrays, ... So this means they cannot all be
      Message 2 of 23 , Mar 3, 2006
      • 0 Attachment
        Hi Wilf,

          Thanks for the great explanation.

        The term LED array implies a x/y matrix like the commercial 5x7 type arrays, however such a matrix cannot be used for this application as the input measured side of each LED must be completely isolated from the other LEDs during the TC measurements to avoid other leakage paths from changing the TC.

        So this means they cannot all be measured simultaniously, right?

        With a 8x8 array scanned 8 LEDs at a time, you would need 65 uController I/O bits but you could read all bits at one time!  Alternatively you can measure 32 LEDs at a time but you would still need 64 individual inputs. The solution is to use eight 74HC4051 and a comparator.      

        Let me see if I understand you correctly.
        Using the 8 74HC4051 [1], each connected to 8 array LEDs, say a single column, you can simultaniously measure 8 LEDs, a single row, all with the same 3-bit address of the 74HC4051 and cycle through all addresses/rows to get the full measurement.

        Where is/why the comparator?

        Thanks,
        Adi



        [1] "74HC4051: This device connects together the outputs of 8 switches, thus achieving an 8 channel Multiplexer. The binary code placed on the A, B, and C select lines determines which one of the eight switches is "on", and connects one of the eight inputs to the common output."
      • wrigter
        Hi Adi, Correct so far! Let me expand on this LED indicator/sensor design using the uController example. It takes two steps for a uController to measure a LED
        Message 3 of 23 , Mar 3, 2006
        • 0 Attachment
          Hi Adi,

          Correct so far!

          Let me expand on this LED indicator/sensor design using the
          uController example.

          It takes two steps for a uController to measure a LED
          sensor:

          a) use two output pins to reverse bias the LED sensor and
          charge the capacitor b) Change one of the output pins to
          input which causes the capcitor to discharge through the LED
          photo leakage current and measure when voltage of the
          capacitor decays to to the switching threshold of the input
          pin.

          In addition the two output pins can be used to drive the LED
          as an indicator.

          The 4051, being a bi-lateral analog gate, is transparent to
          both steps:
          a) when the uController output pins reverse bias the LED
          through the gate
          b) when the decaying voltage on the capacitor is measured
          through the 74HC4051 gate at the input pin of the
          uController.

          And in addition, the 4051 is transparent to driving the LEDs
          as indicators.

          The uController would control the LED as indicators and mux
          8 of 64 LEDs on or off at a time though the 4051 gates and
          then the uController would measure 8 of 64 LEDs as sensors
          at a time using:

          a) 3 output pins for address
          b) 1 output pin (buffered) for indication/sensing switching
          of the LED commons
          c) 8 input/output pins for LED driving and LED sensing.

          The indication and sensing can all be done through the 4051
          muxes

          For acurate measurements the uController input pins should
          be equipped internally with comparators to acurately measure
          when the analog input voltages cross the internal threshold.
          The internal threshold value should be adjustable to
          optimize measurement for changes in ambient light level.

          The simplest method of determining the time constant of the
          decay of the 8 LEDs is - Start a timer, sample 8 input
          (comparator) pins and store timer value in variables as
          each of the decaying LED voltages crosses the threshold.

          By varying the comparator threshold and rapidly sampling the
          same 8 inputs during the TC decay

          Since analog gates have very low leakage when off, the
          analog gates isolate the 8 active LED sensors from the other
          LEDs to avoid crosstalk of LED photocurrents.

          wilf



          > Hi Wilf,
          >
          > Thanks for the great explanation.
          >
          > The term LED array implies a x/y matrix like the
          > > commercial 5x7 type arrays, however such a matrix cannot
          > > be used for this application as the input measured side
          > of each LED must be completely isolated from the other
          > > LEDs during the TC measurements to avoid other leakage
          > > paths from changing the TC.
          > >
          >
          > So this means they cannot all be measured simultaniously,
          > right?
          >
          > With a 8x8 array scanned 8 LEDs at a time, you would need
          > > 65 uController I/O bits but you could read all bits at
          > > one time! Alternatively you can measure 32 LEDs at a
          > > time but you would still need 64 individual inputs. The
          > solution is to use eight 74HC4051 and a comparator. >
          >
          > Let me see if I understand you correctly.
          > Using the 8 74HC4051 [1], each connected to 8 array LEDs,
          > say a single column, you can simultaniously measure 8 LEDs
          > , a single row, all with the same 3-bit address of the
          > 74HC4051 and cycle through all addresses/rows to get the
          > full measurement.
          >
          > Where is/why the comparator?
          >
          > Thanks,
          > Adi
          >
          >
          >
          > [1] "74HC4051
          > <http://www.fairchildsemi.com/pf/MM/MM74HC4051.html>: This
          > device connects together the outputs of 8 switches, thus
          > achieving an 8 channel Multiplexer. The binary code placed
          > on the A, B, and C select lines determines which one of
          > the eight switches is "on", and connects one of the eight
          > inputs to the common output."
          >
        • Adi Shavit
          Hi Wilf, I think this is about how if understood it. The comparator is needed inside the uController for measurement. Staying with the uController design, I
          Message 4 of 23 , Mar 5, 2006
          • 0 Attachment
            Hi Wilf,

              I think this is about how if understood it.
            The comparator is needed "inside" the uController for measurement.

            Staying with the uController design, I have some more related questions.

            Essentially, the process has 3 phases:
            1. Indication - turn LED on
            2. Sensing - reversed biased LED and charging of the capacitor
            3. Measurement - measuring the sensed light levels using a timer and cap discharge.
            In the uController configuration, the time for step 1 can, obviously, be set arbitrarily.
            It seems to me that step 2 has some minimum time limit to allow the cap to charge but after that the processors can switch to the next phase at leisure. Is this about right (assuming no major changes in ambient light)?
            Step 3 is, obviously time dependent, as the uController must wait for all caps to discharge. 

            And in addition, the 4051 is transparent to driving the LEDs as indicators.

            The uController would control the LED as indicators and mux 8 of 64 LEDs on or off at a time though the 4051 gates and then the uController would measure 8 of 64 LEDs as sensors at a time using:

            a) 3 output pins for address
            b) 1 output pin (buffered) for indication/sensing switching of the LED commons
            c) 8 input/output pins for LED driving and LED sensing.

            The indication and sensing can all be done through the 4051 muxes

            This is very clever. Muxing time for pins.
            In fact, if you look a the video it seems to be doing exactly that.
            The first thing the device does is flash each column separately. That's what got me thinking about time muxing in the first place.
            My guess is that at this step the device is measuring the base ambient light for each of the LEDs (8 simultaneously), to get a baseline for comparison later during operation.

             
            By varying the comparator threshold and rapidly sampling the
            same 8 inputs during the TC decay

            What is the formula for the relation between the ambient light and the cap discharge time?
            How can this value later be related to the switching on of the LED if I want it to be on at the same intensity?
            What's the math?

            Thanks,
            Adi

            PS,
            Wilf, did you get my off-list email?
          Your message has been successfully submitted and would be delivered to recipients shortly.