brownout on MCU's - Page 1
Forum section: electronics / projects

author: Simon
author_rank: Unknown
timestamp: July 23, 2010, 06:17:15 pm
content: can someone just explain what brownout is on an MCU (PIC) does it mean that the MCU will not operate if the voltage is too low as oposed to working in a random manner ?

author: RayJones
author_rank: Frequent Contributor
timestamp: July 23, 2010, 10:21:15 pm
content: Brownout refers to a supply that dips well below the proper value such that a device stops operating correctly and shortly returns back to normal.Coined from when you see a dip in mains supplies, and the lights go "brown" for second or so.With the mains situation, refrigerator motors may stall and burn out.With micros, they may just latch up and refuse to run until given a proper reset.You can get power watchdog chips that force and hold a reset for a period after such power drops, and many micros these days build this function in.

author: tecman
author_rank: Frequent Contributor
timestamp: July 23, 2010, 10:50:44 pm
content: Most microcontrollers today have a voltage monitoring circuit that will reset the MCU if the voltage reaches an internal threshold. Some will sleep rather than reset if selected.paul

author: desolatordan
author_rank: Regular Contributor
timestamp: July 24, 2010, 01:03:45 am
content: Quote from: RayJones on July 23, 2010, 10:21:15 pmIt's important to note that during a brownout, digital circuits will often corrupt ram or eeprom. Brownout protection for microcontrollers will turn the MCU completely off during brownouts to ensure this doesn't happen.

author: Simon
author_rank: Unknown
timestamp: July 24, 2010, 06:15:00 am
content: ao basically the brown out function will allow the MCU to work only with correct voltages ?

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 24, 2010, 06:53:13 am
content: Quote from: Simon on July 24, 2010, 06:15:00 amnot at the correct voltage, but at higher than safety voltage level. it will not detect for too much voltage though. if higher than safe voltage is applied, it will be called... burned out! or buy out! another one.if brown out is detected, the mcu will "cold" reset and re-start the program flow from the very beginning. transient/voltage spike will be enuf to make the mcu browned out. i debugged a peculiar mcu behaviour last time where my relay keep on-off very fast. i thought it was my programming, but later found out my mcu keep restarting the program due to brownout, quite nasty last time, i was almost browned out!

author: Simon
author_rank: Unknown
timestamp: July 24, 2010, 02:35:10 pm
content: so will it refuse to work on a lower than safe voltage ?

author: Zero999
author_rank: Super Contributor
timestamp: July 24, 2010, 07:47:46 pm
content: Quote from: desolatordan on July 24, 2010, 01:03:45 amMaybe the RAM but I'm cynical about it corrupting the EERPOM.Don't you need a higher voltage to corrupt the EEPROM?There again, I'm no PIC expert so I could be wrong.

author: Simon
author_rank: Unknown
timestamp: July 24, 2010, 07:55:43 pm
content: my problem is that I will be using a mosfet sensing another voltage to turn the 78L05 on so initially when the voltage is low it could mean that the supply to the 78L05 will be "strangled" as it is not a clear cut comparator type detection

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 24, 2010, 07:57:47 pm
content: @simon, if brownout feature is disabled (thru fuse), mcu will continue to work below the safe voltage, but stability is not guaranteed.@hero, it is documented IIRC in PIC that at certain low voltage, write to EEPROM will cause corruption.

author: Simon
author_rank: Unknown
timestamp: July 24, 2010, 08:03:25 pm
content: so will brownout enabled protect from corruption of the chip ?, if it misbehaves at low voltage it should not be a huge issue but obviously the program must stay intact

author: Pyr0Beast
author_rank: Contributor
timestamp: July 24, 2010, 08:31:36 pm
content: Brownouts can also cause a chip to skip an instruction or freeze LCD's

author: jahonen
author_rank: Super Contributor
timestamp: July 24, 2010, 08:50:40 pm
content: Why not use regulator with "power good" signal output, such as LP2951? It even has enable/disable input. Or, separate reset/voltage supervisor chip, like MAX1232? MAX1232 might however complicate things, such as make debugging more difficult due to WDT action. Those essentially prevent brownout situation, even more if you also enable brownout reset on the PIC.Erratic behavior of a MCU can be a bitch to debug, I have seen cases where for most of the time the system runs just fine, but now and then, flash is mysteriously corrupted. It is better to mitigate it beforehand than try to hunt it afterwards.Regards,Janne

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 24, 2010, 08:54:45 pm
content: Quote from: Simon on July 24, 2010, 08:03:25 pmif you dont implement write to EEPROM/flash, then i think you can disable brownout detection without corrupting anything, its just at some point during brownout, your program will just simply restarted. if pyro statement is true, then it will not do any good if the program is critical to the circuit performance. so maybe the bottom line is... if you want to operate at brownout voltage, dont use mcu in the design.johanen reminds me of the brownout flag in register, if i'm not mistaken it is, but i wonder what its for? i will not allow my mcu to go brownout even for a single picosecond!

