Espritmodel.com Telemetry Radio
Reply
Thread Tools
Old Nov 09, 2013, 12:10 AM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
Discussion
Arduino Lipo Cell Monitor

Hey everyone,

Wondering if there is any interest in me documenting a simple 4s LiPo Cell Monitor on the Arduino platform while I am making one?

I have searched for a while and could not find anything quickly that would show me what was required so if there is interest, I will document this here so that others can refer to this and create their own LiPo monitoring things.

Here is the basic schematic that I have come up with and values of resistors to create appropriate voltage dividers for the Arduino.

Excuse the poor layout skills in Fritzing - first time using this rather than hand scrawl attachments
deswong is offline Find More Posts by deswong
Last edited by deswong; Nov 11, 2013 at 01:42 AM. Reason: Uploaded wrong image.
Reply With Quote
Sign up now
to remove ads between posts
Old Nov 09, 2013, 03:14 AM
Stuart
srnet's Avatar
UK, Cardiff
Joined Dec 2008
3,139 Posts
I am no expert on ATMEGAs, but the circuit just does not look right.

You have the A0 pin connected to 14.4V, its through a current limit resistor, but the input clamp diodes normally found on Micros will limit the A0 pin voltage to around 5.3V.
srnet is offline Find More Posts by srnet
Reply With Quote
Old Nov 09, 2013, 07:05 AM
Registered User
Joined Mar 2006
449 Posts
That MCU also only has a 10 bit single ended ADC. You might need something a little better depending on the resolution you're looking for.
spog is online now Find More Posts by spog
Reply With Quote
Old Nov 09, 2013, 06:15 PM
Dave the Rave
dmccormick001's Avatar
Joined Jun 2007
869 Posts
If you're going to use this as an "on-board" monitor, you'll need to use a smaller MCU. The 28 pins is a bit of overkill, and will make it much bigger and heavier than it really needs to be, don't you think?
dmccormick001 is offline Find More Posts by dmccormick001
Reply With Quote
Old Nov 09, 2013, 11:06 PM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
I've put this together as a basic proof of concept - so far the testing has been promising.

I don't need terribly great accuracy with this one - I am within 0.05v of the cell voltage (only to 2 decimal places) and this is good enough for what I want it to do - determine voltages and low cutoff.

I am finding though because of the accuracy it is jumping a fair bit - so I need to either average out the values or mode the values to get a stable number.

This is actually going to be built onto a Leonardo and have a lot of other functions for a robot I am working on - I wanted to build it on a sacrificial Nano board first, to see that it does work. The other thing I will add to this is a poor person's coulomb counter - I know there are chips etc that do this, but all I want is an approximate usage of current so I will simply add a current monitor to this and poll this intermittently to get usage stats.
deswong is offline Find More Posts by deswong
Reply With Quote
Old Nov 09, 2013, 11:10 PM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
Quote:
Originally Posted by srnet View Post
I am no expert on ATMEGAs, but the circuit just does not look right.

You have the A0 pin connected to 14.4V, its through a current limit resistor, but the input clamp diodes normally found on Micros will limit the A0 pin voltage to around 5.3V.
With the A0 pin, the input to that ends up being at 4.77v with 18v input, due to the voltage divider with the resistors.

I know I am not using the full range of the ADC as I could, I can use op-amps to get a more accurate range and so forth, but I am just after something simple at this stage which can give reasonable single decimal point accuracy for cutoff and monitoring.

I may re-visit this and make it more accurate in the future depending if I need this level of accuracy, but presently I feel that this should be ok for what I am looking for.
deswong is offline Find More Posts by deswong
Reply With Quote
Old Nov 10, 2013, 01:30 AM
Stuart
srnet's Avatar
UK, Cardiff
Joined Dec 2008
3,139 Posts
Quote:
Originally Posted by deswong View Post
With the A0 pin, the input to that ends up being at 4.77v with 18v input, due to the voltage divider with the resistors
You could form a voltage divider, with the 130K and 47K I presume you mean, but that is not how you have shown the resistors are connected on the circuit diagram. They must be wired some other way.
srnet is offline Find More Posts by srnet
Reply With Quote
Old Nov 10, 2013, 01:55 AM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
After a bit more tinkering with code, this is pretty much final of what I wanted to achieve from this.

I will alter the code more later, but this will be specific to the platform I am interfacing with.

Code:
#define battPin0 A3    // select the input pins for the batteries
#define battPin1 A2
#define battPin2 A1
#define battPin3 A0

float battWeighting = 0.1; // define a weighting to apply to our exponential moving average calculation for battery 

int abattValue0 = 0; // variable to store average value (exponential moving average) calculation
int abattValue1 = 0;
int abattValue2 = 0;
int abattValue3 = 0;

float Cell1 = 0.00; // variable to store actual cell voltages
float Cell2 = 0.00;
float Cell3 = 0.00;
float Cell4 = 0.00;

float adcVolt = 0.0048680351906158 ; // one point on the ADC equals this many volts

void setup() {
  Serial.begin(115200);
  
  // Read the battery voltage values and set up the averaging
  // require 50 reads to initialise correct ewv.
  for (int i=0; i<50; i++){
    getBattVolts();
  }
}

void loop() {
  // basic get and show voltages
  getBattVolts();
  showBattVolts();
  delay(500);                  
}

