User avatar
theoB610
Posts: 233
Joined: Sat Jan 05, 2013 12:40 pm
Location: Devon

DIY lipo low voltage alarm

Fri Sep 20, 2013 3:45 pm

How tricky would it be to make my own onboard lipoly low voltage alarm?
I want to do a bulk order from Hobbyking and theirs are out of stock, so thought I could make my own. All I need is a buzzer and a ?comparator or something?

User avatar
theoB610
Posts: 233
Joined: Sat Jan 05, 2013 12:40 pm
Location: Devon

Re: DIY lipo low voltage alarm

Sat Sep 21, 2013 3:54 pm

How would I go about doing this?

User avatar
rpdom
Posts: 17549
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: DIY lipo low voltage alarm

Sat Sep 21, 2013 4:17 pm

I'm assuming you are doing something like running your Pi from a LiPo connected to a UBEC 3.7v(ish) to 5v converter.

You can build a simple low-voltage detector using a 555 chip, a couple of resistors and a couple of capacitors. The 555 has a voltage comparator in it and by running it from 5V and connecting the LiPo output to it with the right resistors it can be made to turn on when the voltage drops to 3V (for example).

A quick web search on "555 voltage comparator" or "555 battery monitor" will give you quite a few examples.

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: DIY lipo low voltage alarm

Sat Sep 21, 2013 7:57 pm

Same thing can be accomplished with a low power op-amp, such as LM124, http://www.ti.com/lit/ds/symlink/lm124-n.pdf and few resistors, the advantage is that supply current will be 1/10 of the supply current needed for 555 circuit, so your monitor will drain your battery less as it would with the 555 chip..
You can use internal 3V3 source as a reference for the comparator circuit.

Roman

User avatar
theoB610
Posts: 233
Joined: Sat Jan 05, 2013 12:40 pm
Location: Devon

Re: DIY lipo low voltage alarm

Sun Sep 22, 2013 8:18 am

RomanG wrote:Same thing can be accomplished with a low power op-amp, such as LM124, http://www.ti.com/lit/ds/symlink/lm124-n.pdf and few resistors
so connect the pi 3.3V to the power of the op-amp and the INPUT1 V-
INPUT1 V+ connected to the balance connector of the battery
OUTPUT connected to buzzer + LED and ground

Where do the resistors go?

EDIT: Just found an LM324N in a random kit that I'd made, will it do the job?

User avatar
rpdom
Posts: 17549
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: DIY lipo low voltage alarm

Sun Sep 22, 2013 9:09 am

Well, the 555 doesn't use a lot of current at 5V, about 6mA if I read the specs correctly. You could always use a 7555 which takes 0.06mA and doesn't really need the capacitors, just two resistors.

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: DIY lipo low voltage alarm

Sun Sep 22, 2013 9:29 am

Does your ESC contain its own BEC or have you an independent UBEC? If it's built in, are the small black wire and large black wire connected directly - use a multimeter with the LiPo not connected. The reason I ask is that BECs generally use a switching regulator to 'create' the 5v required for the control circuitry (i.e. RaspberryPi) from the LiPo power. Switching regulators can also isolate the 5v supply from noise in the LiPo supply, and the two can be isolated completely. This means they may not have connected GND rails. If that's the case, a 555 with resistors solution won't work unless you rejoin the separate ground connections, and that means some of the protection is lost. Whereas if you use the opamp in differential mode and with the LiPo battery, with 3 (say) 10k resistors in line between it, you can then take the opamp + and - inputs from either side of the middle 10k resistor, leaving the ground wires still isolated. Note that's not a completed solution, just a thought for another solution.
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

User avatar
rpdom
Posts: 17549
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: DIY lipo low voltage alarm

Sun Sep 22, 2013 9:42 am

Hove: Interesting. I didn't know that some UBECs have isolated 0V rails. The (admittedly cheap) selection I use all have the 0V common to input and output.

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: DIY lipo low voltage alarm

Sun Sep 22, 2013 10:43 am

I should be honest that what I've written is mostly speculation - the ESC I have from DJI uses opto-isolators as the inputs so the inputs are completely isolated from the outputs. The business part of the ESC is driven by the LiPo's. I have DC-DC converter as the BEC to power the RPi - it's a switching regulator with isolation between input and output voltages. It's the output from this which powers the opto-isolator in the ESCs via the brown and red wires.
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

User avatar
theoB610
Posts: 233
Joined: Sat Jan 05, 2013 12:40 pm
Location: Devon

Re: DIY lipo low voltage alarm

Sun Sep 22, 2013 5:12 pm

Most lipo batteries have a balance connector which is where you plug in the bought LV alarms, so I thought I could use that rather than from the LBEC.
I'm going to be using the LM324N chip, because I've got one.
Will I need to put resistors between the balance connector and comparator? Also, where should I source the 5V needed to power the op-amp? From the LBEC of my ESC?

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: DIY lipo low voltage alarm

Sun Sep 22, 2013 6:27 pm

To answer your direct questions first, because the op-amp / comparator is 5v then it gets powered from the BEC, that I suspect you are using also to power a RaspberryPi. Be careful of the op-amp output is to act as a digital trigger for a GPIO pin - it won't take 5v very nicely.

The resistors go across the balance cable, although I think I was completely wrong about using resistors and what you need is a zener diode and resistor. In realizing that, I realized there was a bigger picture question...

