Topic: Testing the battery board

I have made a separate post for the testing I'm doing to my board since it seems that I'm hijacking mclien's post which is more about getting togheter the people who whants to buy a battery PCB smile

Anyone who whants to see the first steps of my build, they can see them here:

http://www.kosagi.com/forums/viewtopic.php?pid=17#p17
http://www.kosagi.com/forums/viewtopic.php?pid=98#p98
http://www.kosagi.com/forums/viewtopic.php?pid=121#p121
http://www.kosagi.com/forums/viewtopic.php?pid=137#p137

Once the board was complete, I build an adapter board and I did put standard pins so I can access all the SATA connector signals. I hooked up a Bus Pirate to be able to communicate with the board and it worked!! This was the output:

~Resetting (Ver 11, git version bf392dd930ecb7b83cb639cdde6000560b3e6759)~

ChibiOS/RT Shell
ch> help
Commands: help exit info systime i2c mode dac stats leds gg chg setchem setmanuf 
ch> info
Kernel:       2.6.0
Compiler:     GCC 4.8.4 20140526 (release) [ARM/embedded-4_8-branch revision 211358]
Architecture: ARMv7-M
Core Variant: Cortex-M3
Port Info:    Advanced kernel mode
Platform:     STM32F10x Performance Line Medium Density
Board:        Senoko STM32F1
Build time:   12 2014 - 17:39:46
ch> chg 1000 12600 1000
Setting charger: 1000mA @ 12600mV (input: 1000mA)... Ok
ch> gg setup 3 1000
Setting cell count... Unable to set 3 cells: 0xFFFFFFFF
Setting capacity... Unable to set capacity: 0xFFFFFFFE
ch> stats
Manufacturer:       error 0x80000004
Part name:          error 0x80000004
Firmware ver:       error 0x80000004
State:              error 0x80000004
Time until full:    error 0x80000004
Time until empty:   error 0x80000004
Chemistry:          error 0x80000004
Serial number:      erx80000004
Capacity:           error 0x80000004
Full capacity:      error 0x80000004
Design capacity:    error 0x80000004
Temperature:        error 0x80000004
Cell count:         error 0xFFFFFFFF
Voltage:            error 0x80000004
Current:            error 0x80000004
Charging current:   erx80000004
Charging voltage:   error 0x80000004
Avg current:        error 0x80000004
Cell 1 voltage:     error 0x80000004
Cell 2 voltage:     error 0x80000004
Cell 3 voltage: error 0x80000004
Cell 4 voltage:     error 0x80000004
Alarms:
    TERMINATE CHARGE ALARM
    OVER TEMP ALARM
    TERMINATE DISCHARGE ALARarge state:
    Battery discharging/relaxing
STATUS ERROR CODE: 0x4

So, it's great to be able to use the Battery board shell, but it seems that the STM32 isn't able to talk to the gas gauge. sad

I know this is something that few people besides xobs or bunnie will be able to help with, but in any case it may be interesting to anyone who wants to know how the battery board works...

So, trying to isolate the problem this is what I checked (both charger and battery are connected):

  • P3.3V_UC: 3.3V regulator (U102) wich powers the microcontroller: OK

  • CHG_VREF: 3.3V internal regulator of the charging circuit (U200): OK

  • GG_3.3V: 3.3V internal regulator of the gas gauge (U301): NOT OK! measures 1.000V

  • Removed the LED diodes to be sure they aren't causing a short, all remains the same.

  • GG_2.5V: 2.5V internal regulator of the gas gauge (U301): NOT OK! measures 1.490V

  • PACK (pin 2): 0.02V

  • Vcc (pin 3): 11.03V

  • BAT_PROTECTED: 0.02V

Another thing that I have noticed is that when I type "chg" in the chibios shell, when plugged to the charger it doesn't display any voltage or current:

Charger state: 0mA @ 0mV (input: 0mA)

But, when I do the same plugged to the battery while pressing the "prime" button it displays a current and voltage, but it changes a lot each time and it's wrong:

Charger state: 0mA @ 6780mV (input: 16384mA)
Charger state: 8192mA @ 18996mV (input: 4096mA)
Charger state: 0mA @ 0mV (input: 0mA)
Charger state: 2048mA @ 0mV (input: 0mA)
Charger state: 2048mA @ 0mV (input: 0mA)
Charger state: 16386mA @ 10285mV (input: 4096mA)
Charger state: 16386mA @ 10285mV (input: 4096mA)
Charger state: 16386mA @ 10285mV (input: 4096mA)
Charger state: 2048mA @ 20480mV (input: 49664mA)
Charger state: 0mA @ 6777mV (input: 16384mA)
Charger state: 2048mA @ 6777mV (input: 16384mA)                                               
Charger state: 2048mA @ 103mV (input: 0mA)

