DC (via PSU) switch...
 
Notifications
Clear all

DC (via PSU) switching to battery

33 Posts
4 Users
8 Likes
639 Views
RomeoSierra
(@rsalvage)
Active Member
Joined: 12 months ago
Posts: 7
Topic starter  

Hi All.

Firstly, I am quite inexperienced at electronics but try very hard to solve my own problems before asking for help.  IMHO that is the best way to learn - especially in these days of the internet and youtube rather than having to get on a bus and visit the library!  Dronebot workshop has been a fantastic resource and after watching I have incorporated several 74HC165 and 74HC595's in my project.

All of that said, there comes a time when you do need to ask for help, and this is it for me.

My circuit and programming is quite complex but it is a basic thing that is causing me a problem.

I have a pre-built (purchased/chinese) switchover relay.  On one side it has 7.6v coming in via a DC PSU and on the other it has 6xAA batteries @ 2000mah.  The output is 7.6vDC default via the PSU, switching to battery when DC power is lost.

My problem is that there is a 1/4 sec (unmeasured) loss of power during the relay switch, which is causing my ESP32 to reboot.

I have tried to put a 3300uf cap in to smooth it and that didnt work.  I then doubled the 3300uf in parallel to create 6600uf and that didnt work either.

My circuit draws ave 220ma with a peak of 290ma when the SIM800L transmits (telling me there is a power problem!).  During the design and build the circuit works fine.   I assumed (lesson now learned) that the relay board would take the switching into account and provide a smooth output but it doesnt.

LUCKILY I decided to run a final test before etching the board.  That is when I found this problem.

Unfortunately I am not allowed to upload a diagram or picture for some reason.  The "dia" below

DC--->

             Relay module --+ve--------1N4001 DIODE---47K Res -- 3300uf CAP --- Load (eg test LED)

Batt -->                     -ve  GND

Any help would be greatly appreciated.


   
Quote
DaveE
(@davee)
Prominent Member
Joined: 2 years ago
Posts: 678
 

Hi @rsalvage,

  Switching a relatively high current with a relay without risking a brownout voltage dip is tricky.

Depending upon the design of your whole circuit, it might be possible to arrange a 'protected' supply for the ESP32 with extra 'hold up' circuit, but that requires a very customised approach following detailed analysis of your specific circuit. The ESP32 seems to have a fairly narrow 'tolerance band' when it comes to power supply voltage, and the internal brownout circuit ensures the slightest dip causes a reset.

Similarly, it is possible that your relay switching circuit could be modified to detect the supply failure before the power voltage has appreciably fallen. Assuming your 7.6V supply includes a voltage regulator, a 'system' approach might be to monitor the power input to the 7.6V regulator, and switch as soon as it starts to fall. Obviously, this assumes you have access into the internals of the power supply, which (for safety reasons) I would not recommend if you are not familiar with such circuits.

A common approach is to arrange for the back up voltage (say 9V) to be less than the normal voltage (say 10V) by at least one 'diode drop' -- maybe 0.7V. Connecting the output to each of the two supplies to the power input point via a diode in each line, each diode orientated to conduct from its supply, as illustrated below:

image

When the 10V power is available, its diode (D1) will be forward biased, and the unit powered, albeit with the loss of a fraction of a volt. The other diode (D2) will be reverse biased, since the 10V supply will be ensuring the input to the unit is a higher voltage than the battery (9V).

When the normal voltage disappears, the back up supply voltage will maintain the load input voltage at about 8.3V, assuming D2 is 'simple' silicon diode.

Obviously these voltages etc. are a bit different from yours, and only chosen to illustrate the concept. It assumes that the voltage regulation built in to the 'load' can cope with any changes you make. It also assumes your 7.6V supply can be converted/changed to provide a higher voltage than the battery. (NB 6 x AA new batteries are likely to output about 9.6V, which should be included in your calculations.)

Depending upon the design of your "10V" power supply (V1), you might be able to replace D1 with a wire link, thereby removing the voltage drop from D1. Some power supplies will play nicely when the voltage on their output is supplied from elsewhere, some will draw some current depleting your batteries, others may follow the "magic smoke" route.

It is possible to replace D1 and D2 with a pair of power FETs and appropriate drive circuit to emulate the diodes function. The advantage is FETs are essentially 'resistors' from drain to source when conducting, and it is feasible to reduce the resistance to the milliOhms range, thereby reducing the voltage drop. The downside is the extra complexity. I have read about chips specially designed for this purpose, but I can't remember if they are appropriate for your voltage, current and budget levels.

----------

Sorry, I don't have a simple magic answer .. perhaps someone else will do a better job.

Best wishes. Dave


   
ReplyQuote
RomeoSierra
(@rsalvage)
Active Member
Joined: 12 months ago
Posts: 7
Topic starter  

