Arduino Micro based On-Bike Lithium Charger/BMS/AH meter

mikereidis

1 kW
Joined
Jul 24, 2008
Messages
343
Time for a build thread. I'm well along in my design of an Arduino micro-controller based bike mounted Lithium charger, BMS, AH meter and bike computer. This will have features similar to the ebike Cycle Analyst (but more powerful, extensible etc. :) )

For the record: The TME balancers I ordered 7 days ago are being "reshipped" today as apparently there was a customs form snafu. I'm regretting this purchase already since I may have my own balancer etc working by the time I actually get the TMEs. Better I get my design/ideas into the "public record" here so nobody tries to claim I copied the TME. :) Hey, it's just a standard shunt type balancer; micro based.


I have prototyped the basic building blocks and they are working well. I've hacked together an Arduino shield using spare parts from my last personal hobby micro-controller project in 1985. 20+ year old MCT6 opto-isolators and 2n2222 transistors still work fine, as do IC sockets etc.

Coincidentally that 1985 project measured instantaneous engine RPM on my 79 Mustang Turbo updated every ignition pulse. This project will include same concept to measure instantaneous wheel speed from halls so as to measure speed and acceleration. Good concepts like good components and design never die. :) I'll have to try powering up the old 6801 micro; I'd hook it to my bike but I think the code is long gone.

I'm editing this thread and these first posts big time, but I'll leave some of the original post as my design criteria:

- I want it flexible for different chemistries, battery combinations etc. so others can use the design also.

- I want to make it as simple and inexpensive as possible, but with modularity for optional features.

- Fail-safe charging is VERY important. I'm currently using a "$50" manual charger consisting of not much more than a bridge rectifier for 120vac, a heater as a current limiter, and some other switchable loads like a light dimmer and lights. I use the dimmer to constantly trim the average current to try and ensure my highest cells stay at 4.2v or below.

Unfortunately, this: http://www.endless-sphere.com/forums/viewtopic.php?f=14&t=4908&st=0&sk=t&sd=a&start=285#p99779 was the result when I forgot it and left it running over 1 hour at 6-7 amps. :(

- My batteries are 5 cell LiMn 18.5v nominal, 21v max Canadian Tire Yardworks batteries: http://www.endless-sphere.com/forums/viewtopic.php?f=14&t=4908&st=0&sk=t&sd=a . I'm using 2 banks of 4 in series and may change to 4s2p (batts) AKA 20s2p (cells) at some point. But, I'm now thinking seriously of 5s4p - 5s8p to prolong cell life. I'm still hoping to find some rational way to be able to switch battery pack from high voltage serial to high current parallel on the fly with FETs or whatever; perhaps just a few at the 5 cell level, IE: choice of 5s4p, or 10s2p. Regardless, I want a flexible design that will work with any Lithium batts/cells.

- I want the ability to constantly monitor and record each cell voltage, amperage, and perhaps some
batt temperatures as well.

- Also want the same functionality as Cycle Analyst with more features, and perhaps using GPL code.

- I'd like to use USB or similar to gather voltage etc. data, from a Linux (or Windows, cough, cough) laptop, or from other small computers/devices.


Ideas:

I've considered and rejected some simple solutions to prevent over-voltage, like zener diodes, 7805's in series with diodes, and LM317T linear voltage regulators for reasons I'll be happy to write about if anyone is interested. (Basically voltage regulation for CV phase is not tight enough.)

I keep thinking of an idea I have for cell balancing/protection that requires 2 FETS and a voltage monitor per cell. FET1 is normally on and connects the cell in series with the rest of the pack, assuming cell voltage is less than 4.2v. When cell reaches or exceeds 4.2v, FET1 goes off and disconnects the cell from the series string. Also at that point, FET2 goes on and reconnects the series string but without the cell.

With hysteresis and cell "recovery/relaxation" I think the FETs will switch back and forth in a slow PWM like fashion. Yes, one cell oscillating like this will tend to make many cells oscillate, but I think this will be fine. Even with the whole cell pack at full voltage, the worst that happens is all power goes to the current limiting "resistor" (a 120vac heater).

I may revisit the 2 FET idea, but at the 5 cell level, not at the individual cell level. Reason is that even using low on resistance FETs like 4110 will add 10 milliohms of resistance per module. With 25 milli-ohm cells, that's way too much power wasted in FETs IMO. If I do it at the 5 cell level, I may be able to shoe-horn the auto switching 5s4p to 10s2p feature in.

For now however, I am going with the traditional shunt method of balancing.

Special battery chips approach:

I WAS looking for chips (or modules) that are specifically intended for charging, monitoring, protecting etc. Lithium batts. There are some rather interesting chips available. Some handle 3-4 cells, some only 1 or 2; I'd prefer at least 5 cells as my batts are 5 cell and I'd prefer not to have too many chips.