It would be great if xobs or bunnie could point me in the right direction big_smile

Anyway, I know this can be an obscure matter and difficult to diagnose so I will keep searching for any mistake I could have made while populating the PCB and I will update when I find the problem smile

And just because such a long post would be too boring without a picture, here is my current setup:
http://i.imgur.com/MvFNPRA.jpg

Re: Testing the battery board

There is a bootstrapping problem with the gas gauge.  There are a few ways around it, but the easiest is to manually turn on the charger, which will bring the gas gauge out of reset.  Run:

ch> chg 1000 12600 3000

Then give it a second or two, and turn the charger off:

ch> chg -

You should see life when you run "stats".

Once you get it running, you'll need to program the gas gauge with charge voltage and settings for a three-cell battery.  The numbers are still a bit off, and it abuses the battery a bit, so be warned the battery will degrade quicker than normal.  It's a thing we're still working on, and part of why the laptop version is coming out later.  Anyway, program the capacity and the cell count:

ch> gg capacity 3 3000
ch> gg cells 3

The code will eventually flip the charger on momentarily when it boots, in order to kick the gas gauge into action.  But that'll come after we completely, 100% refactor the code.  We've got a branch going where we're moving to ChibiOS 3.0.

Oh, fun side fact: We have Senoko driving WS2812s.

Re: Testing the battery board

Thanks! I will try it as soon as I get home smile

It would be great to have a WS2812 as a charging indicator big_smile

Once I get the battery board running, I will try to do a power supply (and release the design files as OSHW). I have some experience with power integrations designs, so it could be pretty much straight out of their app notes...

4 (edited by ballanux 2014-07-16 03:47:53)

Re: Testing the battery board

It didn't work, I think that for some reason the charger isn't turning on...

Which firmware do I have to use? I used your repository in https://github.com/xobs/senoko-chibios the code is from 5 months ago. The commands "capacity" and "cells" for the gg are not implemented in the code I have, instead there is a command "setup" that sets-up both things.

Anyway I think that the firmware is not the problem, I suppose that when I run "chg 1000 12600 3000", the charger should turn on and I should get 12.6V in the "BAT_PROTECTED" trace, is that right? well... that's not happening sad

If that's the case, I have to check for a problem in the charger circuit, maybe it's the U200 itself or any of the circuitry around it... I have checked the U200 several times and I don't have short circuits, but it could be any other thing.

I have to say that I ordered the wrong shunt resistors, so instead of 4 terminal resistors I have normal 1206 resistors of the same value and tolerance... that may cause a reading on the current a bit off, but it shouldn't prevent it to work...

Edit: I made some progress!

I have been studying the schematic a bit more (I should have done that from the beginning) and I didn't understand why I didn't get any output in the +12V pins of the SATA connector, it turns out that I had a bad solder at the source of Q202 and that prevented Q205 to turn ON...

So, I'm still unable to talk to the gas gauge, but at least I have solved one problem smile

Re: Testing the battery board