@davee I really appreciate your input.  Thank you very much.

As I said, I am a beginner here and need to learn.  That said, this is only my second ever build in less than 12 months and I am quite proud of it as I started with zero knowledge (although I am sure that all of you experienced guys/gals are frowning and rubbing your brow looking at the attached schematic!).

In the top left of the schematic is a connector.  This is the power that comes from the relay module. Pin 3=GND  /  2=7.6v to a 7805 to provide 5v   Pin3=takes the 7.6 back out to a buck converter which provides 4.6v for the SIM800L (Conn U5 on the right) .  Research tells me that a buck converter is good as it can supply the current that the SIM800L requires.

I was only using the PSU at 7.6v as it is the min that the relay circuit and buck converter needs.  I thought anymore would just be wasted as heat on the 7805.  What I am trying to say is that I can afford to change to your circuit as the voltages are not critical.

I have run out of time today to try it, but genuinely appreciate your constructive and detailed reply and as soon as I get some time back behind the bench I will do some experiments and let you know how I get on.

 


   
ReplyQuote
DaveE
(@davee)
Prominent Member
Joined: 2 years ago
Posts: 678
 

Hi @rsalvage.

I hope my suggestions are helpful.

I have had a quick glance at your schematic and my first impressions are generally good, but (of course) I will only comment on my concerns/thoughts, some of which are trivial .. hope that is ok:

  • As discussed below, at first sight your circuit needs 4.1V for the Sim800L, and 3.3V for the rest, except perhaps the LEDS?
  • ESP32 I played with could be 3.3V direct to the chip or 5V, which is converted to 3.3V by onboard linear regulator. This reg was small and only had PCB for heatsink, so I don't know how hot it will get with 7.6V. Might wish to have another regulator, or make the 3.3V supply sufficient to drive ESP directly? I presume this could also be a buck regulator, albeit with some extra capacitance if you are using the ESP32 WiFi transmitter!

 

 

  • Taking above 2 comments, maybe my original suggestion of 6 x AA = 9.6V battery, 10.6V (approx) mains power, with two diodes is appropriate? This should move smoothly from power source to the other , without needing a relay or dipping below the battery voltage (minus diode drop). Probably choose 2.5A (or more) diodes to allow for SIM800 and ESP32 current peaks? Schottky diodes have a lower voltage drop, which might also be helpful.

Other trivia to consider

  • ESP32 is 3.3V only chip. Connecting devices like U2 with 5V outputs risks problems, including magic smoke or short life. I know many others on the web do similar things, and I suspect the ESP32 internal ESD diodes drag enough current to bring the effective output voltages within range, at least for a while, but it doesn't feel right. In your case, I only spotted inputs to this 5V supplied chip, so perhaps the ESP32 is unlikely to be in mortal danger, but the minimum input voltage for the high logic level for the HC chip when powered at 5V, is probably above the high output voltage that the ESP32 could produce, risking the 74HC chip being held in a 'midway logic' position, which is also not good. I presume your concern is getting a high enough voltage to drive the LEDs. In practice, your arrangement will probably work, but in the future, consider using an additional open collector/drain buffer chip to drive the LEDs and keep the logic chips connected to the 3.3V system.

 

  • LED0 looks backwards
  • Try to draw GND symbols downwards ... sometimes sideways (e.g. on the ESP32) is ok, but never upwards

Hope this is useful and good luck .. I hope it all works!


   
RomeoSierra reacted
ReplyQuote
RomeoSierra
(@rsalvage)
Active Member
Joined: 12 months ago
Posts: 7
Topic starter  

@davee Thanks.

The buck, relay board and psu are not on the schematic as they are all pre-manufactured.  That is why I have used connectors.

I used 5v because I originally intended to use 5v for the power to the ESP32.  Only to find that it needed more than 5v in order to work (which is why I utilised the convenient 7.6v).  There was a reason that I used 5v, but it escapes me now.  I will take a look later and try to drop everything to 3.3v via a second buck converter.

I will check the LED and sort my symbols.

 

Thanks again.

 


   
ReplyQuote
DaveE
(@davee)
Prominent Member
Joined: 2 years ago
Posts: 678
 

Hi @rsalvage,

  If the ESP32 card has a USB socket that it should work with, then 5V ought to be enough .. as that is all USB (excluding the new high power USB-C modes) provides. However, it is widely accepted some modules struggle when the WiFi is on.

If a higher voltage than 5V 'fixes' the problem, this suggests the onboard regulator is struggling with the peaks, since this is the only device that sees the incoming voltage ... the rest is powered by the 3.3V output from the regulator.

One might guess, that a 'rock solid' 3.3V supply to the appropriate pins would also work, but no guarantees!

Good luck, Dave


   
ReplyQuote
RomeoSierra
(@rsalvage)
Active Member
Joined: 12 months ago
Posts: 7
Topic starter  

