LDR replacement TEPT 4400

Hello
I have a simple outside light switching system on an 18M2.
Previously I used LDR's for day night sensing.

6 months ago the LDR failed so I directly replaced it with a Vishay TEPT 4400 all worked well until this last week when the system stopped switching on at night. I replaced the sensor and back to working well again.

The sensor is connected directly between 0v and C0 with a 10k resistor between C0 and 5V+.

Testing the faulty sensor on resistance with my multimeter still shows a change in value between dark and light, but evidentally not enough to allow the board to see what is set to the night value.

This was the same fault with LDR's, after several years they do not go very high resistance in the dark to signal "Night Time".

Have I just been unlucky with a random component failure of is there more I need to do to accommodate the photo transistor?

Thanks Mark
 

PhilHornby

Senior Member
Three similar hardware failures seems unusual...especially for a component like this. Is this an 'environmental' issue? Is the device exposed to the elements, or maybe looking through a 'window' that gets dirty?

Given that that the TEPT4400 is a phototransistor, measuring its resistance may not give a meaningful answer.

What voltages do you see at C.0 ?

How does the Picaxe sense this voltage - as a logic level, or using the ADC functionality?

How is the 'twilight zone' handled ... where light levels are just on the cusp of reaching the threshold. Does the code implement some hysteresis?

(I have been running something similar for the past 9 years, without issue)

A circuit diagram and code listing would be handy for further diagnosis ;)
 
Hi code below, no hystesis. Using ADC to detect voltage between 0 and 5 with 10K in series on C0 to + and the photo transistor between C0 and 0V.

The sensor is outside but under cover and looks down so no direct sunlight, which a previous Australian forum member explained eats LDRs in his country, so to a much lesser effect here was my previous problem.

Code:
#PICAXE 18M2
start0:
' this version of code amended For  8-9-17
'4 Beams NC to 5V+ . LDR to 5V+, Panel has on board isolation switches for each zone
'Day/Night LED, Lights on LED and 4 zone led's

symbol LIGHTS1 = B.0                ; lights relay 1 all outputs are neg high
symbol buzzer1 = B.1                ; Buzzer output
symbol zone1led = B.2                ; Zone 1 LED
symbol zone2led = B.3                ; Zone 2 LED
SYMBOL zone3led    = B.4             ; Zone 3 LED
SYMBOL zone4led    = B.5             ; Zone 4 LED

SYMBOL day_or_night_LED  = B.7         ; Day/Night LED, on at night
SYMBOL Zone1    = pinC.2            ; trigger from detector 1
SYMBOL Zone2    = pinC.5            ; trigger from detector 2
SYMBOL Zone3    = pinC.6            ; trigger from detector 3
SYMBOL Zone4    = pinC.7            ; trigger from detector 4
symbol TIMEPOT = C.1                ; potentiometer input for lights on time on board
symbol LDR     = C.0               ; LDR for night operation to 5V+


SYMBOL Night_Day_Setpoint = 38         ;LDR to + 5v

SYMBOL lights_on  = b0              ; reserved for bit flags
symbol lights1_on = bit0            ; flag = 1 if the zone 1 lights on
symbol lights2_on = bit1            ; flag = 1 if the zone 2 lights on
symbol lights3_on = bit2            ; flag = 1 if the zone 3 lights on
symbol lights4_on = bit3            ; flag = 1 if the zone 4 lights on
SYMBOL time_for_lights = b2           ; how long to leave the lights on
symbol night_or_day     = b3          ; reading from the LDR
symbol light_loop     = b4          ; loop control when lights are activated
symbol light_count    = b5          ; count how long to leave the lights on
symbol light1_count     = b6          ; zone 1 lights on while >0
symbol light2_count     = b7          ; zone 1 lights on while >0
symbol light3_count     = b8          ; zone 1 lights on while >0
symbol light4_count     = b9          ; zone 1 lights on while >0


'======================================================================
Init:
' set all B pins as outputs and low
        let dirsB = %11111111
        let pinsB = %00000000
        

Main:
' Main program loop
' 1 buzz subroutine is required
'
' we will loop forever
    DO

' read the time for lights to be on (from pot)       
        readadc TIMEPOT ,time_for_lights
        readadc LDR ,night_or_day
' depending on whether it is night or day act differently
        if night_or_day <  Night_Day_Setpoint then
