United Kingdom
Asked — Edited

2S Lipo Battery Monitor

As also posted in my Hearoid showcase topic, but useful for anyone running LiPo batteries (could be adapted easily for 3S and 4S without too much of a problem).

Parts needed: 1 x Zener Diode 5.1v 500mA (Farnell ref 1861447) 3 x 100k ohm Resistors (Farnell ref 9339078) 1 x Small Piece of Strip Board (12 strips x 7 rows) - Maplin FL17T 3 x Pin Header (1x3) or 1 x Pin Header (1x3) and 1 x Pin Header (1x6) eBay Search 1 x servo Extensions (male to male) - made from 2 normal ones cut & soldered. Solder Soldering Iron Cutters

The Schematic: User-inserted image

User-inserted image

Method:

  1. Solder R1 - 100k resistor from Row 2 Column 3 to Row 2 Column 11 User-inserted image

  2. Solder R2 - 100k resistor from Row 3 Column 5 to Row 3 Column 11 User-inserted image

  3. Solder R2 - 100k resistor from Row 4 Column 7 to Row 4 Column 11 User-inserted image

  4. Solder D1 - Zener Diode from Row 5 Column 5 to Row 5 Column 11 (Band to the right) User-inserted image

  5. Solder the pin headers on Row 1 Columns 1, 2, 3, 5, 6, 7, 8, 9 & 10 User-inserted image

  6. Solder some black off cuts of wire from Row 6 Column 1 to Row 6 Column 5 and from Row 7 Column 5 to Row 6 Column 8 User-inserted image User-inserted image

  7. Solder an off cut of red wire from Row 7 Column 2 to Row 7 Column 10 User-inserted image

  8. You're all done. Plug the balance port connector in to the 3 pin header on Row 1 Columns 1 to 3 (Ground to the left) and plug in some servo extensions (male to male) or 3 pin JST to servo on the two other headers (Ground on left on both), connect the other ends to ADC0 and ADC1 (or any other two ports if those are taken but you will need to adjust the script below if you do).

Now, to use the information in ARC...

The EZ Script


# Read voltage level of 2S LiPo battery and report to software.
# Set variables
# Change $vundervoltage to the under voltage of your specific battery (leave at 3v if unsure)
# Change $vcritical to your lowest voltage you wish for the battery to get before human intervention
# Change $vmin to low level alert value
# Change $vmax to battery full charge
# Change $multiplyer if using voltage divider
# Factor is 5/255 for adc value conversion to volts
$vundervoltage = 3
$vcritical = 3.5
$vmin = 3.7
$vmax = 4.5
$multiplier = 2
$factor = 0.019607843

:ReadCells
# Get ADC values
$vc1 = GetADC(ADC0)
$vc2 = GetADC(ADC1)

# Convert values to voltage
$cell2 = $vc1 * $factor
$cell1 = $vc2 * $factor * $multiplier
$cell1 = $cell1 - $cell2
$batteryv = $cell1 + $cell2

# Check for errors on circuit
IF ($cell1 > $vmax or $cell2 > $vmax)
  Print("Battery Monitor Error")
  Print("Check Monitor Circuits")
  
  # Check for errors on battery connection
ELSEIF ($cell1 <= 0 or $cell2 <= 0)
  Print ("Battery Connection Error")
  Print("Check Battery Connection")

  # Check for under voltage
ELSEIF ($cell1 <= $vundervoltage or $cell2 <= $undervoltage)
  Print ("Battery Under Voltage")
  Print("Check Or Replace Battery")

  # Check if at critical levels
  # Cell 1
ELSEIF ($cell1 <= $vcritical)
  # Do sometihing if critical
  Print("Cell 1 Critical")
  # Shut down all power, switch to back up battery alarm?
  
  # Cell 2
ELSEIF ($cell2 <= $vcritical)
  # Do sometihing if critical
  Print("Cell 2 Critical")
  # Shut down all power, switch to back up battery alarm?
  
  # Check if below recommended levels
  # Cell 1
ELSEIF ($cell1 < $vmin)
  # Do sometihing if voltage low
  Print("Cell 1 Low")
  
  # Cell 2
ELSEIF ($cell2 < $vmin)
  # Do sometihing if voltage low
  Print("Cell 2 Low")