author: Simon
author_rank: Unknown
timestamp: July 24, 2010, 09:14:15 pm
content: well as i said my supply voltage will be unstable to start with so I just want it to work fine when the correct voltage arrives. the other option is to keep the chip constantly powered and to control the MCLR pin with the voltage sensing circuit, how much power does a pic held on on reset use ?

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 24, 2010, 09:15:23 pm
content: i think this question is analogous to... what if i want to use less than 0.3V for a diode/LED?.... its just simply doesnt work. for me, i will just simply stick to the normal operating voltage range. if you want to run really low, do it somewhere else, not in the mcu.

author: Simon
author_rank: Unknown
timestamp: July 24, 2010, 09:27:58 pm
content: I don't want to run on low voltage, but as the circuit is dependant on another voltage that will slowly rise the pic may get a low voltage supply until the voltage is high enough, I'm just trying to figure out what will happen in the first 10ish second when power supply could be unstable. I've done it similar before where i fed the voltage straight to the pic and it still worked fine but that could have been a one off, once this all kicks in the voltage will be 14 V and the mosfet inly needs 1 V to activate the circuit

author: jahonen
author_rank: Super Contributor
timestamp: July 24, 2010, 09:31:24 pm
content: Quote from: shafri on July 24, 2010, 08:54:45 pmThe brownout flag is for the MCU to check after reset if the reset reason was brownout (and possibly do some housekeeping), if that is not necessary to know, just ignore it.Regards,Janne

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 24, 2010, 09:33:28 pm
content: Quote from: Simon on July 24, 2010, 09:14:15 pmwell, you didnt say it earlier... just enable the brownout, your mcu will just simply sleep (reset) during the brownout period to ensure the integrity of your running program and to avoid misbehaviour... no harm will occur. the mcu will start when the V is stable above Vbor. you can add certain delaying loop in your code for more bulletproof to ensure V stable... no need MCLR control. MCLR will be more usefull if you want purposely shutdown the mcu, regardless of brownout condition.well, according to pic16f631 database, Vdd = 2V-5.5V (for Fosc<=4MHz), Vbor <= 2V, not sure about power during BOR reset, but BOR detector will consume 42uA@3V during active period, if i'm not mistaken. better disable it if you are sure your V is already stable.

author: Simon
author_rank: Unknown
timestamp: July 24, 2010, 09:38:15 pm
content: This is my setup, the circuit should activate when the dynamo is outputting more than 1 V this way when the engine stops the circuit is turned off. I expect using the watchdog timer is a good idea too.

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 24, 2010, 09:53:02 pm
content: and where is your mcu? in the dynamo side? or the Vcc side? i suspect, it should be on the Vcc side, i dont see any problem there, either BOR_OFF or BOR_ON, you already got the C1&C2.that whole thing is already looks like a brownout detector circuit to me, i think...now my turn to ask. specifically... whats the Q5 and Q6? saw that many times, cant we just use a single normal transistor and put the dynamo on the base? you are the master there.

author: Zero999
author_rank: Super Contributor
timestamp: July 24, 2010, 10:20:15 pm
content: Quote from: Simon on July 24, 2010, 09:38:15 pmWhat's the value of R8?You do know that Q5 won't turn on until the gate voltage is typically 2.1V, see the datasheet.http://www.fairchildsemi.com/ds/2N/2N7000.pdfWhat's the purpose of R1?It seems a bit pointless to have two series resistors.

author: RayJones
author_rank: Frequent Contributor
timestamp: July 24, 2010, 10:26:55 pm
content: Quote from: desolatordan on July 24, 2010, 01:03:45 amYes indeed.We had a system at work that used an external parallel EEPROM that would suffer random corruption of it's data, but this was with normal power downs, not necessarily brownouts as such.It turned out the write signal would drop to a active low level at a voltage that the EEPROM was still OK with - BAM - instant random junk in random locations.The solution was to gate the write signal through logic that operated correctly at very low voltages.Bit of a nasty combination - active low signals and failing power supplies, and something to always keep in mind with "non volatile" storage.

author: Zero999
author_rank: Super Contributor
timestamp: July 24, 2010, 10:59:21 pm
content: All right, that makes sense but having an active low on an EEPROM write enable input is bad design.

