Jump to content

Cheap LiFePO4 BMS?


jetzi

Featured Posts

Ah, but that's cheating!! 🤣

 

 

I wanted the flexibility of a unknown number of cells to monitor, my solution can monitor up to 256 cells and provide about 1amp balance current for each.

 

 

 

Link to comment
Share on other sites

4 minutes ago, stuart said:

Ah, but that's cheating!! 🤣

 

 

I wanted the flexibility of a unknown number of cells to monitor, my solution can monitor up to 256 cells and provide about 1amp balance current for each.

 

 

 

Definitely cheating. But also sensible in my opinion! I try to avoid wheel-inventing, on the basis that the team who designed that sort of chip are much cleverer than me!

My chip can be cascaded x 8 to measure up to 48 cells (from one SPI interface) which seems plenty to me! 48x3.2v = 150v which is into ouch territory.

Link to comment
Share on other sites

I agree custom chips are the best way for that. I used the INA228 in my current shunt/monitor and that been super accurate (20bit ADC)

 

When monitoring cells, a lot of people have multiple parallel banks, so that's what the 256 monitors allows for, like 5x16 etc.

 

Link to comment
Share on other sites

14 hours ago, nicknorman said:

Well if this is a show and tell, I selected a purpose built IC that measures the voltages of up to 6 cells, with built in multiplexers and 12 bit AtoD spanned over 1 to 5 volts giving a resolution of 1mV for all cells, and an absolute accuracy of about 2mV over a reasonable temperature range. Also has level converters to drive balancing mosfets. Tell it to convert all cells, go away for 1mS or so, come back and read the answers over SPI. Simples! Also has analogue inputs for thermistors to measure cell temperatures, but I prefer the 1-wire digital temperature sensors. Digital is so much easier!

That sounds similar to my first (failed) attempt at hardware, and would definitely have been better if I'd been able to make it work. My point is that the simple-minded solution with Arduino analog inputs works well enough and is simple to do, as long as you understand a few gotchas.

 

MP 

Link to comment
Share on other sites

14 hours ago, stuart said:

I agree custom chips are the best way for that. I used the INA228 in my current shunt/monitor and that been super accurate (20bit ADC)

 

When monitoring cells, a lot of people have multiple parallel banks, so that's what the 256 monitors allows for, like 5x16 etc.

 

That INA228 looks pretty good. I could have used it to measure alternator current in my project since it supports a high-side shunt. Never mind, next time… As it is I can derive alternator current by looking at the field current and alternator rpm. It would certainly be a good starting point for an Ah-counting battery monitor.

Edited by nicknorman
Link to comment
Share on other sites

On 16/11/2021 at 09:56, MoominPapa said:

as long as you understand a few gotchas

If any gotchas do spring to mind I'd appreciate any forewarning!

 

My arduino is driving the one relay no problem, so I'm going to expand it out to include the other 4 relays next week when I'm back at the boat.

 

I still need to add some useful buzzer feedback, temperature sensors, battery warmer, and I want to add SD card logging as well. So actually yeah, still a long way to go. But if I can get it at least operating the tycos based on voltage ASAP then I can sleep a bit easier

 

Link to comment
Share on other sites

38 minutes ago, jetzi said:

If any gotchas do spring to mind I'd appreciate any forewarning!

 

My arduino is driving the one relay no problem, so I'm going to expand it out to include the other 4 relays next week when I'm back at the boat.

 

I still need to add some useful buzzer feedback, temperature sensors, battery warmer, and I want to add SD card logging as well. So actually yeah, still a long way to go. But if I can get it at least operating the tycos based on voltage ASAP then I can sleep a bit easier

 

Did you sort out the cell voltage glitching issue?

Link to comment
Share on other sites

33 minutes ago, jetzi said:

If any gotchas do spring to mind I'd appreciate any forewarning!

 

My arduino is driving the one relay no problem, so I'm going to expand it out to include the other 4 relays next week when I'm back at the boat.

 

I still need to add some useful buzzer feedback, temperature sensors, battery warmer, and I want to add SD card logging as well. So actually yeah, still a long way to go. But if I can get it at least operating the tycos based on voltage ASAP then I can sleep a bit easier

 

For oversampling, I used modified moving average, which is really easy to calculate. The article bellow has the details.

 

https://www.baldengineer.com/measure-pwm-current.html

 

I tend to make n a power of two to optimise the code.

 