So sorry to step back, but what do you want this LV alarm to do? Just beep or flash an LED? In which case, no problem. But if you want it to signal the Raspberry Pi to land / return home the problem becomes more subtle. The current drawn from the LiPo (assuming it's powering a quadcopter) is high and spiky. That means a simple LV alert could get triggered long before you really need it too just by a one off spike. Meaning your flight gets cut short long before it need be.

Sorry I'm not being very helpful but I've not (until now) given a moments though to LV monitoring - until my quad gets off the ground stably for more than a few seconds, then the LV alarm can stay firmly on the to-do list - I know the battery will last for several minutes flight time, and I'm nowhere near reaching that! ;) I just start the day with a full charged battery and that's good enough for me.
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: DIY lipo low voltage alarm

Sun Sep 22, 2013 6:31 pm

324n will work fine, what are you going to do with the comparator output? Turn the LED on? Sound a buzzer? Feed it back in to pi for further processing?
Power the comparator circuit with 5v and use 3v3 as a reference.
Roman

User avatar
theoB610
Posts: 233
Joined: Sat Jan 05, 2013 12:40 pm
Location: Devon

Re: DIY lipo low voltage alarm

Sun Sep 22, 2013 7:10 pm

Hove wrote: The resistors go across the balance cable, although I think I was completely wrong about using resistors and what you need is a zener diode and resistor.
How? What setup?
Hove wrote: ...what do you want this LV alarm to do? Just beep or flash an LED? In which case, no problem...
Yes, exactly that.
Hove wrote: ... That means a simple LV alert could get triggered long before you really need it too just by a one off spike. Meaning your flight gets cut short long before it need be.
How can I avoid this?


Oh and Hove, am I right in thinking that you are writing your own flight control program? That's kinda what I hope to do. Is it phenomenally hard?

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: DIY lipo low voltage alarm

Mon Sep 23, 2013 3:06 am

theoB610 wrote: so connect the pi 3.3V to the power of the op-amp and the INPUT1 V-
INPUT1 V+ connected to the balance connector of the battery
OUTPUT connected to buzzer + LED and ground

Where do the resistors go?
Ok, if you just want to power an LED, that can by driven directly from the op-amp (with resistor).
What voltage is your LiPo pack? Is it 2S or 3S configuration?
At what voltage do you want your alarm to go off?

The way the "op-amp as a comparator" works in this case is as follows.
You power the op-amp form a single 5V supply, so that your high rail voltage is 5V and your low rail voltage is 0V (ground).
Connect the 3v3 reference to the non-inverting input (+) of one of the four op-amps on LM324N (through a 10k resistor).
Then you will need to create a voltage divider by using two resistors. Input voltage to the voltage divider is your battery pack voltage, output voltage of the divider will be connected to the inverting (-) input of the op-amp. Resistor values will need to be set up such that when your pack reaches the alarm voltage level, output of the voltage divider will be 3v3.

Then to avoid false alarms due to momentary load changes, you can create a delay, by feeding the output of the comparator to another op-amp of the LM324N through a resistor and capacitor connected to ground. Output of this RC network will go to the non-inverting input and the inverting input will be connected in to the 3v3 supply. Output of this second comparator will be connected to the LED (through a resistor). That's it.

When your battery pack voltage is above the alarm voltage, voltage divider will scale it back but it will be still higher than 3v3, so the inverting input voltage will be higher than non-inverting input voltage and the output of the op-amp will be at low rail voltage.
When your battery pack reaches alarm voltage, voltage divider will scale it back such that it will be 3v3, then since the inverting input will be less than non-inverting input, output of the op-amp swings to the high rail voltage.
That will start to charge capacitor, similar process as described above is happening on the second comparator. Until voltag eof the capacitor reaches above the 3v3 reference, the LED is off, as soon as voltage of the capacitor (and of the non-inverting input of the second comparator) exceeds 3v3, the LED will be on.

If there is a short voltage dip due to a sudden load change, but the duration of the dip is less than the time delay given by the RC network nothing will happen.

Roman

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: DIY lipo low voltage alarm

Mon Sep 23, 2013 3:13 am

One more thing I forgot, if you want to drive a buzzer as well, you may need a buffer, since buzzer usually draws more current than op-amp can source. Op-amp can usually source up to 20mA, which is enough to drive an LED but not enough for a buzzer.

Roman

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: DIY lipo low voltage alarm

Mon Sep 23, 2013 3:27 am

here is the quick schematics
Image


Roman

User avatar
clicky
Posts: 499
Joined: Thu Oct 25, 2012 7:34 am

Re: DIY lipo low voltage alarm

Mon Sep 23, 2013 8:38 am

Strangely enough I am preparing to get on the same issue, too, but I took completely different path: I am, currently, coding for i2c slave for AVR processors and my idea is to use their ADCs to monitor battery voltage directly. Next is to use a relay (solid state if possible) to power BEC (or any other converter from 8V (2S), 12V(3S) or even 24V(6S as I have a few old batteries) to 5V) controlled by same uController. The uController's code would, then, supply current voltage back to RPi for monitoring but have ability for cut-off voltage to be written in (and stored back in EEPROM) to autonomously switch the power off if reached. Also, I expect to have some kind of 'switch off on timer' build in that i2c slave, too - so I can trigger it from shutdown script and let RPi power off itself, too.

Grander version of it would include more than one battery, good capacitors and ability to switch from one battery to another... But, that's definitively further in the future.

hampi
Posts: 223
Joined: Fri May 31, 2013 11:29 am
Contact: Website

Re: DIY lipo low voltage alarm

Mon Sep 23, 2013 9:05 am

clicky wrote:Strangely enough I am preparing to get on the same issue, too, but I took completely different path: I am, currently, coding for i2c slave for AVR processors and my idea is to use their ADCs to monitor battery voltage directly.
That is similar to what I am testing now for a 12 V SLAB

https://github.com/oh7bf/RaspiPwr12V

Works almost but there is some issue on re-powering the Raspberry Pi after sleeping one hour or more.

Return to “Automation, sensing and robotics”