@davee Firstly, let me apologise for not getting back to you sooner.  Hard to believe, I know, but yesterday was the first chance (since January) that I managed to get back to my electronics desk.  Life had a habit of getting in the way, and electronics / hobbies had to take a back seat.

Thankyou and sorry.

I managed to rig up your diode idea last night and it works perfectly thank you.  I ended up changing some things to make it work.  The 6 x AA rechargeable batteries give 7.8v, which is exactly what I was pumping in via the power adaptor.  I used an 8v2 Zener diode and pushed the adaptor output up to 8.7v to make sure that it was supplying more power than the battery pack. 

The raw feed from the battery pack / adaptor feeds an LM7805 to power the ESP32, so turning up the power should not matter.  The raw feed also splits off to power a buck converter taking the SIM800 voltage down to 4.2v so again, the extra power doesnt hurt.

Thanks again and please do not think I was ungrateful for your answer.  I truly appreciate it and look forward to talking to you again.

Richard


   
ReplyQuote
DaveE
(@davee)
Prominent Member
Joined: 2 years ago
Posts: 678
 

Hi Richard @rsalvage,

  Great to hear you have been successful. I know how time flies when the project isn't the most important thing to do.

What you have done sounds great ...

With projects like yours, keep an eye ... or more accurately a finger .. on the temperature of the onboard regulator on the ESP board when it is 'busy'. to make sure it isn't getting too hot. Warm and even 'comfortably hot',  is usually fine, but 'Ouch' is not!

I think it will be fine in your case, as you have sensibly kept the incoming voltage to a fairly low value, but it doesn't harm to double check.

Now for your next project ... ?  😀 

Best wishes, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 3392
 

@rsalvage Bill used a 2.1mm chassis-mount power jack with an internal cutoff switch in one of his esp32CAM projects, look for it under power supply. In his case the batteries maintain power even when the power jack is inserted or not inserted, IIRC, there is never a time there is NO voltage at the + pin. In his case it was 9V but the same jack can be used for other voltages.

Here is the blog post, see the section titled 'Power Supply Hookup'

https://dronebotworkshop.com/esp32-cam-develop/

"Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon


   
ReplyQuote
DaveE
(@davee)
Prominent Member
Joined: 2 years ago
Posts: 678
 

Hi Ron @zander and Richard @rsalvage,

   Your solution assumes that the only reason to be addressed, is that the mains power fail is because the user unplugged the power supply.

Furthermore, the user must always remember to plug in the battery before disconnecting the mains supply, and disconnect the battery when they have restored the mains supply.

There is a chance that the plugging action will result in momentary poor contact, and brownout. I don't think it is possible to quantify that chance with any useful accuracy. Even experimental evidence of a particular plug and socket may change with time. I am not in a position to judge whether this risk is acceptable.

If the user is content with these limitations, then Ron, your/Bill's solution is simple and effective.

----

However, Richard @rsalvage did not specify the reasons/requirements but he clearly had an automated approach in mind, with his trials with relays.

Hence, I suggested the relatively simple approach to achieve his apparent wishes, using two diodes. It has the advantages of not requiring manual intervention, plus it also copes with short interruptions to the mains supply for any reason.

As in many cases, there are multiple solutions to a problem ... but choosing between them means refering to comprehensive requirements, which in even the most expensive and professional situations, are not always readily available.

Best wishes to you both, Dave


   
ReplyQuote
RomeoSierra
(@rsalvage)
Active Member
Joined: 12 months ago
Posts: 7
Topic starter  

Indeed, I thank you both for your input.  As a novice, I have lots to learn.

I live in the UK, but have a property in rural Romania.  The power to the house is 3 phase as I use electicity to heat the underfloor heating (and yes, it is expensive but the alternative was wood, and I did not fancy flying over there every few hours!).

I also have CCTV inside and out.

From time to time, I lose CCTV and power - meaning that the heating stops and the freezer defrosts.  Not good in -15 degrees of winter.

[a very high level overview here - this is more complex than the description looks, as I also load in lots of variable info via an online web interface and do some jiggery pokery with the output data].

The device I have created monitors each of the 3 phases, Wi-Fi and internet connection. it reports any failures to a web SQL database which then updates a monitor web page.

If the intenet is off, it cannot report to the website, so I use a SIM800L in GPRS mode.  That is fine if the internet is down, but what if the power is down?

That is where I need the auto switchover. 

If the power is down [and battery comes in], the data is flashed into eeprom (for later upload when the power is back) but a message is sent to my mobile phone via good old fashioned SMS over 2G.

Effectively it is a cascade - send via Wi-Fi -> GPRS -> SMS

If it cannot send it at all, it stores it in EEPROM and the next time it gets a successful ping to google.com it sends it to the SQL database.