At least one device ( http://focus.ti.com/docs/prod/folders/print/bq24030.html ) I found has a USB interface, both for charging and for data communications. Supposedly you can set custom charging parameters via USB; I beleive this is just an analog front end; A->D converter(s) would need to be added.

Some of these chips/modules are either limited in current capacity and/or require external transistors to handle higher currents. I'm targetting 12 amps as maximum charging current, but even 4 amps would be nice.

Current approach:

Forget about the special chips. My design now is one single Arduino board for each 5 cell battery with a "shield" board containing a small handful of components. In 5s4p I'd only need one of these combos. In 10s or 20s I'd need 2 or 4. Perhaps another Arduino to collect all the data and handle touchscreen LCD and bike computer/CA type stuff.

DIP based Arduino has 6 analog inputs, SMD based has 8. I'm using DIP and will monitor 5 cell voltages and battery current to use all 6 analog inputs. Cell one goes straight to analog input 1 (through resistor just for safety) with A->D at 5v full scale. Cell N goes to N:1 divider resistors. I can use resistors in megohm range since analog inputs seem to be VERY high impedance. So voltage monitoring will not draw down batteries; I figure 700 years to drain full batts completely. :) (Yes, the self discharge is much higher.)

Subtracting the voltages will give each cell voltage. Low cell is accurate/has resolution to 5 mV and top cell accurate to 25 mV. Good enough. Current monitor may be coarse at 5v full scale, so perhaps I'll revisit the 5v decision. There's a 1.1v reference on the chip that might be better. 0.1v drop at 10 amps would be 10 millio-ohms and would give resolution to 1 mV (10 bits) or about 0.1 amps. Good enough for a first try; will revisit later; perhaps a 10:1 op amp gain would work better.

Post is getting too long so shunts in next post.
 
Shunt control inputs will come from digital outputs on Arduino, tied to opto-isolators.

High current darlington opto's can handle up to 200 mA (Clare CPC1302G). I think I may go with the NEC PS2532 though http://www.sparkfun.com/datasheets/Components/PS2532-Optoisolator.pdf for 150 mA. Toshiba TLP627 also looks decent for 150 mA and comes in 1, 2 and 4 opto models.

With 150 mA, this might be enough shunt current for undamaged and/or lower capacity cells without needing anything more than (per cell) one opto, one 1K input resistor, and one shunt power resistor of 24 ohms and 1 watt.

For higher current needs I'm thinking transistors like 2n2222 for up to 600-800 mA, although I'd love to find a chip I could use with high current and multiple fully independent channels. The http://www.sparkfun.com/datasheets/IC/uln2803a.pdf darlington transistor array with 8 channels at 500 mA per channel looks nice BUT all channels share a common ground so I can't use that for shunting cells in series.

There's a million power transistors out there for higher current needs, but I think I'll stick with 2n2222 for now. A 10 ohm 2 watt power resistor with 2n2222 is good for 350 mA or so, and that's enough for me for now I think.


The micro code should be pretty simple just for charging/balancing. A simple test program to turn shunt on when voltage was over selected value and looping 1000 times second worked OK, although some tweaking will be required for fastest operation. REALLY, it's very simple. I've done MANY software projects much more involved than this; the space on a micro for code is at least 10 times smaller than many of the medium sized professional projects I've done. Of course the sky is the limit for features, but I will severely limit the feature set in the name of getting something decent enough working quickly. Firmware can always be extended in future.
 
Thread has been re-purposed and mostly re-written. Comments, questions, ideas ?

I'm looking to product-ize this project and transition myself into the e-transportation micro-controller business from my currently boring corporate software dev job.

I'm very attracted to the open source GPL and Creative Commons models. I'm not entirely convinced open source GPL is the way to go for the code though, and I think code may be my primary asset since hardware CAN be manufactured quite cheaply.

Hardware design will be pretty basic though; I like the idea of using off the shelf components, but for now at least, there is no such thing as an Arduino BMS shield. Once I'm done, I think there will be.

Charging input provider will not be a part of the micro BMS project. One would be able to use a power supply of whatever DC voltage and current are available or needed. Say, 90v for 20s or 22-25v for 5s. If one wanted to use a "dangerous $50 charger" using a rectifier and heater/resistor to 120vac input, that would also work, although it would probably not be recommended (officially at least).

Cell safety is paramount, so I'm looking to add whatever crow-bar etc. type protection circuitry to have some redundant safety features.

I am thinking about using VERY conservative parameters with new batteries to see how much cell life can be extended. Perhaps 3.4-3.5v under load for LVC, 4.0v max, and 4p with 20 amp controller to limit current drain to 5 amps per 6 AH cell. (Less than 1C). Charging current perhaps 3 amps max for 0.5C charging. My Prius uses the same type of conservative approach to help the nickel batteries last the 10 years some states require for warranty purposes. Reportedly only 1/3rd of the actual capacity is used, but I'm hoping I could settle on conservative values that give at least 70-80% of rated capacity of 6 AH at lower currents.

I'd have another new battery pack using traditional values and higher charging current: 3.0v LVC, 4.2v max, 12 amp 2C charging. Either 2p or 1p for 10 or 20 amps max discharge per cell: 1.67C or 3.33C. Time would tell how these two sets of parameters would impact cell cycle life.

I will monitor, store and graph every charge and discharge cycle for analysis.
 
RLT said:
Well, the electronics is all way over my head, but it sounds like a good idea!

OK, cool. I guess you all want fancy pictures and graphs and everything, huh ? :) They will come when I'm more awake...

I was at a local electronics parts store today for $100 worth of "stuff". Saw a 4 relay interface board kit for $28 and grabbed it.

Tonight I checked the specs and the relays work on 4 volts at 40 ma. Gee, the Arduino Atmel CPU can put out 40 mA per pin... Tried it, bingo ! It works....

It has LEDs so I guess it's like a Blinky.

