2
\$\begingroup\$

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.
\$\endgroup\$
4
\$\begingroup\$

Is there something wrong with [ignoring the USBASP \$V_{CC}\$]?

Rohat's answer is a good one, but there may be more options.

How do I implement this? Clearly I cannot connect different VCCs together.

Correct, \$V_{CC}\$'s cannot be connected. But you can use diodes to isolate them. The MBR0520L for example is a low-loss 0.5A Schottky barrier diode, which is a fancy way of saying it lets power in one direction only with little loss. That loss is described in the datasheet and depends on temperature. Typical diode loss is 0.7v. If the circuit draws 0.2A at 25°C, a MBR0520L will drop about 0.3v. Many circuits will be fine with this.

schematic

simulate this circuit – Schematic created using CircuitLab

The two supplies can be active concurrently (will not conduct between each other directly due to diode isolation), and the higher supply voltage will always power the circuit.

Be aware though, that other pins connected to the USBASP are not protected this way. With the USBASP connected but powered off, applying the 9v battery could inject power into the USBASP through the other pins and either power it on (research "latch-up"), or damage it.

\$\endgroup\$
  • \$\begingroup\$ Thank you, seems simpler that I expected! Do you know if these diodes (or something comparable) are available as through-hole? \$\endgroup\$ – damix911 Sep 30 '20 at 15:51
  • \$\begingroup\$ > Be aware though, that other pins connected to the USBASP are not protected this way. Good to know, thanks, I'll keep it in mind. The MCU (it's going to be either an Attiny84 or 85) I/O ports are partially overlapped with the programmer's interface; if I dedicate those pins to the programmer I should be fine. And also if I only use the programmer's pin as outputs I think. I presume the problem that I could have comes from puhbuttons, that I intend to connect to the MCU via an RC network between VCC and GND and debounce in software; those are going to be high when not pushed. \$\endgroup\$ – damix911 Sep 30 '20 at 15:55
5
\$\begingroup\$

Of course, the idea can be implemented on the circuit to select the correct supply automatically. There's a manual (yet easier) way though.

There's a jumper (JP1) on the programmer:

enter image description here

This jumper basically selects the VCC (5V or 3V3) of the target. If you remove it then there'll be no VCC at the ISP connector.

\$\endgroup\$
  • \$\begingroup\$ thank you! This is a very good suggestion. I thought of having a switch on the circuit itself, but it's great that there is already a way to do this on the programmer. \$\endgroup\$ – damix911 Sep 30 '20 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.