author: RayJones
author_rank: Frequent Contributor
timestamp: July 24, 2010, 11:08:06 pm
content: Quote from: Hero999 on July 24, 2010, 10:59:21 pmWell don't tell me that, tell the multitude of chip designers out there...

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 07:16:41 am
content: Quote from: shafri on July 24, 2010, 09:53:02 pmQ5 and Q6 are an N and P channel mosfet that turn the battery power on and off to the 78L05 that will power the MCU (VCC) as there is a small voltage from the dynamo. And yes I am master in this project ! but that does not mean I don't have questions. The diagram shown is just the power supply circuit section

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 07:19:00 am
content: Quote from: Hero999 on July 24, 2010, 10:20:15 pmR8 is yet to be determined, it is just to discharge the gate of Q6 when Q5 goes offswitch on at 2.1 V is also fineR1 is part of a low pass filter, the reason for two resistors if you look and ignore the mosfet is that I have two low pass filter stages to help keep out spikes

author: Zero999
author_rank: Super Contributor
timestamp: July 25, 2010, 09:07:18 am
content: I've just noticed one more little thing: you've omitted units from the capacitor values, I know it;s obvious to a fool they're in µF and that I'm being picky, but it's not a good habit to get into, as some simulation programs will think you've specified 10F and 100F capacitors; LTSpice will do this by design.

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 10:41:56 am
content: well owing to space constraints on the page and the fact that this is just the circuit drawing part of expresspcb and nothing to do with simulation and that I'd assume them to be uF I omited them. Obviously if i was supplying this diagram to someone to build it from I'd add all the details.

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 25, 2010, 12:50:22 pm
content: now the analog part is yours, but on the digital side, as i mentioned, u ar good to go. just watch out for the spike in your analog part, they might be slipped in, thats all u should really care most about.and then again... my question has not been fully answered, cant we replace the N and P mosfet channel with normal NPN or PNP transistor? or even just a single transistor? to replace both mosfet?

author: Zero999
author_rank: Super Contributor
timestamp: July 25, 2010, 01:02:33 pm
content: I don't see the point in replacing the MOSFETs with BJTs.The only advantage I can see is that BJTs are more resistance to voltage spikes as the Vbe junction is just a diode which won't be destroyed by positive spikes and should be able to recover from low energy negative spikes without being damaged.

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 01:03:01 pm
content: it can be done with BJT's or mosfets, I was actually considering a N mosfet and PNP BJT as that it what I have to hand, mosfets use no power, it cannot be done with only one device, if you find a way of doing it let me know ! less parts are better

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 01:06:26 pm
content: Quote from: Hero999 on July 25, 2010, 01:02:33 pmwell hopefully I've taken care of all the spikes. I am controlling the dynamo and frankly I trust the dynamo more than the crap i'll get back from the engine ignition through the battery (hence heavy filtering on the input to the 78L05), I'll be putting a TVS on the dynamo output and the dynamo exitation drive is back EMF neutralized.

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 25, 2010, 01:26:51 pm
content: this is what i have i mine, but not sure, never tried though. dont laugh ok? just..... explain.

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 01:41:36 pm
content: it might work, again it would guarantee that the initial start up voltage would slowly climb and for a good bit of time the voltage could be unstable, full stable voltage would only be guaranteed with over 8 volts as 7 volts are necessary to run the 78L05 and another volt for the base/emitter junction + a base resistor you have omitted.The idea is that I start the MCU when the circuit detects that the engine is running because a small voltage due to the residual magnetism in the dynamo is being generated, until the circuit starts the dynamo will have no drive (because the project is the dynamo controller).It would all be simpler if the car was + earth or we did not get - and + mixed up when electricity was discoveredQuestions ?

author: jahonen
author_rank: Super Contributor
timestamp: July 25, 2010, 02:05:41 pm
content: Quote from: jahonen on July 24, 2010, 08:50:40 pmSo, like this (two options if LP2951 shutdown current, typ. 3 µA, seems too high).Regards,Janne

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 02:52:53 pm
content: if I were to use that approace I might as well use a comparator and be done with it

author: Zero999
author_rank: Super Contributor
timestamp: July 25, 2010, 03:49:25 pm
content: The common emitter design is also risky if the input voltage suddenly drops to zero because the capacitors can hold charge which will zap the Vbe junctions which is typically only rated for 5V.

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 03:58:07 pm
content: yea the voltage will drop suddenly when the engine is turned off, the cap will hold a charge while the base goes down to "0" quite quikly

author: jahonen
author_rank: Super Contributor
timestamp: July 25, 2010, 03:59:04 pm
content: Quote from: Simon on July 25, 2010, 02:52:53 pmExcept that you get that "out of regulation"-detection almost for free when using LP2951 (or similar), but using a comparator would require a separate voltage reference (if not available otherwise), bunch of resistors and possibly some caps.Regards,Janne

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 04:01:37 pm
content: well this is only to ensure the MCU starts up properly, it won't be an ongoing unstable power supply, if brown out will protect from errors and i have a fairly robust sensing circuit it will be ok, I think the two transistors combined should give a fair amount of gain so there should be a fairly neat on/off point