But the relays make lots of noise so I'd call it a Clicky too... :mrgreen:

At 25 loops per second it was sounding like a typewriter... semi-random typing at first, like a fumbling, frustrated writer. Then later as the cell fills, like a writer who's lost his writers block and letters and symbols being typed at a furious pace. And then, another writer... the second cell fills and they are both typing away...

Too funny. :) Cells are VERY nicely balanced now, after I calibrated with a potentiometer... Works better and easier than software correction could, with only 10 bits of A->d resolution.

I'm not entirely sure the relays are a good long term choice, but it's interesting. I'll have to check some relay specs on life when being cycled like that. I could change code to not cycle so often and that would help. I've been avoiding relays because they seem clunky and prone to mechanical failure.

But relays (with a protection diode) can be hooked straight to the CPU, and that saves a circuit with 1 opto-isolator, 1 transistor and 2 resistors. I suspect the relays are a bit more expensive than those parts, but it's cool to have a simple circuit.

Hmm, Digikey has a "solid state relay" listed for $1.39 from Toshiba: http://www.toshiba.com/taec/components2/Datasheet_Sync//214/4499.pdf

TLP592a is actually a "Photocoupler Photorelay" that is good for half an amp, which I think is good for balancing. Cool... :)

Actually it looks good for one full amp, because it has two sides that can be ganged... even cooler.

TLP222 http://rocky.digikey.com/WebLib/Toshiba/Web%20Data/TLP222A,%20TLP222A-2.pdf and TLP227 http://www.toshiba.com/taec/components2/Datasheet_Sync//214/8687.pdf also seem to be in same family with almost identical specs except $1.53 and $1.78 and they can't be ganged.

"Evil" thought: the Atmel CPU can put out 40 mA per output pin, to a max of 200 mA for all pins. So I could gang five pins together and NOT need any external components, except for a 20 ohm, 1 watt power resistor. :twisted: This would require one CPU/Arduino per cell; Digikey lists cheapest CPU at $2.32, in quantity I guess but not in stock. $4.00 is the minimum for quantity 1 and in stock.

Would still need to opto-isolated connect all these CPUs to a master CPU, but 1 CPU per cell is an intriguing thought. Maybe $10 per cell with a board and a few parts...
 
Yes, I AM publicly documenting my design here...

Several design decisions have been made. As always they are tentative/subject to change if better approaches are identified.

- Basic hardware design will be as generic as possible. This will allow the hardware to be used in different ways and for many more purposes than just as a fixed purpose BMS.

- A professionally made printed circuit board is planned. This PCB will be as generic as possible, with jumpers for different options and generic pinouts used for resistors, opto-isolators/photo-relays, FETs, etc. The PCB can be populated with as many components as needed, and with different resistor values, FETs etc. to customize the voltage ranges and currents needed versus component costs.

There is no reason why the hardware MUST be just for an ebike BMS etc. With a bunch of photo-relays and FETs or BJTs or whatever, and voltage divider analog inputs, this board will be useful for any sort of power interfacing and monitoring application. This includes robotics, radio control models, home automation,....., you name it.

If (actually when) this is productized and sold, anything that makes for higher sales will make me happy and will decrease the costs for purchasers. Win-win... :)

- Hardware design comes first, followed by (but keeping in mind for HW design) "system" design, followed by software design and coding. Software can always be updated and enhanced later (within hardware and system limits). Initial software will be as simple as possible while still being useful.

By "system" design I mean the interconnection of multiple micro-controllers/peripherals. At present I am aiming at 1 micro-controller with its' inputs and outputs as the basic unit capable of managing up to 5 (or 6 or 8?) cells. A 10 cell battery pack could be managed by linking two of these units. An alternate arrangement would be to have a master micro, connected to each of the units. Or who knows, the two units could just send serial data to a 2 port LCD or a 2 port PC/laptop that displays the info and may record it. A serial data logger with CF or SD storage could also be connected.

These system details can be worked on later, but I want the hardware to work well with almost any system design that could be useful.

One system detail I've struggled with is whether to use 1 Arduino per 5-6-8 cell battery, and thus have the potential for needing 4 Arduinos for a 20s pack, or to use 1 Arduino for the whole pack and add external A->D conversion with multiple channels. Reason for this issue is that Arduino only has 6 voltage measuring analog inputs. Texas Instruments has a number of cheap $4 or so A->D converters that handle 8 or more channels. But the Atmel CPU only costs $4 or so ! But then there are issues with the extra boards needed and there components etc.

Anyway, for now at least, I've settled on the multiple Arduino approach. Inter CPU communications can be very complicated, but it IS possible to keep it simple. For now I'm thinking of using standard async serial, through photo-relays for inter CPU communications. SPI and I2C have some interesting capabilities, but for now simple serial.

- PCB will be usable as an Arduino Shield that just plugs into a standard off the shelf Arduino. It will also be usable stand-alone, or with some other micro-controller using wires to connect instead of Arduino shield layout.

- "Reference" and testing components will be the biggest capacity I can get that seems reasonable in price and size etc. For example, 150 mA photo-relays are the tops I think, and 4110 FETs should handle almost anything.

- Perhaps in future, a PCB could be created that hosted multiple Arduinos on on board. The PCB would be "break away" so you could cut a board for 10 CPUs, or 2 or 1 etc. Each Arduino would be electrically isolated with separate grounds and voltage source(s), but with opto-isolated communications ports or a bus like I2C or SPI.


