Backfeed diode and LM7805

Just a quick question really. I just want to make sure I have done this right. Here is a schematic of the lm7805 part of my circuit.

Uploaded with ImageShack.us

It gets fed 12V DC and the output goes to the 5V rail. My issue is that there is a supercap also connected to the 5V rail, so in the event of a power cut or something, the input will be a 0v and the output still at 5V (or there abouts). I have added a diode across the LM7805 to prevent backfeed, but Im not sure if it is the right way to do it. I think it is, but thought i should check before trying it.

Thanks

The idea of a backfeed diode like this is to discharge the output capacitor of the 7805 when the input is switched off. This prevents damage to the 7805 due to its output being at 5V when the input is at 0V. Now, if you have a supercap on the output, the diode may make it discharge when the power supply goes off. Is this what you want? Or do you want the supercap to keep the 5V power supply on for some length of time?

@paul23

Yes, it is correct.

Techone:
@paul23

Yes, it is correct.

I'm not sure it is correct. As shown, the diode may make the supercap on the output discharge when the input voltage goes to zero.

I don't think the 7805 cares if the output is high while the input is low. I have 15 Prominis that I power from an external 5V source, they get turned for 3 hours at a time 5-6 times during the week, does not seem to have bothered any of them.
The regulator is the 800mA regulator vs the 1.5A of a 7805, but they functionally pretty similar.

I don't think the 7805 cares if the output is high while the input is low.

Yes, actually it does, and the datsheet linked below talks of possible faiure mechanisms, and that the bypass diode can help prevent.

A short extract:

SHORTING THE REGULATOR INPUT
When using large capacitors at the output of these regulators,
a protection diode connected input to output (Figure 1)
may be required if the input is shorted to ground. Without the
protection diode, an input short will cause the input to rapidly
approach ground potential, while the output remains near
the initial VOUTbecause of the stored charge in the large
output capacitor. The capacitor will then discharge through a
large internal input to output diode and parasitic transistors.
If the energy released by the capacitor is large enough, this
diode, low current metal and the regulator will be destroyed.
The fast diode in Figure 1 will shunt most of the capacitors
discharge current around the regulator. Generally no protection
diode is required for values of output capacitance ? 10
?F.
RAISING THE OUTPUT VOLTAGE ABOVE THE INPUT
VOLTAGE
Since the output of the device does not sink current, forcing
the output high can cause damage to internal low current
paths in a manner similar to that just described in the “Shorting
the Regulator Input” section.

It's in the Appication Hints in this National datasheet: http://www.national.com/ds/LM/LM340.pdf

Lefty

Huh. Nice catch Lefty. Glad my prominis don't have large cap on them.

Thanks for the help. i had not actually thought about the supercap being discharged doing this. I guess the minimum I really need is for the arduino to remain powered long enough to save some values. It would be nice if it could stay on longer, but it is not essential.

Thanks again.

paul23:
Thanks for the help. i had not actually thought about the supercap being discharged doing this. I guess the minimum I really need is for the arduino to remain powered long enough to save some values. It would be nice if it could stay on longer, but it is not essential.

Thanks again.

The key is not necessarily that the chips Vcc 'stays on longer', but rather that ones has the means to tell that the source voltage is going bye bye to allow the program enough time to save variables to say the EEPROM. Using a battery low type detection circuit, using a external op-amp comparator and generating a interrupt is one method.

Can't think of a 'simple' or 'for free' method, either software or hardware, to accomplish the task, as one really has to have a handle on quite a few details, including how long the 'save' operations requires worst case, and what detection method one will be using, how long the main loop function cycle time is, etc.

I have a sketch around here somewhere where the Arduino can measure the actual specific Vcc voltage value at it's power input pin, but it would have to be called at a frequency often enough to be useful in the main loop, depending on the Vcc decay time for a specific project.

Lefty

Huh. Nice catch Lefty.

