Go Down

Topic: External power to circuit while programming (Read 4808 times) previous topic - next topic


While I'm designing my next project, I came across a scenario for which I am not sure what would happen, or what I should do to avoid whatever problems I might come across.  Basically it's a custom circuit with an Atmel with Arduino bootloader, running LED strings.  I will have an external power supply providing 5V to the whole circuit.  The question is, what happens when I want to reprogram it (as in, download a new sketch) via FTDI.  Because that sketch will be coming from a computer connected via USB to the circuit, I would essentially be providing power both from the USB cable, as well as the external PSU, yes?

My question is, is it safe to do that, is it safe to keep the external supply on, feeding 5V to the circuit, while at the same time also having an FTDI cable connected to download a new sketch?  Ideally, I don't want to have to shut off the external circuit each time, just plug, download, and go.  So I'm thinking I need to add something to the circuit that prevents feedback somewhere.

I just don't know where, how, or what.  Do I add a diode to the FTDI VCC line?  Does it also need a fuse as well?


Using a FTDI with your circuit and re-program the chip is Yes and NO. Yes if the whoe circuit did not use more than the PC - USB voltage rail can provide ( they are protected by a fuse ) I talking about the current for the whole circuit. No if the whole circuit is more.

So my idea is :

1. Remove the chip ( ATMega ) from your board , place into an UNO board. Reprogram. Remove and place into your circuit.

2. Built you owm chip programer using a ZIF. See my tread --> http://arduino.cc/forum/index.php/topic,87747.0.html Same idea 1 but it simply include a USB-TTL adapter, reset circuit, crystal and a zif socket. Power came from the USB computer.

3. Use a RS232 board. Like : http://www.schmartboard.com/index.asp?page=products_populated&id=84 It use the 5 V from your circuit. Connect GND, RX to pin 3 , TX to pin 2, CTS with a 0.1 uF cap in serie with the reset pin 1 of the ATMega328P chip.


That's not going to work.  It's a custom design, in a enclosure with only wires for external power and an FTDI header sticking out.  The thing will be running at all times.  Incoming VIN (5V) is split internally, one leg going to drive the LED strips (which together will be pulling upwards of 10A), and the other leg going to the Atmel.  When it needs to be reprogrammed, I would connect my FTDI cable to the header sticking out of the enclosure.  The external supply is *not* being switched off for this.

So what happens when I connect the FTDI cable?  5V (or close to that) will be fed into the circuit from the FTDI cable.  Will it matter?  Essentially it's a second supply in the circuit, and the grounds will be common anyway.  But, I need a way to protect it from the LED strips pulling current from it.

In my mind, I need to somehow isolate things.  I just don't know how, nor where.


The other option I'm considering is putting an FTDI chip in the circuit, and a USB header so all I'd have to do is plug a USB cable in, and not an actual FTDI cable.  Still, I need to figure out how to safely do this.


Yes, look at (track down) the schematic for the Nano or Duem., there's a schottky diode.  It's only forward-biased if the Nano/Duem is off.
So, you'll want your device powered before connecting the USB to re-programme.  I guess you have to assume the responsibility for getting it right so that some new lines of code don't result a catastrophe.  Depending, you might have a test-bed where you could ascertain whether you got it right basically before committing to re-programming in place.

"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!


Well yeah, that makes me wonder about any of the Arduino boards.  I've never tried it, but what happens if someone has both a wallwart connected to the board providing power, as well as a USB cable programming the thing at the same time.  That's the same thing I'm trying to do.  So what happens in that scenario?  Things go up in smoke?  The computer's USB port goes poof?  Why?  Or why not?


Feb 01, 2012, 03:32 am Last Edit: Feb 01, 2012, 03:35 am by Chris Magagna Reason: 1
The other option I'm considering is putting an FTDI chip in the circuit, and a USB header so all I'd have to do is plug a USB cable in, and not an actual FTDI cable.  Still, I need to figure out how to safely do this.

It's really easy. In the FT232RL info sheet there's a sample circuit that describes how to do this, but basically you connect USB ground to common ground and a 10K resistor to the reset pin, and USB +5V to a 4.7K resistor to the reset pin.

I've built a couple of circuits now with this configuration and have had no problems. I've attached a piece of a schematic showing the layout.

[edit -- the section in the data sheet you want is "Self Powered Configuration" ]

Good luck!


I know how to do that Chris, that's not what my question is.  Assume it's already in the circuit (or not, doesn't matter), the question is whether it's safe to have the circuit powered with a 5V power supply, driving everything, including the controller, while also having a USB cable plugged in to the controller to reprogram it.  What safeguards should I be taking to do that, to avoid the USB getting blown, or anything else for that matter.


Nothing else needed. If you wire the USB connection like this then the Ft232rl chip takes care of the rest.



What about my Option 3. ( RS232 ) It need the 5 V from your circuit, and choose the RS232 port of you computer to send the new program. I did that experiment, and work just fine.  Might work in your case.


Chris Magagna idea, except the 5 V line going to the computer ( USB ) is being disconnected, and connect the 5 V to your circuit.

:~  Crazy Idea...but it just might work...


Oh first, Techone, I didn't mean to completely discount your suggestions.  They are all viable solutions, just not for this particular setup.  And while the RS232 is possible, not in this particular setup.  There's no room.  There's barely 7mm of height clearance, and 1.2mm of that will be taken up by the board itself.  And almost no computer comes with an RS232 port anymore. :)  Sure, I can buy a USB to RS232 cable ... but why, when I can design a complete USB solution ...

As for Chris' idea, the FTDI chip doesn't need to be constantly powered, only when the USB cable is connected to program the controller.  So I don't think connecting it to the circuit's 5V is necessary.


Here's another question: with an FTDI chip in the circuit, is there a way to tell the micro controller when a USB cable has been plugged in?  Before anything is even transmitted through.  Plug the cable in, and the controller knows it's there ... is that possible?


Hey Chris, looking at your circuit, I noticed you left CTS unconnected.  Shouldn't that be connected to ground?  I only ask because I have an actual FTDI board from SparkFun and they have the CTS signal grounded.  Datasheet simply says clear to send control input / handshake signal.  So I'm not sure if it really matters.  Thought I'd ask anyway.


To tell you the truth I'm not sure. I copied that side of the circuit from the Duemilanove, which has CTS going to a header block but isn't otherwise connected.



Just don't connect the USB 5v to the system, only use it to power the FTDI chip.

The only other thing to do is to stop the processor from powering up the FTDI through the TX pin, you could  do that with a diode and a pullup resistor.

Rob Gray aka the GRAYnomad www.robgray.com

Go Up