That concludes my basic design decisions at this point. The rest is mostly details about specific components etc.
 
Mechanical relays? That must have sounded amusing... Clearly mechanical relays will not be good for the long haul. High powered optocouplers are fairly expensive, but may be in the same ballpark as a low powered one plus a transistor. I'd recommend using a transistor.

I have a BMS made by a anonymous high end producer that uses a FET in series with a resistor for the shunt. The FETs are triggered by an independent analog voltage detector, so the MCU is only reading the voltages and controlling the overall charging current so that no cell goes over voltage. The FET is in switching mode, so is either full on or full off.
 
Ideas/thoughts:

- If there are multiple units and 1 is the master, it should be the unit connected to most negative end of battery pack. This will allow it to more easily interface with the bike motor controller and anything else that uses the full pack voltage, or anything that uses a tap off of the pack (like a 20v tap on an 80v pack) with reference to the bottom of the pack at 0v.

If different sized batteries are used in series to create a pack, the bottom, most negative end of the pack should be the most powerful in terms of AH or A. I see no reason why you couldn't mix different chemistries (Pb even) in a pack, if your system is smart enough to handle that.

- Hub motor hall sensors and/or speedo reed magnet or whatever will be hooked to digital input(s). Temp sensors and throttle can be hooked to spare analog inputs. D->A or PWM could be used as throttle input to motor controller. This would allow true cruise control, or even intelligent cruise control. Intelligence could cut back throttle to keep lowest cells above LVC to get maximum range getting home or to charging location without complete pack cutout. I keep thinking of a FET based switch, at battery (or cell possibly?) level that would bypass low batteries or cells or could switch pack from series to parallel on the fly.

- Arduino has a bunch of hardware speed PWM outputs that could be used for many things: DC hub motor speed controller, bike light brightness control, charging current/voltage control, discharge current/voltage control (not for brushless hub motor though, unless..... hmm, maybe that could work with voltage control with decent caps) etc. Arduino could be basis for multiple programmable voltage switching type supplies; it could do that to power itself (after normal wasteful power boot-strap), bike lights, or any other accessories that need smaller voltage than full pack, but that you want to power from full pack (or a tap on pack) to keep cells balanced on a ride.

- If I'm struck down by a truck or disease or whatever, I hope someone else picks up this project or a similar one. (Yes, I'd care from the great beyond or wherever... :) ). Otherwise expect a full commercial product available in spring at start of ebiking season.

- I think I'd make the PCB layouts Creative Commons licensed so anyone/any company can copy the hardware. Like open source software, I think there are advantages (esp. to a single person such as myself) to getting as many units out there as possible, even if that means I sell a smaller percentage of overall HW sales.

- I'm not convinced that open source software is best for me, but it may be. At a minimum, some basic useful code should probably be GPLv3'd. Maybe I could license for free personal usage, but make commercial redistribution of code require a royalty. I will see. Regardless, everything will be so open that others could easily write their own code, with whatever license they choose.
 
fechter said:
Mechanical relays? That must have sounded amusing... Clearly mechanical relays will not be good for the long haul. High powered optocouplers are fairly expensive, but may be in the same ballpark as a low powered one plus a transistor. I'd recommend using a transistor.

I have a BMS made by a anonymous high end producer that uses a FET in series with a resistor for the shunt. The FETs are triggered by an independent analog voltage detector, so the MCU is only reading the voltages and controlling the overall charging current so that no cell goes over voltage. The FET is in switching mode, so is either full on or full off.


Yes, it was amusing. :) Shades of the old ASR-33 110 baud teletype I had in my childhood basement...

I will take and youtube post some video/audio when I get the chance.

I think I'd like to make a PCB with the option of using just a 150 mA photo-relay for outputs, or adding a transistor to the photo-relay for bigger currents. I imagine 4110 FETs would be fine for the maximum currents I foresee in the near future. I guess I just need to have a 10 volt supply to satisfy Vgs on the 4110 ?

Instead of being "stuck" with the feature of MCU digital outputs controlling the shunt FETs or photo-relays, I like the idea of being able to hook a hardware comparator output to the photo-relay input. Thus the hardware would have the option of software based, or hardware based (with extra components) balancing or discharge testing.
 
Well gee, looks like there is already an Open Source BMS project underway: FreeBMS: http://groups.google.com/group/freebms/topics

How come nobody told me ? :) I imagine this project will take some time to gel, if it ever does, but looks like a good source for info and debate on components and design.

I'm really liking that Toshiba TLP592A at $1.59 quantity 1. http://www.toshiba.com/taec/components2/Datasheet_Sync//214/4499.pdf , 500 mA or 1 A ganged and works with AC (non-ganged) or DC.

Toshiba seems to have the best selection of opto-isolating devices and at cheap prices.

I was looking at various linear opto devices for voltage measuring of more than 5-6-8 cells by a single micro. Can't find any that are less than $2.50 per channel. Could possibly use photo-diodes which seem somewhat linear-ish, but I don't think that risk should be taken with lithium and with the need for accurate voltage measurement. So still looking at one micro per 5-6-8 cells.
 
mikereidis said:
Well gee, looks like there is already an Open Source BMS project underway: FreeBMS: http://groups.google.com/group/freebms/topics