ELSE 
  # Output voltages
  Print("C1 Round($cell1,2)V")
  Print("C2 Round($cell2,2)V")
  Print("To Round($batteryv,2)V")
ENDIF 
# Wait 5 seconds
Sleep(5000)

# Go back to the start
Goto(ReadCells)

Note: The;) should be just a normal closed bracket ) but the forums tend to think otherwise.

EZ-Cloud Download

Update: Refer to page #2 post #18 for updated code taking in to account the updated syntax


ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

#1  

Hi Rich,

Today I found my Lipo Turnigy 2S 3000mAh dead with the 2cells measured at 1V (Wall-E stayed "on" all day long). So I think I need to build a monitor to shut down the robot when it is critical...

So I am going to follow your tutorial, but I need all the parts (and I have no electronic shop near home). Could you give me a link to a site (ebay or e-shop) where I can buy all the parts needed?

PS: I have found some ebay links but part references are not exactly the same as in your tutorial and I don't want to buy the wrong Zener diode or resistor.

Thanks in advance

United Kingdom
#2  

I use farnell, they are worldwide so you should be ok with them in France. www.farnell.com They have a minimum order value but I have managed to fill it on all orders so far.

I need to revisit this circuit, I finally managed to test it today but it isn't reporting the correct voltages. I think it may be the diode but I cannot be certain, it may be where I'm using 100k resistors and before I was only using 10k.

I'll edit the first post with part numbers from Farnell.

#3  

Thanks a lot.

Don't hesitate to make an update if you modify the circuit. As I am really new to electronic, I am going to follow your tutorial blindly... more or less.

#4  

Thanks for part numbers... do you have any for a simple Strip Board and for Pin Headers? I found around 1800 & 8000 references on Farnell site... I am a little lost.

United Kingdom
#5  

OK, figured out the problem, the diode is causing the circuit to give false readings.

I've removed it on my circuit, it is there for over voltage protection (so if R2 open circuits it could send the full 8V+ in to the ADC port).

I need to try it directly across R2 but if you aren't worried about over voltage (and to be honest, I fed 8v in to my adc and it took it without any smoke but don't count that as a guarantee) build it without the diode.

United Kingdom
#6  

I got my stripboard and pin headers on ebay. I've no idea on any codes or anything

#7  

Ok Rich. Thanks for all the infos.

United Kingdom
#8  

Sorted it, just changing the first post.

The diode is in the wrong place and gives incorrect readings where I originally put it. Directly across R2 gives correct readings and over voltage protection.

Updated the original post.

United Kingdom
#9  

I just read your post again @fredebec. This circuit doesn't shut down the power on low voltage and needs to be connected to the EZB with ARC running for it to warn.

I am thinking up a low voltage shut off circuit too, along with the possibility of adding in a low voltage alarm which is independent of the EZB (like those little lipo monitors that plug in to the balance port). I have a few ideas so far but nothing perfect yet... watch this space though :)

Although if you (or anyone else) have ideas on that please share.

#10  

@Rich, I understand that your circuit does not shut down power, but I think it is a very interresting power monitor. For now, I have a led connected to the Lipo with changing color when the battery go down. However, it do not reflect the balance between the two cells and moreover it is only a visual warning... I want to use your circuit (and script) to monitor the power and send me a message or a tweet if power is too low. Remotely shutting down the power is another story...

Canada
#11  

Just thinking outside the box.

I use cell monitors from E-Bay for all my LiPo batteries. Rather than re-invent the wheel, maybe we could mod these to give a warning to the EZ-B?

I really don't care about individual cells. The LiPo cell monitor start chirping as soon as one cell drops below 3.3v. Maybe tapping into the alarm leads would do the trick?

Might be an easier route than building the circuit? I buy these things for $2-$3 bucks each.

Just a thought. Back to hide under my rock.

United Arab Emr
#12  

It make sense. just an idea as i am not sure of what monitor type and feature you have . However , If you have simpe led indicators such as green and red LEDs on board, We can activate an electronic relay out of it to provide the supply to the EZB with the robot components. If both LEDs are off or simply only the green one. The relay can be deactivated and ultimately will cut the main circuit.

