How would I efficiently measure multiple cell voltages of my own supply?

Go To Last Post
23 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm building a custom BMS (long story - it is necessary - I need to bypass protection circuits to prevent cutout at unsafe moments).

 

I've got an 8s battery.  This battery powers my MCU through a voltage regulator.  I need to measure the individual voltages of each cell in the battery.

 

I had the idea to use a pair of 16 channel analog multiplexers to connect each cell, one-at-a-time, to my ADC.

 

That idea is unraveling given that my MCU is permanently connected to one end (gnd).

 

I next had the idea to use a voltage controlled oscillator and opto-isolator... but that too is unraveling (the MUX and the VCO still both need to be powered from that same battery).

 

Can anyone suggest the best way to solve this interesting dilemma ?

 

A bit more info - my goal is for the BMS to stay permanently connected - so I'm planning an ultra-low-current regulator and MCU deep sleep.  I do want to "wake up" periodically (e.g. once per day) to do measurements, and sound alarms when cells near empty (many months of non-use are likely, maybe a whole year on occasion).  During use and charging, I'll be monitoring both charge and voltage, to report SOC and SOH (I plan to support LiFePO4 - so voltage alone is no use for capacity-remaining reports).

cndgavruser

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Oh there are some fun devices out there for this sort of application. Here are some part numbers and app notes that may be helpful.

 

Texas Instruments:

bq76PL455A-Q1, EMB1432Q, tidr709.

 

Linear Tech (now Analog Devices):

LTC3305, LTC6804-1 -2, LTC33001, CN0253.

 

Sorry they are not links. Just file names from my local machine.

 

Cheers,

Steve

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Maxim have some interesting devices as well. They refer to them as an AFE (analog front end).

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Before diving into a custom development, have you looked at how standard BMS do it? They must all do this ...

 

As the others said, there are plenty of chips on the market to do this kind of thing. Even if you won't be using one of those chips, it'd be worth studying their documentation & application info for tips & tricks ...

 

 

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. Jan 31, 2020 - 10:36 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

8 cells only gives you around 24VDC - that's manageable with common silicon. I think one Maxim device can cope with up to 72VDC which is where you happily pay the money.

 

Our good friends at Microchip have a device called a PAC1934 which is only 4 channel, but it is good for up to 32 volts, so you'll need two. It talks via I2C so it is easy to interface and you can choose the interface voltage up to 5V. The price isn't too horrific - just a couple of USD in small quantities. Compared to the cost of the batteries it is cheap. These devices have their own adc and are good for 1mV resolution.

 

 

I wrote a driver for the Tasmota project recently to support the PAC1932/3/4 devices so you can have a cheap little WiFi based node that outputs your voltages etc with a webpage and MQTT.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks guys!!  I've done a heap of AFE reading now - what I cannot find are any devices "ready to experiment with" - they're all surface-mount chips, and ebay/aliexpress/google don't show any boards with these on that I can grab to play with :-(

 

I did read a suggestion of using an atmega328p for each cell; these can run from just 1.8v up (the cell drives the MCU), can sleep on nanoamps, can sortof measure voltage (internal bug, so need an external cap for that to work).

 

I would need a creative way for them to communicate 2-ways.

 

On that idea... thinking about each adjacent atmega . the "left" one's VCC will be connected to the "right" one's GND - I wonder if they could safely talk to each other by connecting digital pins?  Keeping in mind that a pair of fully charged cells (4.2v each) would be involved, and the entire string is 33.6v - so messing up the timing on connecting those will clearly fry things.

 

Can anyone recommend a service where I tell them "Hey, I want to experiment with a LTC6811 - can you design, build, and populate a breakout board for me"? and receive back something that's be carefully thought out (i.e. all external recommended parts included, sensible connectors chosen, etc), and built ?

cndgavruser

Last Edited: Fri. Jan 31, 2020 - 12:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't the manufacturers have demo / evaluation boards?

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The LTC6811 is SSOP - piece of piss to solder.

 

