Is this going to work?

Thread Starter

PickyBiker

Joined Aug 18, 2015
101
I have a microprocessor controlled radio project that needs a brownout detector so I can save the Band and Frequency information into EEPROM when the power is turned off or fails. The power supply is 18VDC and the microprocessor runs on 5V with 3.3V I/O levels. What I need is a detector that will send a high (+3.3) signal to the microprocessor when the 18V supply falls below about 13V-14V so it will have enough time to save the information.

The attached schematic is my attempt to make that detector. Will this work as described?
 

Attachments

SLK001

Joined Nov 29, 2011
1,549
It looks to me that the output will always be on. I would change the XSTR to an NPN and tie R3 to ground. With this configuration, when your voltage is more than ZD1 breakover, the base will be high enough to turn on the XSTR, thus giving a high output. When the voltage is less than breakover, then the base is pulled to ground, thus giving a low output.
 

InspectorGadget

Joined Nov 5, 2010
215
By the time you sense power failing, you will probably not have enough power to write to the Flash reliably. If voltages are falling when you try to write to the Flash, results will be unpredictable and could scramble your Flash. Plus have you looked at current requirements during Flash write? How are you going to supply this current?

The technique I always use is to start a virtual "background" timer in my program whenever a change is made to the variables you want to keep persistant from one power-on to the next. If they're changed further, the timer resets to the beginning. When 15 or 30 seconds elapse from the last time one of these parameters is changed, I then write the current values to the Flash, so they're already saved at the point you would power off.

And I try not to power off right after changing parameters, so I don't accidentally power off during a Flash write. Very bad.

I guess the other thing you could do is have your power switch be controlled by the MCU so that it would turn itself off only after writing the saved values to Flash. Then all you have to worry about is someone disconnecting the power, "pulling the plug," without turning it off first.

But my 15/30-second parameter-change-Flash-write holdoff technique described above works even when the power cord is pulled out of the socket.
 

Thread Starter

PickyBiker

Joined Aug 18, 2015
101
I accidentally had the PNP upside-down. This is the circuit I intended.
The microprocessor will have plenty of power for the two EEPROM writes when the supply voltage reaches about 13 volts because of the large supply capacitance (not shown). An EEPROM write takes 3.3 ms to complete so in total, I need less that 10MS to save the 2 values. I am fully confident there will be enough power for that duration. Brownout Detector.jpg Brownout Detector.jpg
 

AnalogKid

Joined Aug 1, 2013
10,986
Actually, the first schematic will work better than the 2nd if it is corrected. Change the transistor to an NPN type like 2N4401, 3904, or 2222. Leave it as an emitter follower, and reconnect R3 from the ZD1 cathode to GND.

Note that the output will not transition quickly. If the 18 V source wanders down slowly between 13 V and 12 V, the input to the uC also will move slowly. And the input to the uC will go low on error. Not huge problems, but some things to be aware of.

ak
 

dannyf

Joined Sep 13, 2015
2,197
Unless you have tons of data to write, it is sufficient to use the built in brownout.

If you have to prolong the lower off time, consider a diode Intl the cap from the 18v line. It prevents the cap from being bleed off.
 

Tonyr1084

Joined Sep 24, 2015
7,852
So you want 3.3 volts positive to go to the Micro Controller when power is dropping below a set threshold; right? If so the second diagram may do. As long as you move R3 from power to ground. With R3 configured the way you have it now it will never turn on. The 2904 needs to pull to ground in order to turn the transistor on. Holding it high between two different voltages will never let it turn on - AND you can send a high voltage through R1 & R3.

I'm not the expert on this stuff, but I think I'd use a comparator with a preset reference voltage. When the supplied power drops below that threshold the comparator can switch from low to high. You'd also want to use divider networks to keep the voltages on the comparator low. You said you wanted 3.3 V signal to trigger a flash memory dump. Not sure if it needs to be 3.3 volts or if that's a minimum requirement. Since you have a five volt regulator operating why not power the comparator with the 5 v. When you trigger the memory dump you'll be sending 5 volts to whatever pin it is you're wanting to.

OK, here's a comparator circuit. Using the 5V source and divider network I've divided a reference voltage of 2.5 volts. Let the 18 volt source feed a network that provides a divided voltage of about 3.125 volts. When the 18 volts drops by 21% (14.22 v) the 3.125 volts will drop below 2.5 volts, sending the output of the comparator high. You can incorporate a feed back loop to make switching faster if you don't get the desired rise time from the brown-out condition.

I chose 14.4 volts as the threshold for triggering the auto-save because 12 volts is 33.3% below normal operating voltage. You CAN use whatever values you like for the other two resistors, that's why I left them blank (actually I was having trouble calculating the values - to be honest - not my strong suit). But I think this will work.

BrouwOut Trig.png
 
Last edited:

dannyf