United Kingdom
#13  

A good thought, and one I had but found it to be much easier to just build the circuit, the cost is minimal (3 resistors and a diode from memory).

If the alarm buzzer is less than 5v you could just feed the +v in to an adc, when it activates acd changes and ARC knows. I plan to do something similar with my lipo charger which has a green light that turns on/off when charging or finished.

#14  

This should be listed under tutorials. Nice.

United Kingdom
#15  

I'm sure that eventually all tutorials etc. will get listed as appropriate. It's in the tutorial index I started, which is marked as a tutorial so it's halfway there :)

United Kingdom
#16  

I had a few minutes spare so adjusted the script to suit a 12v Lead Acid battery (or any Lead Acid battery really)


# Read voltage level of a single battery pack and report to software.
# Adapted from LiPo monitor circuit.
# Assumed monitor circuit connected to ADC0
# Set variables
# Default values set for 12v Lead Acid. For 6v divide by 2
# Change $vundervoltage to the under voltage of your specific battery if required
# Change $vcritical to your lowest voltage you wish for the battery to get before human intervention
# Change $vmin to low level alert value
# Change $vmax to battery full charge
# Change $multiplyer if using voltage divider
# Factor is 5/255 for adc value conversion to volts
$vundervoltage = 10.50
$vcritical = 11.31
$vmin = 11.58
$vmax = 12.70
$multiplier = 4
$factor = 0.019607843

:ReadCells
# Get ADC values
$vc1 = GetADC(ADC0)

# Convert values to voltage to 2 decimal places
$batterylevel = $vc1 * $factor
$batterylevel = $batterylevel * $multiplier
$batterylevel = Round($batterylevel,2)

# Check for errors on circuit
IF ($batterylevel > $vmax)
  Print("Battery Monitor Error")
  Print("Check Monitor Circuits")
  
  # Check for errors on battery connection
ELSEIF ($batterylevel <= 0)
  Print ("Battery Connection Error")
  Print("Check Battery Connection")

  # Check for under voltage
ELSEIF ($batterylevel <= $vundervoltage)
  Print ("Battery Under Voltage")
  Print("Check Or Replace Battery")

  # Check if at critical levels
ELSEIF ($batterylevel <= $vcritical)
  # Do sometihing if critical
  Print("Battery Critical")
  # Shut down all power, switch to back up battery alarm?
  
  # Check if below recommended levels
ELSEIF ($batterylevel < $vmin)
  # Do something if voltage low
  Print("Battery Level Low")

ELSE 
  # Output voltages
  Print("$batterylevel V")
  # Output to LCD display here (if required)
ENDIF 
# Wait 5 seconds
Sleep(5000)

# Go back to the start
Goto(ReadCells)

This assumes a 1/4 voltage divider has been used to drop the 12v down to 3v which is suitable for the ADC port (5v max). If you use a 6V battery you can use a 1/2 voltage divider and adjust the values to suit.

Default voltage levels are based on 12v Lead Acid. Divide these by 2 for 6v Lead Acid. Multiply by 2 for 24v Lead Acid. Etc.

Hopefully it all makes enough sense to be usable and adaptable for anyone and any battery.

I plan to add in automatic calculations for different voltage levels and output to LCD display. I can also adjust it for any battery type, please request your specific battery type should it not be covered.

United Kingdom
#17  

Updated code to suit 2013.07.22 release of ARC with the syntax change. Currently untested - will check and adjust (if required) later

2S LiPo Version


# Read voltage level of 2S LiPo battery and report to software.
# Set variables
# Change $vundervoltage to the under voltage of your specific battery (leave at 3v if unsure)
# Change $vcritical to your lowest voltage you wish for the battery to get before human intervention
# Change $vmin to low level alert value
# Change $vmax to battery full charge
# Change $multiplyer if using voltage divider
# Factor is 5/255 for adc value conversion to volts
$vundervoltage = 3
$vcritical = 3.5
$vmin = 3.7
$vmax = 4.5
$multiplier = 2
$factor = 0.019607843

:ReadCells
# Get ADC values
$vc1 = GetADC(ADC0)
$vc2 = GetADC(ADC1)

