other automatic night light circuits for the explanation.
A 3-wire cable connects the sensor circuit to the main control circuit. According to the MCP627x op amp datasheet:
Driving large capacitive loads can cause stability problems for voltage feedback op amps. As the load capacitance increases, the feedback loop’s phase margin decreases and the closed-loop bandwidth is reduced. This produces gain peaking in the frequency response, with overshoot and ringing in the step response. A unity-gain buffer (G = +1) is the most sensitive to capacitive loads, though all gains show the same general behavior. When driving large capacitive loads with these op amps (e.g., > 100 pF when G = +1), a small series resistor at the output improves the feedback loop’s phase margin (stability) by making the output load resistive at higher frequencies. (DS21810F, 2008, p.14)
Well, we're working with essentially a DC signal and I have no idea of how much capacitance there is in the cable, but I just added R3 to be sure. The hysteresis circuit (R5, R6, R7) needs a low impedance source, thus A2 is used as a voltage follower--else R3 will foul up the resistor values for the hysteresis. For a discussion of hysteresis in single-supply op amps read this. Equations are provided.
A push-pull configuration using complementary transistors drives the relay and LEDs. A 12-volt relay is the output amplifier (and high-voltage isolator) which switches the 220VAC load. The relay is some 10 ten meters from the control circuit. Its normally open contacts are connected in parallel with the light's wall switch--so this switch has to be off for the circuit to turn the load on/off automatically. Green and red indicator LEDs provide feedback when adjusting the pots.
The shortcoming of this circuit--and for that matter all ANL circuits--is that the ambient light level at which the load is turned off must be higher than the light level at which it's switched on. In other words, incorporating a hysteresis--however small--forces the circuit to turn the load off at a brighter condition than for load switch-on.
But in some cases (probably a majority) we want the lights off at the crack of dawn--i.e., at a darker condition than when it was turned on. Someone may have already done so, but I haven't yet come up with a way of doing this using linear components/ICs. I don't even know where to begin! Using a microcontroller on the other hand seems obvious and the simplest way to implement it.
And that's what I've been doing these past two days. Because it's MCU-based the circuit itself is a no-brainer. The firmware's where the brain-racking is. I've already installed a temporary circuit in place of the above all-analog one and will be checking its performance till week's end.
Given that I'm using an MCU--and all the computing power it's got--I pared down the sensor subcircuit and eliminated the low pass filter. Filtering is now performed digitally using algorithms. Pots are gone as well. Trip point is set using a momentary contact push button. "Negative" hysteresis (as I'm calling it, at least for now) is relatively simple to implement in firmware. Testing over the next few days will actually be assessment of the robustness of the algorithms I'm using, tweaking the values used in the equations, and ferreting out bugs.