For logging I used an 8 pin i2c EEPROM which  is arguably easier to wire up than an SD card, and certainly easier to read and write using an Ardunino. You do have to arrange your own wear-levelling though (don't have a single root block that gets written on every logging event and will wear out first.) The Ardunio MCU has 1k of EEPROM built in which is sufficient for quite a bit of logging if you optimise record size and logging frequency.

 

 

MP.

 

Link to comment
Share on other sites

7 minutes ago, MoominPapa said:

For oversampling, I used modified moving average, which is really easy to calculate. The article bellow has the details.

 

https://www.baldengineer.com/measure-pwm-current.html

 

I tend to make n a power of two to optimise the code.

 

For logging I used an 8 pin i2c EEPROM which  is arguably easier to wire up than an SD card, and certainly easier to read and write using an Ardunino. You do have to arrange your own wear-levelling though (don't have a single root block that gets written on every logging event and will wear out first.) The Ardunio MCU has 1k of EEPROM built in which is sufficient for quite a bit of logging if you optimise record size and logging frequency.

MP.

 

Presumably since the thing is going to be powered on permanently and the loss of some logging data wouldn’t be catastrophic, logging data could be accumulated and kept in RAM for a while until writing a complete block to EEPROM.

 

Of course the disadvantage of eeprom is that you have to develop means of getting the log data out again, which is where an SD card is so much easier, but a disk file system for an Arduino is surely going to take up a lot of programme ROM!

Link to comment
Share on other sites

47 minutes ago, nicknorman said:

Presumably since the thing is going to be powered on permanently and the loss of some logging data wouldn’t be catastrophic, logging data could be accumulated and kept in RAM for a while until writing a complete block to EEPROM.

The main problem to solve is finding where the log data starts and ends. The obvious solution is to keep that in a dedicated location in the EEPROM, but then that location gets written every time the log is updated, while all the other blocks are written every n updates, where n is the size of the EEPROM in log entries. I have designed a self-describing log format in the past, where you just write the new block at each log, and a scan through the whole thing at startup  is enough to  tell you where the valid data starts and ends. The current code uses a two-step approach. The metadata is stored in the 1k on-chip EEPROM and the logs in the i2c EEPROM. On chip EEPROM has a single location which points to the actual metatdata . The metadata includes an update count and when it has been updated 65356 times, the initial pointer is updated and the metadata moves along to new unworn locations in EEPROM. That extends the theoretical lifetime from months to decades.

47 minutes ago, nicknorman said:

 

Of course the disadvantage of eeprom is that you have to develop means of getting the log data out again, which is where an SD card is so much easier, but a disk file system for an Arduino is surely going to take up a lot of programme ROM!

 

Getting the data out over the serial line is easier and less code than writing a filesystem on an SdCard, I think.

 

MP.

Link to comment
Share on other sites

1 hour ago, nicknorman said:

Did you sort out the cell voltage glitching issue?

Oh yes, it was just a wibbly connection, but it can have quite serious consequences tripping various relays, so I really do need to make a more productionised build before I can let it loose on my battery. It was just weird that it would happen without anything touching it.

 

1 hour ago, MoominPapa said:

For oversampling, I used modified moving average, which is really easy to calculate. The article bellow has the details.

 

https://www.baldengineer.com/measure-pwm-current.html

 

I tend to make n a power of two to optimise the code.

Yeah I think adding a moving average is a good idea. How many samples / seconds do you calculate the average over?

 

1 hour ago, nicknorman said:

Presumably since the thing is going to be powered on permanently and the loss of some logging data wouldn’t be catastrophic, logging data could be accumulated and kept in RAM for a while until writing a complete block to EEPROM.

Why would you want to log to EEPROM first, to reduce writes to the SD card / whatever other permanent storage? Would it be to save power, to save on wear on the memory, or something else?

 

7 minutes ago, MoominPapa said:

Getting the data out over the serial line is easier and less code than writing a filesystem on an SdCard, I think.

Where does it go though... Have you got a server running permanently that receives this information? I was thinking of either whipping out the SD card periodically to check out the data or to just write it over in a cycle so that I can diagnose issues of they occur. But a better option would be if I could write to permanent storage, but then I have to either connect the BMS to the internet or I have to have a local data store permanently running.

Link to comment
Share on other sites

31 minutes ago, jetzi said:

Yeah I think adding a moving average is a good idea. How many samples / seconds do you calculate the average over?

Check the link. Modified moving average doesn't require storing a fixed number of samples and the influence of old samples falls out of the result automatically at a rate determined by the n parameter and the number as samples per second being fed into the calculation. I sample as fast as possible and pick n so that it takes a second or so to slew to a new reading. Pick n as a power of two, as the algorithm divides by it, and be aware that the accumulator's maximum value is the maximum sample value multiplied by n, so you might need to worry about overflow.

 

31 minutes ago, jetzi said:

 

Where does it go though... Have you got a server running permanently that receives this information? I was thinking of either whipping out the SD card periodically to check out the data or to just write it over in a cycle so that I can diagnose issues of they occur. But a better option would be if I could write to permanent storage, but then I have to either connect the BMS to the internet or I have to have a local data store permanently running.

 

No server running permanently,  the information ends up on my laptop. Each record has a 32-bit serial number, and the EEPROM in the Arduino can store the last 8192 records in EEPROM. The program on the laptop knows the serial number of the last record already in the file on disk, asks the Arduino what the serial number of the most recent record is, then requests all the records between those two serials and adds them to the end of the file. I log a record every five minutes, so as long as I plug the laptop in once a month, I have a complete copy of the log.

 

For the first couple of years, I just plugged the USB from the Arduino into the laptop. Now I have a serial line from the Arduino connected to a serial port on my internet router, so the laptop can talk to the Arduino via the internet. The router still doesn't store the data, it's just a way for the laptop to talk the same protocol as it does via USB, but remotely.

 

MP.

Link to comment
Share on other sites

6 hours ago, jetzi said:

 

Why would you want to log to EEPROM first, to reduce writes to the SD card / whatever other permanent storage? Would it be to save power, to save on wear on the memory, or something else?

 


No it was an “instead of” thing. Using an EEPROM instead of an SD card.

 

Not sure how much programme rom you have on your particular device, but I would check to see how much space a disk file system is going to take before committing to that route.

Link to comment
Share on other sites

11 minutes ago, stuart said:

 

Yep, thats what I did - RS485/MODBUS based Current Monitor, with electrically isolated data connection.

 

https://github.com/stuartpittaway/diyBMS-CurrentShunt

Unfortunately I don’t have Kicad and there’s no image of the schematic, but I get the general idea. Good to see someone else using JLCPCB!

Link to comment
Share on other sites

1 minute ago, nicknorman said:

Unfortunately I don’t have Kicad and there’s no image of the schematic, but I get the general idea. Good to see someone else using JLCPCB!

 

Heres the PDF of the schematic - https://github.com/stuartpittaway/diyBMS-CurrentShunt/blob/master/CurrentShuntCircuit/export/Schematic.pdf

 

I've spent thousands with JLCPCB this year already !

@nicknorman forgot to ask, what was the cell monitoring chip you used?  I'd be interested to use that in my next designs.

Link to comment
Share on other sites

29 minutes ago, stuart said:

 

Heres the PDF of the schematic - https://github.com/stuartpittaway/diyBMS-CurrentShunt/blob/master/CurrentShuntCircuit/export/Schematic.pdf

 

I've spent thousands with JLCPCB this year already !

@nicknorman forgot to ask, what was the cell monitoring chip you used?  I'd be interested to use that in my next designs.

Thanks. The circuitry for the INA228 is very straightforward.

 

I used Analog Devices AD7280A. It’s becoming obsolete but I think you can still get them from Farnell. Biggest problem with these and equivalent replacements is the package footprint. LQFP is not great for hobbyists! (0.5mm lead pitch). A struggle, but I managed it.

Link to comment
Share on other sites

39 minutes ago, nicknorman said:

Analog Devices AD7280A

 

Thanks for that.    Are you only using 4x cells for a 12V style setup?

 

 

 

40 minutes ago, nicknorman said:

LQFP is not great for hobbyists! (0.5mm lead pitch)

 

As luck would have it, I'm also part of a project for a pick and place machine 🙂  https://indexmachines.io/

Link to comment
Share on other sites

3 minutes ago, stuart said:

 

Thanks for that.    Are you only using 4x cells for a 12V style setup?

 


Yes. The daisy chaining ability of the chip is therefore wasted. It added complexity in understanding the data sheet but not in the physical implementation because the daisy chain connections are just left unused. I selected it not because it was the best fit but just because it was available in small quantities from RS/Farnell. Happy to share schematic etc if you are interested. I use RS DesignSpark but could export a pdf.

Edited by nicknorman
Link to comment
Share on other sites

10 minutes ago, stuart said:

 

Thanks for that.    Are you only using 4x cells for a 12V style setup?

 

As luck would have it, I'm also part of a project for a pick and place machine 🙂  https://indexmachines.io/

 

If you think 0.5mm pitch LQFP are bad, try dealing with a ~1000 pin BGA... 😉

  • Greenie 1
Link to comment
Share on other sites

15 minutes ago, stuart said:

Thanks for the info, looks like a similar replacement device for the AD7280A is the LTC6803-3.

 

Just double the cost and out of stock everywhere!

Yes, along with so many semiconductors (the out of stock bit I mean). The global chip shortage is biting!

 

The AD7280A had obsolescence on the horizon when I first selected it in 2019. Of course being for a one-off hobby purpose this didn’t matter. I have a stash of a few spares for future-proofing!

Edited by nicknorman
Link to comment
Share on other sites

17 minutes ago, stuart said:

Thanks for the info, looks like a similar replacement device for the AD7280A is the LTC6803-3.

 

Just double the cost and out of stock everywhere!

That's the problem with a lot of electronic components right now. We're seeing components that used to have a leadtime of 2-3 months now quoting a year or more, which leads to some interesting problems when you want to actually make and sell things... 😞

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.