author: Zero999
author_rank: Super Contributor
timestamp: July 25, 2010, 06:02:45 pm
content: Quote from: jahonen on July 25, 2010, 03:59:04 pmThe shut down pin is active high which isn't good, what happens if you've told the regulator to shut down but the power supply voltage is just under 2V (the maximum value specified on the datasheet)? Will it try to turn on causing your PIC to behave erratically?The error pin is also active high which might result in a similar logic error during a brownout situation.

author: jahonen
author_rank: Super Contributor
timestamp: July 25, 2010, 06:47:20 pm
content: Quote from: Hero999 on July 25, 2010, 06:02:45 pmShutdown is active high, thus it is connected via resistor to the input voltage, works fine. Of course, it doesn't work great if you have less than 2.0 volts to start regulating. Of course, the output voltage would then be less than 2 volts, however much less is not possible, since internal reference is 1.25 volts.For normal operation, shutdown pin is pulled low via external transistor. There is a curve on the datasheet how the error pin behaves. It becomes erratic at something below 1.5 volts, which I suppose is too low for the MCU to work anyway. Proper reset circuit, like MAX809 is somewhat better (but not dramatically), it works properly downto 1 volt VCC. Regulator supervisor output is just for preventing possible brownouts (it indicates when VCC is about to fall out of regulation). MCU internal voltage supervision should handle rest of the input voltages.Error input is actually open drain active low (otherwise it wouldn't be very good) one if you check the datasheet.Regards,Janne

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 06:53:45 pm
content: the supply will start from 0 and climb up to 12

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 25, 2010, 07:01:58 pm
content: @johanen, your circuit up there that is using LP2951 is relying on VDD_5P0. simon indicates that the main supply is unstable, so does the VDD_5P0 i think. wouldnt it create any instability in the LP2951?

author: jahonen
author_rank: Super Contributor
timestamp: July 25, 2010, 07:13:04 pm
content: Quote from: shafri on July 25, 2010, 07:01:58 pmLP2951 is a (LDO) regulator, which creates a stable voltage (VDD_5P0) from unstable voltage, I see no problem there, as long as input voltage stays above dropout (max. 600 mV @ 100 mA).Regards,Janne

author: Zero999
author_rank: Super Contributor
timestamp: July 25, 2010, 07:19:50 pm
content: Quote from: shafri on July 25, 2010, 07:01:58 pmI agree, it could become unstable.This isn't because of it going into drop out but because the disable and error flags are active high.If you can get hold of a device which is the other way round, i.e. it has a disable input and a supply OK output, it would be less prone to instability.

author: jahonen
author_rank: Super Contributor
timestamp: July 25, 2010, 07:22:53 pm
content: Quote from: Hero999 on July 25, 2010, 07:19:50 pmError flag is still active low, if you bother to check the datasheet.Regards,Janne

author: Simon
author_rank: Unknown
timestamp: July 25, 2010, 07:47:35 pm
content: the reg is fed from a battery but it's supply is "gated" by the mosfet circuitry that senses another voltage to tell it the engine is turning, the voltage will be at 12+ volts normally so only issue is the instant the engine is first turned over

author: Zero999
author_rank: Super Contributor
timestamp: July 25, 2010, 08:30:17 pm
content: It's still no good because the disable input is active high.What about using a TL431 with a PNP transistor to make a low voltage protection circuit?The values of R1 and R2 can be calculated using the formula found on the datasheet. R3 some positive feedback so there's some hysteresis to prevent oscillation. R4 just limits the base current, choose a value which will allow the transistor to saturate whilst the maximum load current is flowing.

author: jahonen
author_rank: Super Contributor
timestamp: July 26, 2010, 05:28:41 am
content: Well, the simulation does not look very promising, "check"-circuit works just fine (just to show that TL431 SPICE macromodel works).Regards,Janne

author: Zero999
author_rank: Super Contributor
timestamp: July 26, 2010, 08:06:21 am
content: Why is it not working?It will work, it's not working because I made a mistake on my schematic, can you guess what it is?Hint: I missed out a component.Look at the datasheet for the TL431 and the LM431 for more information.I'll tell you in a day or so, if no one can figure it out.

author: jahonen
author_rank: Super Contributor
timestamp: July 26, 2010, 08:40:36 am
content: It misses the usual B-E-resistor which is needed to bias the TL431 correctly.Regards,Janne

author: Zero999
author_rank: Super Contributor
timestamp: July 26, 2010, 09:33:07 am
content: Yes that's it. The TL431 will pass a small current when the voltage is below 2.495V so without a pull up the transistor will turn on before it should.