In theory I think your circuit would work, but real components might be hard to find.
I like your use of LDR 1 to inhibit operation in daylight if it can be pointed away from head light & door light, but see day light.
Here is my take of a light control. LDR 2 is in a 2 in. X 1/2 in . tube.( block of wood with a hole ). End of tube can be covered with red or clear plastic to keep out bugs. I used red with headlight test. C1 - R3, any combination to give 5 min. 470 uF more common than 500 uF ? Supply V to match relay. If R2 pot not available try 4.7 k. for R1 + R2. LDR size not critical, mine is 1 cm. 1 meg. to 200 ohm.
Left my design suite hardware key at home - GRRRR. word schematic -
1 - CD4093
1 - decoupling capacitor
2 - LDR
2 - LDR bias resistors
1 - timing capacitor
1 - timing resistor
1 - timing diode
1 - 2N7000 MOSFET
1 - relay and diode, relay current 100 mA or less
Two LDRs and 2 resistors form a bridge. LDR1 is on the low side as the daylight sensor. LDR2 is on the high side as the headlight sensor.
The two bridge leg centers go to 2 inputs of a 4093 NAND gate. When dark, daylight side goes high; when headlights arrive, headlight side goes high; when both inputs are high, gate a output goes low.
Gates b and c form a true monostable (3 minute period), triggered by low from gate a.
Gate c output drives 2N7000 MOSFET transistor, the relay coil driver.
Because a true monostable has feedback (unlike a 555), it will time out 3 minutes even if the headlights go off quickly, or come and go multiple times during the timing period. After the timing period, it will not retrigger until LDR2 goes dark and then light again. The timing diode is in parallel with the timing resistor so the monostable takes fewer than 3 minutes to reset.
The bridge input allows the two LDRs to be the same part, even though they are responding to very different light levels, by adjusting their bias resistors. A more gutsy move is to get two LDRs with ON resistances about 10:1 different and put them in series with no bias resistors. This would make sensor placement much more critical to the circuit's success. Hmmm - maybe too gutsy.
The only static current in the circuit is through the LDR legs. Even with very high value LDRs, battery life might be inconvenient. Offline power circuits are not allowed on this forum, so I recommend a $2 12 V wall wart to run the circuit.
Bernard, ak thanks for taking the time to come up with the circuit ideas, much appreciated.
Will have a go at building both circuits, think I have most of components to build the 555 timer based circuit, so will probably try it first. Will try changes as mentioned by dodgydave, and adjust C1 and R3 for 3min.
If it's not too much trouble ak could you provide me with a wiring diagram for your circuit and component values, think I'd go without the 10:1 type ldr though, and power it from a 12v supply as recommended.
Thanks again guys.
First pass at the design in post #24. Note that the LDR and bias resistors (R1-R4) will have to be selected based on what you can get for the LDRs. The 100K values are place holders; select R3 and R4 to get the trip points you want. You might want to replace each one with a fixed resistor and a trimpot in series to give you an adjustment range.
The four gates are used in a different order to make the wiring easier. The timer works out to about 3.7 minutes. Adjust R5 to taste. P1 and P2 can be connectors on a perf board, a terminal block, or just about anything else you want to use. The wires from the sensors can be connected directly to the circuit, but this makes installation and experimenting difficult.
One issue with this design is that the raw +12 V is out in one of the wire runs to a sensor. The next post fixes this.
Second pass. This is the same basic circuit with all of the same parts, with the relay drive taken from the other monostable output polarity. This frees up U1C to invert the signal from the headlight sensor so that one also is direct connected to GND rather than +12 V. This should prevent accidental shorts from killing the power source. The timing and sensitivity caveats from above apply here.
Thanks ak will have a go at building the second circuit. I understand it up to U1D, U1A and B that are tricky.
Can't really see how it operates the relay, could you explain further?
Could I run circuit on 5v as I have a 5v relay, and supply?
Had a go at 555 timer circuit thought it worked best without ldr1. Think it will work with one ldr in shade, probably burried a few inches in garage door then brightness of headlights will be enough to trigger the circuit.
Had it working on breadboard turned lights on and off to trigger circuit, adjusted rc to give more accurate time, all seemed good.
Don't see point in having ldr1 as it doesn't stop ldr2 from conducting, or am I missing something?
Post #26 is the more conventional of drawing it. When the circuit is at rest, R5 holds the inputs to U1B low. So pin 4 is high. Pin 1 is the trigger input. When it is high, pin 3 is low, so both sides of timing capacitor C1 are low.
When pin 1 goes low, pin 3 snaps high. Since the voltage across a capacitor cannot change instantaneously, the other end C5 snaps high. U1B is acting as an inverter, so pin 4 goes low. This applies a low to pin 2, and assures that pin 3 will stay high throughout the timing period no matter what happens to pin 1. All of this happens in nanoseconds (two gate propagation delays).
Now timing has started. Pin 3 is holding one end of the timing capacitor high, but the cap is charging through the timing resistor R5. When the voltage on pins 5 and 6 decrease below the gate's input transition level, pin 4 goes high, "unlocking" the trigger input. Timing has now ended.
At this point the C1 has 5 V (or whatever Vdd is) across it. If the trigger input pin 1 still is low, everything just sits unchanging. If pin 1 is high (ready to go low and trigger again), or whenever it does go high, pin 1 goes low. This drives the left side of C1 to GND and the right side below GND. If D1 were not in place, it would take another 3 minutes for C5 to discharge to 0 V across it through R5. But the diode shorts out R5 until the right side of C1 gets to within 0.6 V of GND. During this time, the capacitor discharges through the output impedance of U1A, a few hundred ohms. So while the capacitor doesn't reset "instantly", it is a very small fraction of the timing period.
The positive feedback from one of the outputs to one of the inputs is what makes a true monostable immune to trigger transitions during the timing period.
Just a moment ... just a moment ... While writing this I realize that moving the drive point for Q1 to the other end of the timing capacitor means that it will not turn off at the end of the timing period unless the headlights are off. If the headlights still are on, the relay will stay activated until the headlights go off. This needs a small fix, the addition of 1 resistor and 1 capacitor. I'll post the update tomorrow.
In either circuit, if the headlights remain on the light stays on-- is this a real problem ??
Both circuits will operate on 5 V. 555 ckt. operated on 5 V on breadboard with LED instead of relay.
Added C3 and R6. These form a differentiator, and assure that the trigger input at U1A pin 1 will be high when the monostable times out, even if the headlights still are on.
The classic two-gate monostable has complimentary outputs, but only most of the time. It can be made out of any of the four standard gate types as long as both gates are the same. There are some subtleties that allow other parts, but that's the short form. With NAND gates, a negative trigger edge produces a negative timed pulse at the main output after the second gate. The other output, used in post #27 and here, has a quirk that makes it more like a 555 than a true monostable. At the end of the timed period, its output is partly determined by the state of the trigger signal. Placing a differentiator, or "edge extractor", on the trigger source solved this problem if the differentiator R-C time constant is shorter than the monostable R-C time constant. In effect, it turns an input level into a pulse, that then triggers the monostable to make a longer pulse.
Ak thanks for explaining have better understanding of circuit now, look forward to update.
Bernard no probs with light staying on as long as headlights are still on.
I have your circuit breadboarded, just not sure of the need for ldr1. Could you explain?
I thought it was supposed to turn on ldr2 at night so that when headlights hit it then circuit would trigger.
The circuit I built following your diagram is triggered all the time, and only goes out when ldr2 is covered, plus time period.
I also tried changes suggested by dodgydave but no difference.
Can you measure LDR2's resistance under expected light conditions ? Were you using a pot. for R2 ?
To prevent false triggering, pin 2 should be above 1.7 V, @ Vcc 5 V. Is LDR shaded ?
Ok from what you said in last post Bernard I think I get how circuit works.
Ldr1 keeps pin 2 above 1.7v in daylight, then at night Pin 2 remains above 1.7v through r1 and r2.
Circuit is then triggered by headlights on ldr2 momentarily grounding pin 2, turning on relay for amount of time determined by c1 and r3.
To answer your question I did have pot in circuit, set at 5k.
Will check circuit again and measure voltage levels at pin 2.
I think its possible to use just one ldr If shaded enough inside door, what do you think?
To compare results, I remeasured LDR 2- in 2 in. X .5 in. black tube, facing bright N sky = 1.2k, headlight at 1 m =300 ohm. If R1 + R2 = 2329 ohms, then pin 2 in daylight = 1.7 V & with HL = .59 V. 1.7 V is a little close so lower R1 + R2 to 1812 ohm, then pin 2 = 2 V & .7 V. That is why we used a pot. for R2. Pot can be replaced with a fixed measured value. LDR1 is just insurance.
Hello, been busy lately not had time to post.
Just thought I'd finish up this thread.
For anyone interested I decided to go with 555 timer circuit using one ldr instead of two.
Will save running cable to back of house where second ldr would have to be.
Thanks again Bernard and ak for your help much appreciated.