The gauge is pretty reluctant to turn on.  I do know you have to enable the charger for a brief period to kickstart it.  It's been a while since I've looked at the code (five months, you're right), so I'm not sure what to suggest.  I will definitely be rewriting the code there, and have my current repo up at https://github.com/xobs/senoko-chibios-3, but it currently boots and that's about it.  I don't even have I2C enabled yet.

My firmware must be old.  Try running the "setup" command, then.  I do know that the GG will freak out and refuse to charge because it sees the voltage as too low, because it comes factory-programmed to charge four cells.  And yes, you should see 12.6V coming out the BAT_PROTECTED trace.

Re: Testing the battery board

xobs wrote:

And yes, you should see 12.6V coming out the BAT_PROTECTED trace.

My main problem now is that I don't have an oscilloscope at home and probably I won't have spare time at work to use one there until September or so... sad

Anyway, with the multimeter I'm able to see the charger turning on during a brief period of time, then turning off. The multimeter has a max-hold feature and I was able to measure the BAT_PROTECTED voltage and it seems to work well, I tried several output voltages and it seems to reach the specified voltage and then it turns off.

These are good news, because it means that the charging IC is working, but it has a lot of protections and conditions which if they aren't meet they cause to turn itself off, so probably I will have to check for every one of them during the turn-on process hmm

Also, today I changed the shunt resistors I had (which were the wrong type) for the correct ones, mainly to ensure the current reading is accurate enough for when I get the circuit to work, but of course, that wasn't the problem.

7 (edited by ballanux 2014-07-27 01:21:13)

Re: Testing the battery board

Eureka!!! smile

I took more time that I would like, but I finally found the problem!!

Of course, it had to be a bad solder big_smile

It was the SCL line of the gas gauge! I inspected it with a magnifying glass a dozen times and everything looked good, but still there was no electrical connection! I soldered the pin and everything was good!!

This was the output from the initial configuration:

ch> info
Kernel:       2.6.0
Compiler:     GCC 4.8.4 20140526 (release) [ARM/embedded-4_8-branch revision 211358]
Architecture: ARMv7-M
Core Variant: Cortex-M3
Port Info:    Advanced kernel mode
Platform:     STM32F10x Performance Line Medium Density
Board:        Senoko STM32F1
Buiime:   Jul 26 2014 - 16:06:47
ch> stats
Manufacturer:       error 0x80000004
Part name:          error 0x80000004
Firmware ver:       error 0x80000004
State:              error 0x80000004
Time until full:    error 0x80000004
Time until empty:   error 0x80000004
Chemistry:          error 0x80000004
Serial number:  error 0x80000004
Capacity:           error 0x80000004
Full capacity:      error 0x80000004
Design capacity:    error 0x80000004
Temperature:        error 0x80000004
Cell count:         error 0xFFFFFFFF
Voltage:            error 0x80000004
Current:            error 0x80000004
Charging curre error 0x80000004
Charging voltage:   error 0x80000004
Avg current:        error 0x80000004
Cell 1 voltage:     error 0x80000004
Cell 2 voltage:     error 0x80000004
Celvoltage:     error 0x80000004
Cell 4 voltage:     error 0x80000004
Alarms:
    TERMINATE CHARGE ALARM
    OVER TEMP ALARM
    TERMINASCHARGE ALARM
Charge state:
    Battery discharging/relaxing
STATUS ERROR CODE: 0xC
ch> chg 1000 12600 3000
Setting charger: 1000mA @ 12600mV (input: 3000mA)... Ok
ch> chg
        Current is measured in mA, voltage in mV
        Chager manufacturer ID: 0x0040
        Chager device ID: 0x0007
Charger state: 2944mA @ 12592mV (input: 3584mA)
Usage: chg [current] [voltage] [[input]]
ch> chg -
Disabling charging
ch> gg
Usage:
gg dsg +/-            Force dsg fet on or off
gg setup [3/4] [mAh]  Set up charger with [3/4] cells and a capacity of [mAh]
gg cal                Calibrate battery pack
ch> gg setup 3 1000
Setting cell count... Set 3-cell mode
Setting capacity... Set capacity of 3 cells to 1000 mAh
ch> chg 1000 12600 3000
Setting charger: 1000mA @ 12600mV (input: 3000mA)... Ok
ch> chg
        Current is measured in mA, voltage in mV
        Chager manufacturer ID: 0x0040
        Chager device ID: 0x0007
Charger state: 896mA @ 12592mV (input: 2816mA)
Usage: chg [current] [voltage] [[input]]
ch> stats
Manufacturer:       Texas Inst.
Part name:          bq20z95
Firmware ver:       0x5009
Charge FET:         off
Discharge FET:      off
State:              normal discharge
Time until full:    65535 minutes
Time until empty:   0 minutes
Chemistry:          LION
Serial num     0x0001
Capacity:           0%
Full capacity:      1538 mAh
Design capacity:    1000 mAh
Temperature:        -37.-5 C
Cell count:         3 cells
Voltage:            11523 mV
Current:            -7 mA
Charging current:   0 mA
Charging voltage:   0 mV
Avg current:        -6 mA
C1 voltage:     3904 mV
Cell 2 voltage:     3834 mV
Cell 3 voltage:     3785 mV
Cell 4 voltage:     0 mV
Alarms:
    TERMINATE DISCHARLARM
    REMAINING CAPACITY ALARM
    REMAINING TIME ALARM
Charge state:
    Battery initialized
    Battery discharging/relaxing
  ttery fully discharged
No errors detected
ch> 

Now I will try to charge a small 3S 1000mAh Li-Po battery. If everything goes well I will wire a RaspberryPI in the same way the novena main board would be and start doing some tests. I want to make a couple of battery packs from 18650 Li-ion cells as I have a bunch of those...

I would also want to take a further look at the code, maybe I can contribute with something smile

8 (edited by ballanux 2014-07-27 23:55:00)

Re: Testing the battery board

Finally, today I was able to run my Raspberry Pi from the senoko board with a 3S LiPo battery!! big_smile In fact, I'm writing this post from the rPi right now:

http://i.imgur.com/rx0RIB1.jpg

As you will see from the picture I'm getting the 5V from a linear regulator which is really a bad thing to do with such a great voltage drop. I will replace it with a switching regulator as soon as possible. In fact, I'm running the rPI from batteries because that implies "only" a 7 volt voltage drop in the regulator, but with the AC power is much worse, (12V drop) and the LM317 gets hot really fast...

Apart from powering the rPI, I also have the serial connection working, next, I will use some GPIOs to control the board as the novena does.

Re: Testing the battery board

Hey, that's great!  Glad to see you got it up and running.  It's definitely more motivation for me to improve the code I'm writing for Senoko.  Especially if there are consumers out there already.

Re: Testing the battery board

Wow very good work.
So I hope you're in for a assembly workshop at 31c3 as our "dark lord"

"one board to controll them all, one board to connect them,
one board to power up them all, and with novena to light them.
In the land of 31c3, where the creativity lie"

Re: Testing the battery board

Very nice, ballanux.

12 (edited by ballanux 2014-08-02 23:25:08)

Re: Testing the battery board

Thanks everyone! smile

Today I was able to change the LM317 I was using for a buck converter, I used a MC33063A. This way I can use the rPI while the charger is connected. The IC warms up a little but nothing compared with the linear regulator.

http://i.imgur.com/kBOjvf3.jpg

Next I would like to test some 18650 batteries I have in a 3S 2P configuration, which should give me a lot of capacity. I haven't measured the exact capacity of the cells I have but should be something between 2000 and 3000 mAh, so that would mean a battery pack of 4000 ~ 6000 mAh.

I'm trying to come up with a battery holder that fits in the novena case, but the vertical space is very limited! The cells are about 18.5mm in diameter and the holder should be 21mm or less, so not much room to put the cables below the batteries... I will have to route them on the sides.

http://i.imgur.com/WHq9AiU.png

Re: Testing the battery board

Yesterday I printed the battery holder:

http://i.imgur.com/5WSAOLy.jpg

I was planning on using springs in both the + and - side, but I tried to make a "slider" type contact with a paper clip and turned pretty well, so probably I will use them for the + side in the final design:

http://i.imgur.com/HuvZRvi.jpg

From this first print I think I can make the individual holder diameters a bit smaller so the battery locks in place better and I definitely have to find a way to make wider and deeper wire slots:

http://i.imgur.com/0FOHX57.jpg

This battery arrangement will take a lot of space in the novena case, but I hope it fits! If not, I will just make a "heat shrink" battery pack or use a RC battery like xobs and bunnie intended in the first place smile

BTW: The holder design is based on http://www.thingiverse.com/thing:331394 but it's heavily modified, if anyone is interested I will release the STL and OpenScad sources once I get it right.

Re: Testing the battery board

Have you made any progress with this? I've got a bunch of 18650's I'd like to use in my Novena and it'd be great not to have to reinvent the wheel...

Re: Testing the battery board

I still don't have my novena, but based on the STL files, the battery holder I made won't fit properly (it's too tall). I started a new model which should fit, but I didn't want to finish until I have the novena so I don't waste work...

http://i.imgur.com/e1BsapW.png

As you see in this version the holder has slots so the height of the holder is actually less than the battery itself. I hope to continue with this in a couple of weeks, but if you want to go ahead I can share the Blender model.

The main things remaining to this model are the mounting holes and cable passages.

Re: Testing the battery board

I made the horrible discovery this evening that 18650's are *just* too big to fit by themselves, without any battery box. My micrometer pegs them at 18.25mm diameter.

Augh! For the sake of 0.5mm, all is lost.

Re: Testing the battery board

pelrun wrote:

I made the horrible discovery this evening that 18650's are *just* too big to fit by themselves, without any battery box. My micrometer pegs them at 18.25mm diameter.

Augh! For the sake of 0.5mm, all is lost.

In the case the came with the Novena? You could try cutting/sanding/filing down the peek array a bit.

That's a good reminder to make sure I have some extra room in my case design... You're definitely right that 18650s are a LITTLE bigger than 18mm in diameter.

Re: Testing the battery board

On further investigation, part of the problem is that the LCD bracket tends to bow out a bit in the centre, which removes a couple of mm of clearance. I'm not sure there's much I can do about that.

Re: Testing the battery board

I've given up on the 18650's. The final clincher was that the battery contacts I have are actually taller than the cells, blargh.

It's a shame that all the 3S batteries on hobbyking are too thick. It looks like the best option is the 2S 8000mAh zippy, which would have a similar capacity to a 3S 5300mAh pack. It'll pretty much take up all the room in the peek array, but it's not like I'm using much of it yet.

Re: Testing the battery board

pelrun wrote:

I made the horrible discovery this evening that 18650's are *just* too big to fit by themselves, without any battery box. My micrometer pegs them at 18.25mm diameter.

Augh! For the sake of 0.5mm, all is lost.

Your LCD bracket must have too much bent in it, I have no problem fitting the batteries in my novena!