View Single Post
Old 07-31-2018, 09:47 PM
citfta's Avatar
citfta citfta is online now
Gold Member
Join Date: Jun 2008
Posts: 1,321
Originally Posted by axxelxavier View Post
I am trying to make a battery swapper for 2 batts setup with arduino, did anybody find a way to solve the voltage threshold issue? So, when the first battery reach the lower level voltage, arduino should switch to second battery, and stay there until he reach also the low voltage, and so on.
I am a complete beginner in programming, but even so, I have learned a lot in past 2 weeks, and after some experiments with N channel Mosfet as switch (VERY INTERESTING, low current draw, but unfortunately, with a BIG issue - non-isolation), now I'm working with relays.
For my setup, I'm using 2 custom voltage divisors, an Arduino Nano, 4 relays board with optocoupler isolation, all powered by 4 x 18650 Li-Ion and a buck converter, to step down voltage to 5 volts. All setup will be soon wired up on a single board.
So far I manage to switch battery at low voltage, but when the load is removed and the battery regain voltage, very quick the setup stay in a kind of perpetual loop On-Off.
Can anybody help me on this?
Matt is probably a better programmer than I am on arduino but I do have a suggestion while you are waiting for his input.

What you basically need to do is have two loops. One for each battery. Only one loop should be running at any one time. As a loop runs it needs to read the battery voltage like you apparently have it doing correctly. When the battery reaches the low voltage you have set you need that to signal the program to jump to the loop for the other battery. Then it should stay there until that battery reaches it's low voltage target which will then trigger the program to jump back to the first loop and first battery.

I hope this gives you enough info to get it working. I am much more familiar with programming the picaxe chips.

Good luck,
Just because someone disagrees with you does NOT make them your enemy. We can disagree without attacking someone. This means YOU especially BroMikey.