Can anyone recommend a service where I tell them "Hey, I want to experiment with a LTC6811 - can you design, build, and populate a breakout board for me"? and receive back something that's be carefully thought out (i.e. all external recommended parts included, sensible connectors chosen, etc), and built ?

 

You can have anything you want - for a price.  Unfortunately, something like  "carefully thought out (i.e. all external recommended parts included, sensible connectors chosen, etc), and built ?" is very application dependant. As Andy suggests, you can get an eval board, but these are usually not intended to be used as actual solutions, so 'sensible connectors' probably aren't on the list.......

 

If you are really clear about your requirements, then you could visit your local hackerspace and hopefully find someone who would be happy to assist in designing a little pcb and assembling something for you for probably beer money. If you are not clear about your requirements, then avoid that solution.

Last Edited: Fri. Jan 31, 2020 - 01:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

I use Tiny85s on each cell that sleep until reset, then send Vcc via RC-5 infrared pulses and sleep again. The max 4 volt offset between each Tiny is small enough to capacitor couple a pulse to the reset of the next one up. So resetting the first one gives sequential readout of all 12 cells in about a second. If ambient light is a problem you could instead transformer couple each one to a common bus.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dak664 wrote:
If ambient light is a problem you could instead transformer couple each one to a common bus.

I would think an optocoupler would work here for each unit.

Jim

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
I would think an optocoupler would work

Indeed - never head of optocouplers having trouble with ambient light!

 

Nowadays, there are direct "digital" isolators available from the likes of Maxim, Analog Devices - including some specifically for I2C, SPI, etc ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


cndgavruser wrote:
I've got an 8s battery. ...

I had the idea to use a pair of 16 channel analog multiplexers to connect each cell, one-at-a-time, to my ADC.

A 4S battery into an XMEGA's analog mux :

AN2535 AVR1300: Using the XMEGA ADC

...

Lowering the resistance would cause more leakage current and this can again be solved by adding switching FET to enable and disable the analogue source. An example of this can be seen in the figure below.

...

via ATxmega8E5 - 8-bit PIC Microcontrollers

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Fri. Jan 31, 2020 - 05:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe I need some more sleep, or caffeine, or just to hit the books again.

 

