Connect with us

LED as a Sensor and Indicator

Discussion in 'Sensors and Actuators' started by eleeng, Jun 1, 2013.

Scroll to continue with content
  1. eleeng

    eleeng

    7
    0
    May 24, 2013
    [​IMG]
    LEDs can also be used as sensors, as discussed in the introduction of this chapter. In fact, LEDs can act as alternating light emitters and sensors so rapidly that there is a perception of there being two
    devices in one. To use an LED as a sensor without an ADC, one needs to reverse-bias the LED. To use the LED as an emitter, that is, in its normal use, one needs to forward-bias it. In this [ link removed ]electrical engineering project we
    show how an LED can be used to sense light without using expensive ADCs. The same LED is also used as an indicator of the sensed light. An LED under reverse-bias conditions can be modeled as a light-dependent current source in parallel with a capacitor. The more incident light there is, the larger is the current source value, and that discharges the equivalent capacitor faster. In the following illustration, the LED is reversebiased, with the anode connected to ground and the cathode connected to a microcontroller pin (pin 2). The microcontroller applies Vcc to pin 2, which charges the equivalent capacitor. Subsequently, the cathode of the LED is connected to an input pin (pin 1) of the microcontroller. The capacitor that was charged to Vcc will now discharge through the current source, and when the voltage on the capacitor falls below the lower logic threshold, pin 1 of the microcontroller will sense the logic as “0.” If the incident light intensity is greater, the
    capacitor discharges faster; and if the ambient light is less, it takes longer for the capacitor to discharge. Thus, by measuring the time it takes for the voltage on pin 1 to reach logic “0,” the microcontroller can estimate the intensity of the ambient light incident on the LED.

    Design Specifications
    The objective of the project is to use an LED as a sensor and to use the same LED to output the information about the sensed light. The illustration below shows the block diagram of the project. A single LED and a handful of other components are used. The LED blinks, and the rate of blinking is proportional to the ambient light falling on the LED. Thus, if the LED is placed under bright light, it blinks faster compared to when the ambient light falling on the LED is less.

    Design Description
    Figure 5-1 shows the schematic of an AVR ATTiny15-based circuit that uses a 3-mm, red LED (LED1) in a clear packaging to sense the ambient
    light as well as to indicate the incident light intensity by flashing the same LED at a proportional frequency. The circuit is simple and uses just four components. The power supply to
    the circuit can be any voltage between 3 and 5.5V DC. The LED is connected to port pins PB0 and PB1 of the AVR microcontroller. Another port pin, PB3, is used to output a square wave, with a
    frequency proportional to the incident light intensity. The circuit operates by first forwardbiasing the LED for a fixed period. It then applies reverse-bias to the LED by changing the bit sequences applied to PB0 and PB1. In the next step, PB0 is then reconfigured as an input pin.
    [​IMG]
    [​IMG]An internal timing loop is used to measure the time it takes for the LED to change the logic voltage applied to PB0 from logic “1” to logic “0.” This time, T, is inversely proportional to the ambient
    light incident on the LED. The LED is then flashed at a frequency inversely proportional to the time T. Thus, for lower light levels, the LED flashes at a lower frequency. As the incident light intensity
    increases, the LED flashing frequency increases. This provides a visual indication regarding the incident light intensity.

    Fabrication
    The schematic of the project can be downloaded from [ link removed ]. The circuit is fabricated on a small generalpurpose circuit board, as seen in Figures 5-2 and 5-3. The circuit has just five components.

    Design Code
    The design code for this project is written in assembly language, as shown in Listing 5-1. The code first initializes PB0 and PB1 as output and sets PB0 to “1” and PB1 to “0” to reverse-bias the LED. It then sets PB0 as an input pin and waits for the LED cathode (connected to PB0) to discharge to logic “0.” The time is stored in register R19.
    [​IMG]
    Code:
    .include "tn15def.inc"
    .cseg
    .org 0
    ;LED as light sensor...
    main:
    ldi r16, 255
    out DDRB, r16
    ldi r16, 0
    out PORTB, r16
    ldi r19, 1
    rcall delay
    ldi r19, 1
    new_main:
    sbi DDRB, 0
    nop
    nop
    sbi PORTB, 1 ; LED forward bias
    cbi PORTB, 0
    rcall delay
    sbi PORTB, 0
    cbi PORTB, 1 ; reverse bias
    cbi DDRB, 0 ; LED discharge
    cbi PORTB, 0
    ; set registers for minimum delay
    ldi r19, 1
    wait_here:
    sbis PinB, 0
    rjmp its_one
    rcall min_delay
    inc r19
    brne dont_inc_r20
    rjmp over_flow
    dont_inc_r20: rjmp wait_here
    over_flow:
    its_one:
    in r16, PORTB
    ldi r17, 0b00001000
    eor r16, r17 ; toggle PB3 to generate frequency prop to light
    out PORTB, r16
    mov r2, r19
    rcall delay
    mov r19, r2
    rjmp new_main
    delay:
    ldi r20, 0
    dec_r20:
    dec_r21: dec r20
    brne dec_r20
    dec r19
    brne dec_r20
    ret
    min_delay: in r0, SREG
    ldi r18, 200
    not_over:
    dec r18
    brne not_over
    out SREG, r0
    ret
    It then configures PB0 again as an output pin and the LED is forward-biased (to light up the LED) for a time equal to the time stored in register R19. Thus, if the microcontroller measures T time units as the time it takes to discharge the LED in the first measurement cycle, it turns the LED on for T time units. The frequency at which the LED is pulsed is proportional to the light incident on the LED.

    Working
    The circuit was tested by applying light of known intensity through a test LED. For low values of LED forward current, the light output intensity is fairly linear. The light output of the test LED was
    coupled to the sensor LED (LED1 in Figure 5-3) of the circuit. It was ensured that no other external light was incident on the sensor LED by enclosing the test LED and the sensor LED in a sealed tube
    covered with black tape. The test LED current varied between 0.33mA and 2.8mA. The corresponding output of the sensor LED flashing frequency was recorded and is shown as a plot in Figure 5-4. As can be seen in this figure, the circuit provides a fairly linear output.
    [​IMG]
    The ATTiny15 AVR microcontroller is an eightpin device. The circuit presented here uses only three out of the six I/O pins. The rest of the pins can be used to control external devices or for communication with other devices. The efficiency of using an LED as a sensor depends upon current source and capacitance values of the LED operated in reverse-bias. We estimated these values to compare with the figures reported in literature. To estimate the reverse photocurrent, we connected a 1-meg-ohm resistor in parallel with a sensor LED and measured the voltage across the resistor. The sensor LED was subjected to constant illumination and voltage across the resistor noted. We changed the resistor value to 500 kilo-ohm and 100 kiloohm and repeated the measurement. The resultant photocurrent for the constant illumination was observed to be around 25mA for all the measurements. For the same illumination on the sensor LED, the frequency generated by the circuit in Figure 5-3 was measured, and delay loop times, current, and voltage were substituted in the equation dv/dt = I/C to calculate the reverse capacitance. The calculated values lie in the range of 25 to 60pF.
     
    Last edited by a moderator: Jun 1, 2013
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
Loading...
Electronics Point Logo
Continue to site
Quote of the day

-