# Convert values to voltage
$cell2 = $vc1 * $factor
$cell1 = $vc2 * $factor * $multiplier
$cell1 = $cell1 - $cell2
$batteryv = $cell1 + $cell2

# Check for errors on circuit
IF ($cell1 > $vmax or $cell2 > $vmax)
  Print("Battery Monitor Error")
  Print("Check Monitor Circuits")
  
  # Check for errors on battery connection
ELSEIF ($cell1 <= 0 or $cell2 <= 0)
  Print ("Battery Connection Error")
  Print("Check Battery Connection")

  # Check for under voltage
ELSEIF ($cell1 <= $vundervoltage or $cell2 <= $vundervoltage)
  Print ("Battery Under Voltage")
  Print("Check Or Replace Battery")

  # Check if at critical levels
  # Cell 1
ELSEIF ($cell1 <= $vcritical)
  # Do sometihing if critical
  Print("Cell 1 Critical")
  # Shut down all power, switch to back up battery alarm?
  
  # Cell 2
ELSEIF ($cell2 <= $vcritical)
  # Do sometihing if critical
  Print("Cell 2 Critical")
  # Shut down all power, switch to back up battery alarm?
  
  # Check if below recommended levels
  # Cell 1
ELSEIF ($cell1 < $vmin)
  # Do sometihing if voltage low
  Print("Cell 1 Low")
  
  # Cell 2
ELSEIF ($cell2 < $vmin)
  # Do sometihing if voltage low
  Print("Cell 2 Low")

ELSE 
  # Output voltages
  $cell1round = Round($cell1,2)
  $cell2round = Round($cell2,2)
  $totalround = Round($batteryv,2)
  Print("C1 " + $cell1round + "V")
  Print("C2 " + $cell2round + "V")
  Print("To " + $totalround + "V")
ENDIF 
# Wait 5 seconds
Sleep(5000)

# Go back to the start
Goto(ReadCells)

SLA Version


# Read voltage level of a single battery pack and report to software.
# Adapted from LiPo monitor circuit.
# Assumed monitor circuit connected to ADC0
# Set variables
# Default values set for 12v Lead Acid. For 6v divide by 2
# Change $vundervoltage to the under voltage of your specific battery if required
# Change $vcritical to your lowest voltage you wish for the battery to get before human intervention
# Change $vmin to low level alert value
# Change $vmax to battery full charge
# Change $multiplyer if using voltage divider
# Factor is 5/255 for adc value conversion to volts
$vundervoltage = 10.50
$vcritical = 11.31
$vmin = 11.58
$vmax = 12.70
$multiplier = 4
$factor = 0.019607843

:ReadCells
# Get ADC values
$vc1 = GetADC(ADC0)

# Convert values to voltage to 2 decimal places
$batterylevel = $vc1 * $factor
$batterylevel = $batterylevel * $multiplier
$batterylevel = Round($batterylevel,2)

# Check for errors on circuit
IF ($batterylevel > $vmax)
  Print("Battery Monitor Error")
  Print("Check Monitor Circuits")
  
  # Check for errors on battery connection
ELSEIF ($batterylevel <= 0)
  Print ("Battery Connection Error")
  Print ("Check Battery Connection")

  # Check for under voltage
ELSEIF ($batterylevel <= $vundervoltage)
  Print ("Battery Under Voltage")
  Print("Check Or Replace Battery")

  # Check if at critical levels
ELSEIF ($batterylevel <= $vcritical)
  # Do sometihing if critical
  Print("Battery Critical")
  # Shut down all power, switch to back up battery alarm?
  
  # Check if below recommended levels
ELSEIF ($batterylevel < $vmin)
  # Do something if voltage low
  Print("Battery Level Low")

ELSE 
  # Output voltages
  Print($batterylevel + "V")
  # Output to LCD display here (if required)
ENDIF 
# Wait 5 seconds
Sleep(5000)

# Go back to the start
Goto(ReadCells)

If anyone tries any of these please report any errors and I shall correct to suit.

#18  

Thanks Rich for the update on this!

Can't reply if it works or not as I haven't built the circuit yet but it is on my to-do list.

United Kingdom
#19  

Updated to fix the errors that remained.

Also now on the cloud, both scripts in one project. Download Here