' NIGHT time operation - lights and buzzer
' plus keep looping here while another loop has been broken
            lights_on = 0
            light_loop = 0
            light_count = 0
            
            do                            ; Zone NC to 5V+ so 1 is clear
                if Zone1 = 0 then              ; test if zone 1 is (still) active
                    Pause 50                ;anti bounce delay
                    high LIGHTS1                 ; turn on the zone 1 lights
                    gosub buzz1                 ; sound the zone 1 buzzer
                    lights1_on = 1              ; set the zone1 activity flag     
                    light1_count = time_for_lights   ; keep the zone 1 "timer" at max until zone 1 cleared
                end if
                if Zone2 = 0 then              ; test if zone 2 is (still) active
                    Pause 50                ;anti bounce delay
                    high LIGHTS1
                    gosub buzz1
                    lights1_on = 1
                    light1_count = time_for_lights
                end if
                if Zone3 = 0 then              ; test if zone 3 is (still) active
                    Pause 50                ;anti bounce delay
                    high LIGHTS1
                    gosub buzz1
                    lights1_on = 1
                    light1_count = time_for_lights
                end if
                if Zone4 = 0 then
                    Pause 50                ;anti bounce delay
                    high LIGHTS1
                    gosub buzz1
                    lights1_on = 1
                    light1_count = time_for_lights
                end if
                
                IF lights_on > 0 THEN         ; check if ANY zone is active     
                    light_loop = 1          ; set the general alarm flag
                    pause 500              ; wait a while
                    
                    IF light1_count>0 THEN         ; if the zone 1 "timer" is active
                        DEC light1_count        ; then decrement the remaining period         
                    ELSE
                        LOW LIGHTS1             ; otherwise if zone 1 timer at zero 
                        lights1_on = 0        ; turn lights off and clear activity flag
                    ENDIF
                    IF light2_count>0 THEN
                        DEC light2_count
                    ELSE
                        ;LOW LIGHTS1
                        lights2_on = 0
                    ENDIF
                    IF light3_count>0 THEN
                        DEC light3_count
                    ELSE
                        ;LOW LIGHTS1
                        lights3_on = 0

                    ENDIF
                    IF light4_count>0 THEN
                        DEC light4_count
                    ELSE
                        ;LOW LIGHTS1
                        lights4_on = 0
                    ENDIF
                ELSE
                    light_loop = 0
                    
                
                ENDIF
            
' now check whether to keep looping here
' if the light counter is set but is less than the duration check then keep looping
                
            loop while light_loop = 1
        else
' DAY time operation - just sound the buzzer
            
              if Zone1 = 0 pause 50 then gosub buzz1 ;only one buzzer output
            if Zone2 = 0 pause 50 then gosub buzz1 ;triggered by each beam
            if Zone3 = 0 pause 50 then gosub buzz1 ;pause 50 anti bounce
            if Zone4 = 0 pause 50 then gosub buzz1
        end if
    LOOP
'======================================================================
buzz1:            ; buzz on off 4 times
    high Buzzer1   
    pause 500
    low Buzzer1
    pause 500
    high Buzzer1   
    pause 500
    low Buzzer1
    pause 500
    high Buzzer1   
    pause 500
    low Buzzer1
    pause 500
    high Buzzer1   
    pause 500
    low Buzzer1
    pause 500
    return 
    
    
    start1: ;For LED indicators on panel
    Main2:
    if night_or_day <  Night_Day_Setpoint then high day_or_night_led
else low day_or_night_led endif ; this gives a day night LED on the panel
                    ; yellow LED on at night
        
    if zone1 = 0 then low zone1led ; this has 4 LED's to show zone status
else high zone1led endif    ; green LED on if zone clear
    
    if zone2 = 0 then low zone2led
else high zone2led endif
    
    if zone3 = 0 then low zone3led
else high zone3led endif
    
    if zone4 = 0 then low zone4led
    else high zone4led
endif

    goto main2
 

PhilHornby

Senior Member
The max. operating temperature for the TEPT4400 is quoted as 85°C and the venerable ORP12 LDR as 75°C; I can't see any restriction on maximum light level. LDRs are commonly used in Oil Boilers to confirm that they're lit, so I've always thought of them as pretty robust.

I think you need some debugging - despite how impractical that might be - in the form of the voltage at C.0, along with a 'debug' statement to show the corresponding value returned by the readadc LDR ,night_or_day

Note: The code above, can't be the code you're running ...
Rich (BB code):
            if Zone1 = 0 pause 50 then gosub buzz1 ;only one buzzer output
            if Zone2 = 0 pause 50 then gosub buzz1 ;triggered by each beam
            if Zone3 = 0 pause 50 then gosub buzz1 ;pause 50 anti bounce
            if Zone4 = 0 pause 50 then gosub buzz1
26010
 
Last edited:
Top