I am experimenting with MCUs, specifically AVR.
I am programming them with USBASP v2.
When the circuit is small it can be powered by the programmer itself; one of the PINs from the programmer to the MCU is a VCC that can provide a (tiny) current, which is definitely enough to power the MCU and a few LEDs.
As soon as I attach a servo motor to the circuit, the VCC from the programmer is not sufficient anymore. The solution is of course to use a separate power supply (batteries or 9V DC input and regulators) for either the servo alone or for the entire circuit, including the MCU. If for the entire circuit, I don't need the VCC from the programmer anymore and I can (and should) disconnect it.
This is what I would like to do:
- When the power switch on the circuit is OFF, the circuit is, well, OFF, but if connected to the programmer I would like the MCU to still receive the VCC from the programmer so that it can be flashed.
- When the power switch on the circuit is ON, the separate power supply is used to power everything, and the VCC from the programmer, if connected, is "ignored".
This would allow me to program the circuit irrespective of whether it's on or off, and it would also enable the circuit to function on its own when not connected to the programmer.
Questions
- Is there something wrong with this idea?
- How do I implement this? Clearly I cannot connect different VCCs together.