void getBattVolts() {
  // read the value from the sensor:
  abattValue0 = (analogRead(battPin0) * battWeighting) + (abattValue0 * (1-battWeighting));
  abattValue1 = (analogRead(battPin1) * battWeighting) + (abattValue1 * (1-battWeighting));
  abattValue2 = (analogRead(battPin2) * battWeighting) + (abattValue2 * (1-battWeighting));
  abattValue3 = (analogRead(battPin3) * battWeighting) + (abattValue3 * (1-battWeighting));
  // convert these values to cell voltages
  Cell1 = (adcVolt * abattValue0 * 1) ;
  Cell2 = (adcVolt * abattValue1 * 1.8298)-Cell1;
  Cell3 = (adcVolt * abattValue2 * 2.6078)-Cell2-Cell1;
  Cell4 = (adcVolt * abattValue3 * 3.7659)-Cell3-Cell2-Cell1;
}

void showBattVolts() {
  Serial.print (Cell1);
  Serial.print ("V. " );
  Serial.print (Cell2);
  Serial.print ("V. ");
  Serial.print (Cell3);
  Serial.print ("V. ");
  Serial.print (Cell4);
  Serial.print ("V. Total = " );
  Serial.println (Cell1+Cell2+Cell3+Cell4);
}
deswong is offline Find More Posts by deswong
Reply With Quote
Old Nov 10, 2013, 02:04 AM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
Quote:
Originally Posted by srnet View Post
You could form a voltage divider, with the 130K and 47K I presume you mean, but that is not how you have shown the resistors are connected on the circuit diagram. They must be wired some other way.
Hmm, I am looking again at this and I do think this is right...

I have built it according to the schematic and it seems to be recording the right values and voltages to the A0 pin and converting it to a real voltage.

I've double checked against an online calculator and got the voltage at 14.4v that would go to A0 as shown.
deswong is offline Find More Posts by deswong
Reply With Quote
Old Nov 10, 2013, 02:09 AM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
I forgot to include the boring output in case someone doesn't quite get what it is outputting.



(one of the cells seems to be recovering after turning off the pc that this is currently attached to lol)
deswong is offline Find More Posts by deswong
Reply With Quote
Old Nov 10, 2013, 03:14 AM
Stuart
srnet's Avatar
UK, Cardiff
Joined Dec 2008
3,139 Posts
Quote:
Originally Posted by deswong View Post
Hmm, I am looking again at this and I do think this is right...
Nope, look again at what you have drawn.

For the voltage divider to work, R5 should be connected between A0 and ground.

You have R5 connected to +14.4V where it does nothing apart from add a small load to the battery.
srnet is offline Find More Posts by srnet
Reply With Quote
Old Nov 10, 2013, 08:50 AM
Dave the Rave
dmccormick001's Avatar
Joined Jun 2007
869 Posts
I think this is more like what you want.....
dmccormick001 is offline Find More Posts by dmccormick001
Reply With Quote
Old Nov 10, 2013, 09:17 AM
Registered User
United Kingdom, Bristol
Joined Aug 2008
1,736 Posts
there both the same...just latter looks better.
And guessing when he hooked up the circuit for real was like second post.
SadSack is online now Find More Posts by SadSack
Reply With Quote
Old Nov 10, 2013, 12:40 PM
Stuart
srnet's Avatar
UK, Cardiff
Joined Dec 2008
3,139 Posts
Quote:
Originally Posted by dmccormick001 View Post
I think this is more like what you want.....
Indeed.

The other point is that using fixed value resistors in this type of circuit can be a very bad idea.

We dont know what tolerance of resistors are being used, but the errors are accumulative as you go from the bottom Lipo to the top because of the way the maths are done.

Even with 1% resistors, the voltage error for the top (4th) Lipo could be close to 0.2V which for Lipo balancing is way too much.
srnet is offline Find More Posts by srnet
Reply With Quote
Old Nov 10, 2013, 12:46 PM
Registered User
Joined Mar 2006
449 Posts
Quote:
Originally Posted by srnet View Post
Indeed.

The other point is that using fixed value resistors in this type of circuit can be a very bad idea.

We dont know what tolerance of resistors are being used, but the errors are accumulative as you go from the bottom Lipo to the top because of the way the maths are done.

Even with 1% resistors, the voltage error for the top (4th) Lipo could be close to 0.2V which for Lipo balancing is way too much.
If you're referring to dmcormick's drawing,I don't think that's correct. You could completely remove all the resistors except the ones on the A0 input and the A0 input voltage wouldn't change.
spog is online now Find More Posts by spog
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Question About programming ESC with arduino Serial Monitor AbdulRahmna Multirotor Talk 0 Jul 25, 2013 09:38 AM
Sold 2 cell lipo monitor jhaymes2006 Aircraft - General - Radio Equipment (FS/W) 0 Jan 21, 2013 09:25 PM
HXT Lipo Monitor 3S & 3S cell lipo checker Mikemynameis Non R/C Items (FS/W) 1 Dec 30, 2012 03:33 PM
Sold (8) BM-6 Cell Voltage Monitor 2-6S Lipo monitors FairlyFaded Aircraft - Electric - Batteries & Chargers (FS/W) 3 Sep 18, 2012 10:05 AM
Inline Connection for Cell Monitor for Lipos stuka Batteries and Chargers 3 May 27, 2004 12:33 PM