How come nobody told me ? :) I imagine this project will take some time to gel, if it ever does, but looks like a good source for info and debate on components and design.

Hmmm... looks interesting. Mostly stuff we already did here a while back.
Perhaps someone should post a like to our site over there. :wink:

10v would be the minimum drive for a 4110. I'd go with at least 12v. One can handle up to 70 amps with adequate heat sinking. About 20 amps with no heat sink in the switching mode.
 
Well, I guess the "clicky" part of the design has gone by the wayside, huh, Mike??? I did wonder about durability of the relays if they were to get bounced around. For heaven's sake keep the 'blinky" part, though, purely as a customer satisfaction feature. You know...."hey, man, the lights are all blinking - - it must be doing somethin' awesome!!! Back when I was building radio stations, we put in audio processing gear with lots of blinking red, yellow and green LEDs, and the disk jockey's drug bill went down by an average of thirty percent! :shock: :shock: :shock:

ATB

BC
 
fechter said:
mikereidis said:
Well gee, looks like there is already an Open Source BMS project underway: FreeBMS: http://groups.google.com/group/freebms/topics

How come nobody told me ? :) I imagine this project will take some time to gel, if it ever does, but looks like a good source for info and debate on components and design.

Hmmm... looks interesting. Mostly stuff we already did here a while back.
Perhaps someone should post a like to our site over there. :wink:

There's an even more active EV BMS project/group at http://autos.groups.yahoo.com/group/EVBMS/ . I probably stumbled across these before and forgot... :) Yes, it would be nice to get some cross-fertilization between groups needing Lithium BMSs. I think some of this, like cell monitoring, amp-hours in versus out etc., could also be useful for the solar/wind etc. power crowd. They pretty much use Lead Acid of course, and cell voltage isn't the whole story, but it could be useful.

Anyway, one could spend forever reading and debating designs, but my approach is just to dive in, design and build.

fechter said:
10v would be the minimum drive for a 4110. I'd go with at least 12v. One can handle up to 70 amps with adequate heat sinking. About 20 amps with no heat sink in the switching mode.

OK, cool. I've never designed with FETs before but I probed them in my previous life as an electronics tech(nologist). Heat-sinkless would be fine I think for my 20 amp controller; 20 A x 5 mR = 0.1v, 20 A * 0.1v = 2 watts dissipated. I'll try torture tests to see how that works.

I've designed what I think will work for separate current controls/connections and monitoring for charge and discharge. These will be 4110 (N-channel) connected to the positive end of the battery pack. I've concluded that I MUST disconnect the positive end for LVC or over-current, to keep the negative end as a constant ground, and I see that the P-channel FETs are nowhere near as good or as inexpensive as N-channel.

The downside is that I then need a supply 12v more positive than the positive end of the batt pack. I might consider some form of gate driver chip, but for now I'm just going to go with a small battery to power this. This battery will also power a micro that has it's ground connected to other side of discharge current sensing shunt. I don't suppose anybody senses current by measuring voltage drop on the FET ?

So this topside micro will measure charge and discharge currents, charge voltage, and it's own battery voltage and current. I think it will also steal some charging current when needed if I use a rechargable battery to power it. It will be able to monitor, and shut down charging or discharging if current goes too high. Since FETs often go shorted when they fail, perhaps some sort of fuses and/or crow-bar type circuitry would be good too.

This topside micro would also be able to do PWM on charge current. I'm hoping this would be sufficient to tame my "bridge rectifier and heater/resistor" charger like a light dimmer does. Timing the pulsating DC would allow chopping off the tops of the sine wave to keep peak current every 8.3 mS lower.

PWMing discharge current might have uses also, with certain loads, like DC motors. Perhaps this could even be done for a brushless motor controller, using BIG honking caps, super-caps, or even a string of nicads, to step down a 80-100v source to 20-40-60v. I've read however that pulse discharge (like on cell phones) can reduce AH capacity versus DC discharge.

Topside micro COULD communicate with the lower voltage monitor/charge balancing micros, so that when one of the lower micros detects LVC or max voltage on a cell it sends the right commands to topside micro to cut off or cut back on charge or discharge current. I'd prefer however to have each low side micro able to cut off (or PWM) charge or discharge current by series connecting opto-isolator outputs from each micro. So all micros must agree that everything is cool before charge or discharge current is provided, and this agreement is hard-wired; not dependent on communications.
 
64ragtop said:
Well, I guess the "clicky" part of the design has gone by the wayside, huh, Mike??? I did wonder about durability of the relays if they were to get bounced around. For heaven's sake keep the 'blinky" part, though, purely as a customer satisfaction feature. You know...."hey, man, the lights are all blinking - - it must be doing somethin' awesome!!! Back when I was building radio stations, we put in audio processing gear with lots of blinking red, yellow and green LEDs, and the disk jockey's drug bill went down by an average of thirty percent! :shock: :shock: :shock:

ATB

BC

Clicky isn't gone. It just needs a piezo or a speaker to be reborn. :) I want a speaker of some sort (or siren/really loud device) as a bike bell replacement (required by law, but even my wimpy tiny mechanical bell is OK) that would get the attention of stupid drivers or pedestrians. I want audio feedback for things like voltage so I don't have to watch meters all the time. Heck, I could have the sexy star trek computer voice telling me my stats. ("LVC cell 5, dear...". :) )