But why, in the schematic above, (Post #13), are the switching Fets placed in the middle of the resistor divider instead of attached to the ground rail?

Is this merely to eliminate the input current leakage of the ADCs, or is there another reason?

 

Edit:  I guess the filter caps will also have a tiny leakage current as well.

So that becomes a trade off on the energy needed to charge up the cap for each reading, vs its baseline leakage.

 

JC

 

 

 

 

Last Edited: Fri. Jan 31, 2020 - 06:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
Is this merely to eliminate the input current leakage of the ADCs, or is there another reason?
XMEGA AU don't leak much though XMEGA E leak more.

Most MOSFET have significant leakage though a relative few greatly reduce the leakage.

A JFET is typical for analog switching.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For easier prototyping, this link may be handy...

 

SiliconChip Mag, March 2016, Battery Pack Cell Balancer

 

You'll only get "preview" level access but you should be able to purchase the full article.

You may even be able to purchase a PCB and or kit of parts from the SC web store.

 

Cheers

Steve

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I vote to isolate and merge at the output (digital) side rather than the analog side. 

 

Opto Isolators should be fine though you would want to insure that idle state has the input LED off. There are also capacitive and inductive (transformer) coupled isolators that are typically good for higher bit rates. You MIGHT want a separate isolated "sync bus" between them. Or, use signals from other modules for synchronizing and avoidance of bus collisions.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But why, in the schematic above, (Post #13), are the switching Fets placed in the middle of the resistor divider instead of attached to the ground rail?

That is the best position so the batteries can disconnect from everything....since the ADC levels are scaled to deliver 1V max, if you drive the gate at 5V (or possibly even at 3.3...maybe)...you still get 5-1= 4V Vgs to fully turn on the fet, even if it is located in  the middle of the road.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

....since the ADC levels are scaled to deliver 1V max

 

I guess I'm not understanding this circuit accurately.

 

If the Gate is off, and there is no Drain to Source current, then the Source is sitting a 0 V.

The Drain, however, is sitting at the battery stack voltage, as the resistive divider that holds the ADC voltage to <= 1 V has been disconnected.

So a 3.3 V logic level signal to drive the Gate might not be sufficient, (I think).

 

If so, then the "Fet_Control" signal would likely be derived from a PFet which is driven by the uC logic level signal and which itself drives the NFet.

 

I would have to lookup / study JFet gate drive requirements to see how one could drive them from a low voltage micro, if they were employed in this task.

 

JC

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

you got it - the gate voltage would have to be high enough above the adc input voltage in order to turn the mosfet on sufficiently. Thus, if you used logic levels from the micro to drive the gate, with something like a BSS123 you'd sacrifice around 1.4V of your adc input range using a 3V3 reference. With a 1.1V reference there shouldn't be a problem.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the Fet is full ON, the the resistor dividers deliver a max of 1V to the ADC, for the given Batt Voltages.

 

This 1V works against turning the fet on, by reducing its Vgs.  However, with a 5V gate signal, even a 1V drop allows a 4V Vgs, which is plenty to guarantee the fet is almost full on.  So the tug of war goes in the AVR's favor.  That might not be the case if the fet chosen were a higher threshold type (remember old fets that needed 10V to be near full-on).   The Rds of the fet is so low compared to the dividers, that even half on Rds is plenty good enough to not affect the divide ratio.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nice, and clever.  Did you find a way to get the Tiny85s to accurately read their own VCC?  As far as I know, the internal resistor to the 1.1v reference is wrong - 1M when it should have been 10k - so it takes as long as 500ms to get an accurate reading.

What kind of voltage reading accuracy are you getting?

 

The reset cap is clever.

 

Expanding on that idea - can you think of a way for each Tiny85 to talk (data) to its neighbor?  It would be nice if all the readings could be passed along the string, so only the last Tiny85 needs to talk through an opto isolator to an MCU!

 

 

p.s. 1m hardware bug details: "ATmega328P – measuring its own supply voltage III" https://www.sciencetronics.com/g...

cndgavruser

Last Edited: Sat. Feb 1, 2020 - 04:03 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not aware of any issues measuring Vcc in the Tiny85. This gave consistent three digit precision in either mode:

//Toss the first conversion, voltage probably not stable yet
  ADCSRA|=1<<ADSC;                 //Start conversion
  while (ADCSRA&(1<<ADSC));        //Wait till done

#if ADCINTERRUPTS                  //CPU clock stops for cleaner conversion
  set_sleep_mode(SLEEP_MODE_ADC);
  sei();
  sleep_mode();
#else                              //Keeps CPU running
  ADCSRA|=1<<ADSC;                 //Start conversion on BATIN pin
  while (ADCSRA&(1<<ADSC));        //Wait till done
#endif
  Vbat=1131632UL/ADC;              //Get approximate battery voltage - 3.49
  
  ...
  
 /* -------------------------------------------------------------------------
 * ADC interrupt routine, just wakes the CPU
 */
ISR(ADC_vect) {}

 

The first start after programming using known Vcc can write a calibration factor to EEPROM. If Vcc is high enough the Tiny can stay awake and determine whether charging or discharging, and if charging can add proportionate load to clamp the cell voltage to the desired limit. That avoids the short potential of all those sense wires going to a battery balancer.

 

The battery packs were for an electric bicycle and I had a 20 amp polyfuse in the middle to limit damage from the occasional short. Tripping that would raise the potential between two Tinys to 36 volts, so any direct signal connections between them could cause damage.