I know that this seems a little complex for a "novice" but I was a programmer in the good old days (started in early 80's with a Sinclair ZX81 and never looked back) and it is just the electonic piece which is hard for me.

I WAS going to go 2 x LIPO 3.6v with an auto charger when the power was back on but I simply dont have the time.  I am going back out in August which is why I have put other stuff aside and turned back to it.  I will mount my battery feed using a connector, which means I can build a LIPO/Charger/Power feed another time and just replace the 6 x AA's.

Hope you dont mind me filling in the blanks.

Thanks again both of you.

Richard (got to go as I am supposed to be at work!)


   
ReplyQuote
DaveE
(@davee)
Prominent Member
Joined: 2 years ago
Posts: 678
 

Hi Richard @rsalvage ,

Thanks for the update, which is  very interesting. I hope you now have a solution that meets your needs.

As a postscript:

Take a little care over the battery charging .. it's a bit beyond my useful experience, but I do know a mismatch /poor design can result in the charger giving the battery a 'hard time' .. usually by trying to 'gently' overcharge it,  which is often associated with shortened its life, especially when it is happening 24x7.

By comparison, leaving it slightly short of the 100% charge level could be much kinder and result in a longer life.

So maybe choose a battery one size bigger than you think you need, and aim to charge to 90% .. I think most chargers look at the battery voltage to decide if it needs charging, so maybe it is possible (in some cases), to tweak this. I have never done it, so this is only a random thought .. treat with as many pinches of salt as you wish.

For most lithium battery based devices we buy (phones, etc.) . size, weight and cost all point towards the manufacturer trying to get as near to 100% charge range as possible. In your case, I presume none of these three constraints are particularly important, so you have an opportunity to 'tune' it to your requirements.

Best wishes and good luck, Dave

 


   
RomeoSierra reacted
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 3392
 

@davee And let's not forget that some chemistries are more likely than others to overheat and catch fire.

I use LiFePO4, Lithium Phosphate because they are very safe even though the energy density is not as good as some others.

"Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon


   
DaveE and RomeoSierra reacted
ReplyQuote
DaveE
(@davee)
Prominent Member
Joined: 2 years ago
Posts: 678
 

Hi Ron @zander an Richard @rsalvage

 Thanks for the LiFePO4 mention..as you say the AmpHrs that fit in a given package size tends to be lower, and also the voltage is somewhat lower, so Whr per unit volume is less, but their intrinsic safety appears to be much higher.

 

I did a relatively quick 'Internet paper survey' of battery technologies a few years back, and this technology came out as the least likely to go into thermal runaway

... unlike most/all of the other types, which when their temperature exceeded a certain value, could not be stopped from catching fire by changing the electrical charging or discharging ...the only 'simple' effective treatment was to dramatically improve the cooling ... typically by drenching in water.

Please note, the most useful papers I saw were reviews of earlier papers, and commercial sensitivity limited the number of open papers in total, so much of the information I saw is now 10 or more years old. Hence my reluctance to push it too strongly.

---------------

I did wonder about mentioning it, but at the same time wondered if this would be going 'over the top', given that I have laptops, phones, headlights, drill, plane, etc, all around the house, and without checking, I am pretty confident, none will be iron phosphate type.

Of course, these are all fairly small batteries, probably below 50 Whr for the laptops, and much less for the other items. I was guessing this back up would also be small .. presently being 6 AA NiH

If I get involved in the larger batteries that I think (Ron) you have, or even the intermediate sizes that appear in the larger bots on this forum, I would be much more strongly attracted to looking into the battery type.

I should also mention, a theme from my paper survey, is that LiFePO4 cells were reported to have a much longer life (in terms of charge/discharge cycles), especially if you treated them kindly.

--------

Richard, As I say, my discussion is based on limited and now rather aged information .. I am sure things have moved on, but maybe (say) 2 or 3 18650 LiFePO4s, with suitable (ie designed for LiFePO4) charging and balancing circuitry, would be worth considering.

Best wishes, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 3392
 

@davee I have never heard of 18650's coming in LiFePO4. It is the 18650 that is often shown on fire. There is a well known flaw plus the batteries come in a protected version (micro BMS?) and an unprotected version. The unprotected are the problem. The other flaw is some batteries are constructed in a way that if you insert the negative end first then slide the positive end down the brass strip, the negative outside case and the positive end can both be in contact with the brass strip. Ask me how I know.

I have more than a dozen of every kind of 18650. I have a decent quality charger. I NEVER leave the batteries unattended in the charger. If it's an unprotected variant, I will periodically check for heat very carefully.

SInce the OP is doing this in a remote location then the unprotected cells are a nogo.

I am unable to evaluate his proposal versus a commercial UPS.

"Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon


   
ReplyQuote
Page 1 / 3