One other plus of mech relays is tactile feedback. One could feel the row of relays to determine which ones are chattering. No plans at present to reproduce tactile, but it's a thought to be filed away for now at least.

Yes, yes, yes, blinky flashy LEDs in standard red for danger, yellow for caution and green for all systems go. Slowly undulating blue to get into the calm zone, with gregorian chanting from the speaker. :) I'm also tired of using hand signals, so some turn blinkers will be essential, but that perhaps should be a separate micro project.

I'm keeping in mind applications for some Spoke POV devices: http://www.ladyada.net/make/spokepov/ . This one http://hackedgadgets.com/2006/06/11/bike-pov-displays-rpm/ shows wheel RPM; no reason it couldn't show all your important stats.
 
>My design now is one single Arduino board for each 5 cell battery with a "shield" board containing a small handful of components. In 5s4p I'd only need one of these combos. In 10s or 20s I'd need 2 or 4.

I've now switched direction on this one particular issue: voltage monitoring and many micros versus fewer micros.

I first started considering ways to opto-isolate voltage measurements. Linear optos are too expensive (~ $10 per voltage/cell for good ones) and are somewhat uncommon/obscure/harder to find. Maybe cheaper optos could be hacked for linear-ish operations. Then I started thinking of 1 opto, 1 comparator and 1 linear voltage ramp chip per cell; micro would time the pulse lengths to determine voltage.

Then I noticed that Linear and some others like TI have 16 bit delta sigma ADCs in the $2 range, and 24 bit units in the $7-$20 range. These are slower, like 10-500 samples per second, but that should be sufficient for most BMS/charger applications. Some of these ADCs have true differential inputs and 4-8 channels.

I'd like to try a 24 bit delta sigma ADC for my own testing at least with static battery conditions, or voltage that remains pretty steady. 24 full bits of resolution in the $7-20 range is amazing IMO. Imagine a 0-5 volt range with accuracy to 0.3 micro-volts ! That cell is 4.199,999,4 volts not 4.199,999,7 volts !

But for now I've settled on the $5.70 Microchip MCP3304: http://ww1.microchip.com/downloads/en/DeviceDoc/21697d.pdf
13-Bit Differential Input, Low Power A/D Converter with SPI Serial Interface.
4 Differential or 8 Single ended Inputs
100 ksps sampling rate with 5V supply voltage

Just having higher resolution: 13 bits compared to 10 bits in Atmel micro, would allow the subtraction method of single ended ADC to have same 25 mV error for 40 cells, instead of just 5. 8 inputs means 8 cells can be supported without external multiplexer. For more cells, 4051 Muxes http://www.toshiba.com/taec/components2/Datasheet_Sync//151/361.pdf are cheap.

I'm favoring using the 4 differential inputs however, as it avoids the need for cell voltage subtraction method and thus gives me less than 1 milli-volt resolution for every cell, AND it also will help to reject common mode noise on sensing wires. Need twice as many muxes for differential however; maybe there is a mux chip that can do both sides of a ladder instead of just 1 side.

So with 8 8:1 mux chips at $0.50 each (or 4 double sided muxes?) plus the ADC, I'm looking at 9 (or 5?) 16 pin chips for about $10. This would handle up to 32 cells, which should be plenty for a 100v or less ebike. Nine 16 pin chips would take all the board real estate for an Arduino shield however; 5 would be much better if possible. Single ended would only need 5, as would some sort of ladder mux.

Alternatively, 8 ADCs could be used in differential, for $46, but board real-estate is similar and cost much higher.

With differential inputs, no opto-isolation is needed as all voltages are referenced to negative/ground and lower than VCC. With Vcc=5v, I'd use fixed 20:1 voltage dividers to reduce a top 100v cell to 5v range, and bottom 3v cell to 0.15v range. Differences between each cell at 20:1 taps would be in 0.15v range also. Perhaps there are precision-ish voltage divider resistor networks/chips that could be used.

Outputs to balance 32 cells though would take more digital output pins than the Arduino has. So some sort of shift registers or similar output expanders would be needed.

So my conclusion now is that using a single micro, with external ADC and muxes, and output expanders for balancing, has some nice advantages over using Atmel internal ADC and multiple micros.
 
Board is modular and split into logical/functional/conceptual blocks that could also be cut into physical blocks to make smaller PCBs.

This is not just an ebike or BMS project; The board is a generic I/O expansion device for micros and could be used for data acquisition, N-phase motor control, LED signs, RC model/robotics control/feedback, etc., etc. Your imagination is the main limit; handles anything needing up to 16, 1 amp photo-isolated outputs, and 16 differential or 32 single ended analog or digital inputs. If you need more channels, you can stack a virtually infinite number of boards or otherwise connect them with SPI sync serial.

Board is an "Arduino Shield" so it can plug on top of an Arduino micro board. But it has it's own CPU same as the latest Arduino boards, so it doesn't need an Arduino. Effectively it's an Arduino clone with LOTS of I/O, that can be linked to a virtually unlimited number of other identical boards.

Connector on left is the high current output connector, supporting un-connected or connected (such as battery balance connections) loads. It can also be used for analog or TTL level in/out if optos are replaced with resistors or jumpers. Can also be used for opto-isolated inputs if the optos are spun in their sockets.