It's too bad the Arduino people didn't read that application note before they designed their auto switching power supply circuit. I brought this up in a previous thread a while ago (but of course I can't find it now!).

Don

retrolefty:
The key is not necessarily that the chips Vcc 'stays on longer', but rather that ones has the means to tell that the source voltage is going bye bye to allow the program enough time to save variables to say the EEPROM. Using a battery low type detection circuit, using a external op-amp comparator and generating a interrupt is one method.

Can't think of a 'simple' or 'for free' method, either software or hardware, to accomplish the task, as one really has to have a handle on quite a few details, including how long the 'save' operations requires worst case, and what detection method one will be using, how long the main loop function cycle time is, etc.

I have a sketch around here somewhere where the Arduino can measure the actual specific Vcc voltage value at it's power input pin, but it would have to be called at a frequency often enough to be useful in the main loop, depending on the Vcc decay time for a specific project.

Lefty

The way I am doing it (although untested so far) is to incorporate a voltage divider that I have before the voltage regulator. This is basically for measuring the mains voltage for something else unrelated (I am not putting mains straight through it, it is protected but that is irrelevant for this topic). So I have a way to detect that the mains voltage is present or not. In the event that mains is lost, the arduino saves the required values to the eeprom and then switches doff everything (the supercap runs through a transistor). I may ditch the transistor and just save the values and then stop everything until either the power is reinstated or there is not enough power for the chip.

After a quick test, the supercap kept a LED illumintated for just over 2 hours and watching the multimter, the drain is quite slow. I need to test it some more, but I am 90% confident that it will power an arduino (when fully charged) for at least 10 seconds, which should be more than enough time.

SHORTING THE REGULATOR INPUT …

The note is related to shorting input, not about leaving input floating. When Vin is shorted (or lower than Vout) there is an internal low current path from Vout to Vin, but not so when Vin is floating.

I would not worry too much about this. In fact I would be more cautious with adding the return diode, especially with a supercap.

I don't know about the 7805, but the 5v regulators I'm using specifically call for such a diode to be in place "in case of reverse current flow".
With the pin floating, it certainly isn't going to flow very long! It will flow long enough to fill the capacitor between VIN and GND though.

Can't think of a 'simple' or 'for free' method, either software or hardware,

What you could do is use the built in analog comparator of the Arduino. On one side of the comparator you select the internal bandgap voltage which should stay relatively stable as power starts to drop. On the other side of the comparator you can monitor the supply voltage through a resistor network. Then set the comparator to generate an interrupt if the voltage drops.

wayneft:

Can't think of a 'simple' or 'for free' method, either software or hardware,

What you could do is use the built in analog comparator of the Arduino. On one side of the comparator you select the internal bandgap voltage which should stay relatively stable as power starts to drop. On the other side of the comparator you can monitor the supply voltage through a resistor network. Then set the comparator to generate an interrupt if the voltage drops.

That does sound promising. Perhaps a simple example sketch would help people try out this method?

Lefty

retrolefty:

wayneft:

Can't think of a 'simple' or 'for free' method, either software or hardware,

What you could do is use the built in analog comparator of the Arduino. On one side of the comparator you select the internal bandgap voltage which should stay relatively stable as power starts to drop. On the other side of the comparator you can monitor the supply voltage through a resistor network. Then set the comparator to generate an interrupt if the voltage drops.

That does sound promising. Perhaps a simple example sketch would help people try out this method?

Lefty

It's slightly modified from another button press sketch I wrote but this should work. It uses A0 as the input from the resistor network.

#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

int powerDrop = 0;


void setup() 
{
  sbi(ADCSRB,ACME) ; //switch off ADC multiplexor to use ADC input
  cbi(ADCSRA,ADEN) ; //Turns off the ADC
  cbi(ADMUX,MUX2) ; //set address for A0 as input instead AIN1
  cbi(ADMUX,MUX1) ; //set address for A0 as input instead AIN1
  cbi(ADMUX,MUX0) ; //set address for A0 as input instead AIN1
  
  ACSR =
  (0<<ACD) |   // Analog Comparator: Enabled
  (1<<ACBG) |   // Analog Comparator Bandgap Selected: 
  (0<<ACO) |   // Analog Comparator Output: Off
  (1<<ACI) |   // Analog Comparator Interrupt Flag: Clear Pending Interrupt
  (1<<ACIE) |   // Analog Comparator Interrupt: Enabled
  (0<<ACIC) |   // Analog Comparator Input Capture: Disabled
  (1<<ACIS1) | (0<<ACIS0);   // Analog Comparator Interrupt Mode: Comparator Interrupt on Falling Output Edge
  
  Serial.begin(115200);
}

void loop() 
{
  if(powerDrop)
  {
    Serial.println("Save your data");
    powerDrop--;
  }
}

ISR(ANALOG_COMP_vect)
{
  powerDrop++; // Drop in power detected
}

Some of the more modern low-dropout regulators are tolerant of negative input voltages. This may make them tolerant of the output being driven above the input as well. I've just looked at the data sheet of the LM2397 (wich is an example of one of these regulators), but unfortuately it doesn't say whether a backfeed diode is needed or not.

Semi-related: I'd like to be able to provide already-regulated 5V into the power jack of a Duemilanove and take the board's regulator out of the picture. Seems like shorting Vin to Vout with a jumper would do so without problem, no? I didn't just want to backdrive the regulator, which has problems as discussed here, also, that would mess up the auto-switching logic when the USB is connected

Joe

Sounds like a reaonable plan.