Joined Sep 13, 2015
2,197
A simpler approach is to use a gpuo pin with St input structure, driven by a resistive divider on the 18v line.

Once the pin goes logic low, it triggers an interrupt, .....
 

Thread Starter

PickyBiker

Joined Aug 18, 2015
101
dannyf, i like your idea, although i'm not sure what an St input structure is.

On my microprocessor inputs are guaranteed high at .7 * vcc which is 2.24V. A guaranteed low is .3 * vcc or 0.96V. Input pin current is only 5ua so I can ignore that in the calculations. if I use a divider of 20k and 3.1k, then at 18V, it would be at 2.416 (logic high). It would have to drop to 7.154V in order to reach a logic low of .96V. at 7.154V the regulator is still putting out 5V so there is plenty of power and time to save two bytes into EEPROM.

Since this is the recommendation with the fewest parts, I will try this out and let you know if it works.
 

ErnieM

Joined Apr 24, 2011
8,377
One thing you should consider is extending the time to save the data.

One simple way is to put a diode and a large cap between your 18v and the regulator. The 18 v is thus free to drop out while your micro runs along on the energy stored in the cap.
 

BobaMosfet

Joined Jul 1, 2009
2,110
Just off the top of my head, given the voltage requirements stated, I've put a small schematic together. Once power is no longer supplied to the regulator, essentially power is coming from both C1 & C2, and will do so based on the load's overall impedance. In the schematic, the voltage divider R1+R2 essentially acts as a pull-up for the transistor Q1, keeping it OFF. When power fails, R1 & R2 essentially become a pull-down for C1 to cleanly take the line-side to ground, which activates Q1. once Q1 is activated, you know that the MCU is operating off of C2 via MCUVCC. Q1 begins to conduct to BOD-INT, which should be a pin on the MCU that generates an interrupt if it goes high. I only showed the resistor values specific to limit current to proper levels. 2mA for R1 and ~1mA for R3.

bod.jpg
(see updated schematic, further down)

When the MCU is first powered- up, I'd have it wait 1 second before enabling the pin-interrupt on BOD-INT, so you don't have an erroneous write to the EEPROM.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
Just off the top of my head, given the voltage requirements stated, I've put a small schematic together....
It is a nice idea that may work once or twice. Reason being these regulators cannot be reversed biased like you wish. They pretty much instantantly blow up due to the reverse in to out voltage.

If you put a diode between R1 and C1 then this could work as long as C2<C1, or you have a diode out to in as the regulator data sheet will tell you.
 

BobaMosfet

Joined Jul 1, 2009
2,110
It is a nice idea that may work once or twice. Reason being these regulators cannot be reversed biased like you wish. They pretty much instantantly blow up due to the reverse in to out voltage.

If you put a diode between R1 and C1 then this could work as long as C2<C1, or you have a diode out to in as the regulator data sheet will tell you.
Updated schematic:
bod.jpg
I looked at this more-- thanks again for your sharp eye on the diode-- I feel silly I missed that. I agree, putting it between R1 and C1 seems to be the best place for it. I also looked at doing this with a 4N35, but wound up with more parts overall.... In the end, a resistor and an inverting logic gate would be the simplest for providing appropriate logic to an interrupt pin, but the IC might be more expensive than a handful of components I've used. I don't consider the diode an 'extra' part, as it should be on the circuit _anyway_ for polarity protection.
 
Last edited:

Thread Starter

PickyBiker

Joined Aug 18, 2015
101
Thank you all for the many good suggestions.

In my case, C1 is quite large at 1000mfd and C2, is quite small at 10mfd. To add some information, I measured the power supply slope after power off and the 18V supply reached 9V after about 220-225ms. It only needs < 10ms to write the EEPROM data so the writes will happen under full power as long as I trigger them at or before 9V (in fact, the regulator works all the way down to 7V). I will shoot for triggering at 13.5V to be conservative about not triggering too early or too late.

1st up for build and test is a zener diode over a resistor divider feeding a microprocessor input pin that will cause an interrupt.
 

Thread Starter

PickyBiker

Joined Aug 18, 2015
101
Success! The zener diode over a resistor divider feeding a microprocessor input pin that will cause an interrupt worked. I have a 12v zener over a 10k/4.7k divider. Although that shortens my power window to about 130ms it still has plenty of time to write the two bytes of data. In fact, to check the margins, I send a message out the serial port saying "Entering eeprom save", save the two bytes and then send a message saying "Exiting eeprom save". That works fine too so clearly there is plenty of reliable power for this BOD.

Thanks for all the good suggestion and especially to dannyf who suggested the one I successfully implemented.
 

dannyf

Joined Sep 13, 2015
2,197
I'm glad that it worked out for you.

I think you will find that the BoD feature of mcu can be useful in cases like this, if your mcu supports it. That will save a few and a few parts. Worth experimenting.
 
Top