Okay, now that the sound detector is clear, I thought I'd move on to my next project. This is the very first one I built, and I chose it because it seemed to be quite simple, though I quickly discovered that it was anything but.
It's an LED heart that pulsates:
The problem is, it uses an LM358P chip, which Google tells me is a pair of op-amps. I had heard of op-amps, as they're so frequently discussed on these forums, but I had no idea what they were supposed to do and how. So I read a bit about them and understood their basic working principle, and I have also built a small non-inverting amplifier circuit on the breadboard, using the very chip from this heart, to check the voltages and see how the amplification works.
But this particular case seems to be a bit more complicated, so again I need to appeal to you for help.
This is the schematic, as figured out by myself based on the tracks on the PCB.
The LED part is simple enough. They're powered through a 22Ω resistor, which for 22 LEDs in parallel means just slightly over 10mA for each one. That's perfect. And this is just the maximum current; they won't always receive this much.
But I can't figure out exactly how the pulsating part works.
At first I thought that perhaps the op-amps modulate the current through the base of Q1 somehow. But now I think this is unlikely. I think what causes the base current to fluctuate is actually the C1 capacitor charging and discharging.
I suspect that the first op-amp, labelled U1A, alternately delivers either full voltage (in which case the base current of Q1 slowly increases while the capacitor is charging), or no voltage at all (in which case the base of Q1 continues to be powered by the slowly discharging capacitor).
U1A seems to be set up not as an op-amp per se, but as a simple comparator. A fixed 2.5V reference (because R1 and R2 form a voltage divider and have equal resistance values) on the non-inverting input is compared with whatever voltage is received at the inverting input. If the latter is lower than 2.5V, then U1A delivers 5V to the transistor, and the capacitor starts charging. If it's higher than 2.5V, then it delivers 0V to the transistor, and the capacitor starts discharging.
Am I right so far?
But now I'm blocked. I can't figure out how the voltage at the inverting input of U1A is regulated. Obviously, it's the second op-amp, U1B, that's responsible for this. But I'm not sure I understand how it does it.
U1B doesn't look like a simple comparator, because it uses feedback. So at first glance it doesn't look like it outputs all or nothing, like U1A does, but rather a varying voltage. But it's strange that it receives feedback at its non-inverting input. All the examples that I've seen of op-amps used as amplifiers, be they inverting or non-inverting, were receiving feedback on the inverting input. So maybe U1B, despite using feedback, isn't actually set up as an amplifier, but still as a comparator?
I'm imagining it works somewhat like this:
- With no power, everything is off (obviously).
- When you turn on the power, U1B has 2.5V at the inverting input and 0V at the non-inverting one. Consequently, its output is 0V, which means U1A has 0V at the inverting input. But U1A has 2.5V at the non-inverting input, which is higher than 0V, so it will output 5V.
- While U1A outputs 5V, the capacitor starts charging and the LEDs turn slowly on, reaching full output when the capacitor is fully charged.
- While the capacitor is charging, the voltage through RV1 and R6 slowly increases, until it gets to 5V.
- Now U1B receives 5V at its non-inverting input, which is higher than the 2.5V that it has at the inverting one, so now U1B outputs 5V.
- This causes U1A to receive 5V on the inverting input, which is higher than the 2.5V that it has at the non-inverting one, so now U1A will output 0V. Now the capacitor starts discharging into the circuit and the LEDs slowly fade.
- While the capacitor discharges, the voltage through RV1 and R6 slowly drops down to 0V. Now the non-inverting input of U1B is again lower than its inverting one, so its output becomes 0V again. And the cycle repeats.
Am I close?