To right of left connector are 16 photo-relays TI TLP592a; can handle 1 Amp DC or 0.5 Amp AC. Each can be removed or replaced with a cheaper opto, although that may mean some wasted socket space since most are 4 pin, not 6. LEDs (or switches etc.) could also be plugged into sockets; bargraph LEDs should work. With some jumpers or trace rework, op-amps could be installed. Optos are optional; you could have 0-16.

To right of optos is TI TCL5940NT LED driver chip that provides 16 channels of 12 bit PWM (or simple on/off). Cool chip; about $4 quantity 1. Chip is optional.

Between optos and PWM chip is single row header with 16 pins. This can be used to hook something external to optos or whatever is in their sockets. Could also be used to connect LEDs or small motors directly to PWM chip, which can handle 120 mA each output. Not sure how well that'd work for socketed chip, SMD versions have a nice thermal contact area to use copper on board as heat sink.
 
To right of PWM chip are 4 TI 74HCT4351E 8 channel analog/digital mux / demuxes with address latches. Primary purpose is the selection of 2 random differential voltages, or 4 single ended voltages simultaneously. Also usable as generic digital I/O. Chips are optional, can use 0-4 depending on your needs/channel/battery cell requirements.

Between PWM chip and muxes is a 2 row 16 pin header for connecting battery voltage sensing wires or any other analog or digital in/outs.

To right of that is the same Atmel micro-controller used on the Arduino. Above that is a Microchip SPI connected 8 channel single ended or 4 differential A2D chip that is inexpensive and gives 13 bits resolution. I was going to put a differential instrumentation amp there, but am going with this A2D for now at least.

Output connector on left can be hooked to battery cells for charging and balancing. a 10 ohm 1-2 watt resistor on each cell tap would allow about 200 mA of balancing.

Part or all of the output connector can be used with an external power semi-conductor board containing FETs, BJTs, SCRs, Triacs, relays or whatever. In theory, with 4110 FETs, one could control over 250 kilowatts with only one FET per channel. :) Derate that to a mere 125, and that could be good for a 60 horsepower motor; 6 channels could implement a 3 phase motor controller and each channel could parallel as many FETs as you can reasonably current balance between the FETs.

Pic is not showing traces. I have all the major trace groups figured out via manual pen and paper design, and they very heavily influenced the chip layouts. No, I did not just throw a bunch of chip ideas on to a board.

All components are through hole type; DIP, SIP, etc. No SMD by design. All components chosen for utility, availability (including future availability prospects) and low cost for their functionality. I've agonized endlessly over component selection and some could still change, but I'm pretty happy with these parts at present.

Board will be two layer only; top and bottom. Some traces might be pretty squeezed; I may have to move components around a little bit. Higher current traces will be thick as possible of course. I should be able to prototype this with 4 solder-less breadboards. Don't even need all chips for testing since most are optional and sections are modular.

I think each board will have at least 2 LEDs and 2 pushbuttons for the most minimal UI that is reasonable. Primary UI will be standard async serial, although at TTL level from this board; convertable to RS-232 or USB etc with adapter. Looking to use Wireless router (Linksys etc.) supported by OpenWRT Linux. This will give capability to have wireless and wired ethernet tiny web server UI as well as telnet/ssh CLI and SNMP etc. No self respecting techie e-bike would have a controller without ethernet and wireless. :)

I also think it would be nice to include a small low profile speaker (/microphone) on the standard "reference" board. Having your micro talk to you to give instructions would be very nice. As microphone one could whistle or use other sounds to control. :)

Yes, I WILL try a steering servo at some point to make a fully remote controllable e-bike; via 802.11. Perhaps one could do the same with a Prius or EV. I think this board could provide all electronic functions for an ebike or EV.

Preferred UI will be web browser, which can run on netbooks like Asus EEE PC or MSI Wind etc. Also black-berries, cell phones or anything with a browser interface.

In order not to get bogged down, and to get this out there quickly, I'm assuming the role of board designer, tester, integrator and basic functionality software designer/developer. Hardware and software will be open source and I will encourage others to build this board and write software.

I'm VERY pumped about the idea of open hardware, in addition to open software. By making hardware open I expect there will be a LOT more boards produced and tinkered with. If successful I'm sure I'll have opportunities so I'm not bothered by the concept that I may make no money directly from board sales. Perhaps I could package some ebike systems; but I'd prefer to design a package, with feedback from packagers, and let those packagers/ebike specialty shops/individuals deal with all that physical real-world e-commerce and customer hand-holding stuff.
 
With two diodes for each cell connection, either the balancing resistor board (not shown here) or the voltage sensing resistor divider board will be able to tap micro power from the battery pack, or use a separate battery for battery torture or high accuracy testing.

With the diodes and a bit of code, it's possible to have battery connectors that can be plugged in "backwards" or offset, and everything will still work, although you might lose some channels and have the board hurl verbal insults at you that some error condition exists.

Digital oscilloscope is one of the board apps I have in mind. General purpose in mind, but yes, one could record the waveforms on your motor.

BMS functionality for this board has some importance even for non ebike uses; remote sensing device could use solar cells to recharge lithium battery pack and wireless could be used to connect.

Board with FET power board attached could be used as a step-down switching power supply; IE. DC-DC converter for whatever set of voltages you need. So your 72v pack can be hopefully reasonably efficiently converted to 5v, 12v, etc; whatever you need for bike lights, computers etc.

