# Conditional analog sample and hold (analog override?) - circuit suggestion request

Preamble: I have a LED driven by an opamp-based constant current source (CCS). It works fine, I can set up current required and it is reasonably stable. The problem is, that LED forward voltage drops over first 5-10 minutes due to internal heating, optical output power drops with it. To compensate for this, I would like to use a photodiode (PD) as an optical feedback, which adjusts current through the LED to keep optical output stable (increase drive current as Vfwd drops).

Request: A circuit idea, which would allow to set initial output level as a function of CCS setpoint, which is measured by PD and then used for driving the CCS (in theory setpoint input shouldn't matter after initial setup). The sequence I envision could be:

1. power up
2. set current limit (turn the LED on)
3. photodiode gets connected in feedback (perhaps with a small delay)
4. photodiode feedback controls output power, initial setpoint can be ignored, since no changes in levels are planned


EDIT: Per Andy's request CCS circuit, borrowed from another question:

EDIT2: Essentially I'm looking for a way to override one analog signal with another.

• Sounds like you are swallowing a spider to catch a fly. If the voltage drop is the reason for the initial loss in brightness then use that as an indication and do compensation based on that. – Andy aka Jul 17 '20 at 10:46
• Hmm, that's an actual idea worth trying out. But my main problem is I don't know how to go about overriding CCS setpoint input with whatever feedback source I use – stiebrs Jul 17 '20 at 12:09
• Well, I would help but I see no circuit. – Andy aka Jul 17 '20 at 12:18
• That's my problem. I have no idea how to implement external feedback for CCS in the form "use a if b is not present, otherwise use b". I could post generic opamp+transistor with feedback from low side sense resistor circuit, but I don't think that's necessary. Question is about how to plug that feedback into opamp based CCS in such a way, that it overrides the setpoint – stiebrs Jul 17 '20 at 12:27
• You're not helping yourself. – Andy aka Jul 17 '20 at 12:28