I see no reason why this couldn't be the only electronic device you need on an ebike or EV. If it can provide bike light voltages, be a DC or 3 phase motor controller with regen, do bike computer/Cycle Analyst type stuff, etc. what more do you need except some power control/interface circuitry, a simple dumb charger, lights, switches, battery, motor and bike ?

GPS, blue-tooth, accelerometers, environmental sensors (temp, humid, press, etc.) are all on my list of desirable peripherals.
 
I'm definitely subscribing to this thread and I'll definitely be reading it later after I cull all this battery test data on ES.
 
Hi all, long time no post ! :)

I've had a few PMs, so here's my 'update' on this and related projects:

I went kinda manic on this project in the late fall, and that contributed to a bout of depression that resulted in my leaving my job on disability, and I wasn't able to get much else done either... I DID continue this project for a bit, came across a few seemingly fatal flaws in my approaches, found some IMO interesting solutions, and figured I had a design as close to 'perfection' as possible, but given my state, who knows ? :D

I'm feeling much better now and I'd LOVE to get back into the BMS project in a less manic manner. Unfortunately I have other responsibilities like family, a hopeful return to my paying job, and all the other things that didn't get done in the last 6 months.

So I'll just have to see how things go. I think my employer may find some excuse to fire me if/when I return from disability leave, so who knows, I may just have a lot more time to get back into this than I'm expecting right now.

Cheers !
Mike.
 
Mike,

I know it's been a while and hoping you got your meds right and lost the mania but wondering, did you ever pick this project up... feel like donating it to the good of mankind for further development?

I'm using Attiny's as my sub pack level MCU (6S) with their 10bit A2D resolution but am using 11 transistors at the moment to connect directly to a single cell at high impedance from 2 Analog Input Pins on the Tiny... This allows me switching between each cell in a series pack and getting a 10bit read from the ground and 10bit from the high side, well within the 5v range of Attiny but I prescale it with an opamp to expand the maximum range possible for higher accuracy then sample 8 times and average just to be perfectly safe.

Each of 3 (eventually 4) of these are in daisy chain mode with an opto coupler line held high when transmitting to the master and then passed to the next in line, the tx from each tiny is collected via optocoupler at the Atmega board providing pack level isolation.

So far this has yeilded the most accurate results by far and will be my method going forward for distributed and isolated low cost HVC/LVC and the natural evolution of this BMS, Charge Control and eventually maybe even AH meter or SOC meter to ensure capacity can be enforced.

-Mike
 
mikereidis said:
I went kinda manic on this project in the late fall, and that contributed to a bout of depression that resulted in my leaving my job on disability, and I wasn't able to get much else done either...


Whoa. This sort of effect (though not all the way to this extreme extent) seems to be something shared in common with most everybody who has tried to put together a high current digital BMS. Interesting.
 
I like the idea of a low current digital/analog , smart, bms. Use a servo with a wheel, magnet, and 40 reed switches in a circular array. just charge each sell seperately. Use it smartly with a micro, that can sample and charge each cell seperatly. Like it could for example sample each cell in 20 seconds, decide which cell is lowest, and start charging it up to the an average calculated setpoint. This would result in the fastest balancing possible , you could even run a capacitor system this way, saving the balance charge, distributing to the lowest, up to a calculated setpoint. you could top balance, bottom balance or side balance. you could run it in tandem with a bulk charger as well.

I know Ive seen that wheel idea on here, but I really think it could be done for around 20 bucks? and be smart enough to be cool? I mean the one I saw on here was on a timer and a single cell charger, real cheap and simple idea. I like.

Luke , I once thought, what a better way to ruin the creativity of a few important players, than to sell or distribute some "bunk" electronic parts with low reliability etc etc. then step back and watch the frustration and blood boil, when the protos start killing cells etc.......this IS conspiracy , at the highest levels. mabye a persons meds could be getting messed with as well!! I mean a BMS is key here.....
 
The only thing I would add to this "mechanical design" (which failure could likely be detected monitoring servo / stepper motor current), but I would strongly suggest an enclosed, very (I mean uber) low power ratcheting style servo (micros I guess), modified for 360 degree rotation. additionally I would honestly think 5v supply and SMD based halls - spaced far enough apart and with the refresh or cycle speed low enough to create break before make without chance of possible overlap - otherwise we need a gate so that only full 4.7v return will enable a transition event and the subsequent - connection of 2 very low current draw 5v relays (or transistor and current limiting resistor).

I suppose this could be made on a fairly tini scale - I've looked into parts and will at some point later post up the links (I need to find the OneNote page - hey does anyone else use OneNote?)...

I found some stepper motors with 1023 degrees of motion and others with 360 degrees - 360 degrees / 24S = 15 degrees step per selection from cell 1 to 24.

This could easily be adjusted to support even 100 cells if done right with proper engineering - for best results we will need a high res optical disc for position feedback information.

Just an idea... more than happy to continue brainstorming if anyone wants to - seems if it were designed with dual motor based selectors and a method of isolating them we could design in atleast a single measure of redundancy to prevent total failure while riding.

On another note - I think I figured a manor for calibrating each channel of the Muxed style cell interface automatically on boot up using a fairly simple bit of code, 1 digital 1K pot and an LM7805 though it may also require a 2 channel quad mux (4 channels total). More later as I flesh it out :)

-Mike
 
Back
Top