Sunday, March 2, 2014

Trains. And moon.




Update 030214 - Cosmetic


It's cool but also ugly. I only have one tail fairing and no front end. My headlight are flashlights hard-wired into the headlight circuit. This needs some work.



I finally bought a welder. I definitely need more practice and a CO2 tank, but flux core works for now. I built a front headlight fairing to replace the original instrumentation and zip-tied flashlights. The headlights are still flashlights, but they've got focusing lenses and are definitely bright enough.

Now it looks really cool. I'm going for a post-apocalyptic theme, and that's not just an excuse.


Update 030214 - Charge Controller

It's been a while, but I've been making steady progress!

I built up the charge controller board from my last post. It's got eight optoisolators on each side, one for each cell balancer. The blue potentiometer is used as a voltage divider to bring the 50+ pack voltage down to IO levels for the ADC. I wanted the option of using this board as a general breakout for this microcontroller, so it's got a few buttons and some prototyping space as well.

As with any rushed prototypes, it's got a few bodge wires. Apparently not ALL of the PSoC3's GPIO pins are really GPIO, some of them are for USB only (dedicated differential amplifier inside?). I cut a few traces and re-routed these to some extra pins, no big deal.


I added a 130 ohm resistor to an unpopulated pad on each cell balancer to limit the current driving the LED in the optoisolators. Then each balancer has two leads added, one on positive and one on the lower side of the "Balancing" LED, through the 130 ohm resistor. When the balancing LED comes on, the LED within the optocoupler will also switch on, pulling a microcontroller IO pin low.

R15 is the added resistor.
It works! I can bias the transistor that controls the balancing by touching the board in the right place with a wet finger. The charger shuts off to keep from overcharging any cell.



But it also doesn't work. As the batteries charge and cell voltage nears 3.6 volts, the balancers activate but cell voltage keeps rising, shooting past 3.6 volts and higher. As soon as the microcontroller shuts the charger off, the cell voltage quickly drops below 3.6 volts and the balancers turn back off - never actually balancing anything. So, this system will keep the cells from overcharging but can't be used to actively balance the battery pack.

The solution? Wet fingers. I can further modify the balance circuits so my microcontroller can put them into the balancing state. Then once a cell reaches full charge the microcontroller can shut the charger off, hold the charged cell in balancing mode (10-20 minutes?), and then start charging again.

This offers another advantage: self test on power up. Before beginning a charge, the microcontroller can briefly put the cells in balancing mode and check that each balancing LED is on. Then I don't have to worry so much about the controller failing, overcharging a cell, and burning down the house I live in.

This means re-spinning the PCB. A good opportunity to fix the mistakes in the first one, and it won't be as much work this time since I can work off the old schematic and layout.

Thursday, December 5, 2013

Update 120513

I have batteries!



I'm using 16 60Ah LiFePO4 cells, 3.3 volts nominal for a total of ~52 volts. Lithium batteries are difficult to charge since they must be kept from overcharging, which can happen if the individual cells become unbalanced (some cells undercharged, some overcharged, but pack voltage looks normal). This can happen over several charge/discharge cycles.

The best way to fix it is with a battery management system. This measures the voltage of each cell and can charge/discharge individual cells to keep them all balanced. The cheaper way uses cell balancers, an isolated circuit for each cell which shunts 500 mA across the cell if it reaches the 3.6 volt "overcharged" threshold.

Guess which way I'm doing it? Actually a combination of both. Even with balancers the cells can overcharge. 500 mA across a cell won't stop the cell from charging with a 15 Amp charge current, it'll just slow it down. To remedy this, I'm building a management system that can shut off the charger should any of the cells begin to balance. After the cell voltage drops below the 3.6v threshold, the charger starts again, bringing up the rest of the cells. After repeating this (probably many times), the cells will eventually remain in pretty close balance.

I'm using a Cypress PSoC 3 microcontroller to control this and a few other things on the bike. In a TQFP100 package it's not very easy to develop with, but the high IO count allows me to do a lot of things with it. I've soldered this to a generic TQFP100 breakout board (I'm quite proud of my ability to solder .5mm pitch 100 pin IC :D )

TQFP100 .5mm pitch!
The cell balancers have a red LED which light when they're balancing. I'm using the voltage at this LED as a signal to tell the microcontroller which cell is balancing. Since each balancer is isolated and has its own ground level, I'm using optoisolators to levelshift to the microcontroller IO levels.

Testing with 4 of the cells.
Character display shows which cells are balancing and overall pack voltage.

The microcontroller is also reading overall pack voltage (pretty close, it's difficult to measure 50 volts with a 5 volt microcontroller and ADC) and can time how long each cell has been balancing. The row of numbers along the bottom of the display represent the balancing state of each cell. 1 is balancing, 0 is not balancing. Once a cell begins balancing, the microcontroller can wait a preset amount of time, shut off the charger with a relay or over CAN (depending on how sophisticated my charger is), and then being charging again when the cell has balanced.

I could also add to the microcontroller the ability to turn on and off the balancing circuit on each cell. The balancers turn off when the cell voltage drops to 3.57 volts, so if the other cells are quite below this, it'd take many cycles of charging, waiting, charging, waiting before all the cells are balanced. We'll see how this works first.

After prototyping with a breakout board and 4 cells, I designed a PCB for the microcontroller and optocouplers. I spent too much time on this layout, but symmetry is beauty and it's $/inch^2.

layout
render

Sunday, October 27, 2013

Update 102713

Lots accomplished this weekend, I've started the wiring!

I'm using 0 gauge wire, which isn't very easy to work with. This should be a little overkill for 100 amps, but maybe I'll increase the system voltage someday. I crimped the big copper lugs by squishing them in a vice with an allen wrench to make an indentation.


Grommets are the unsung heroes of wires going through holes. The distance between the IGBT and the motor needs to be as short as possible to limit inductive spikes from the high-current wiring. It's probably possible to get them even shorter than this, but it's difficult to bend the thick wire.


Shrink wrap and grommets will make anything look professional. Ammo boxes won't, but that's entirely okay. I sanded off the paint between the IGBT, ammo box wall, and aluminum heat sink and bolted it all together with heat sink compound.


With a home for the electronics now built, it's time to put them in! I installed the microcontroller and supporting hardware this weekend. I cut a piece of Plexiglas to slide into the bottom of the ammo box, creating a sturdy and insulated mounting surface for the electronics.


The red PCB on the left is the main microcontroller for the motorcycle. It's a Cypress PSoC 4 Pioneer kit using an ARM Cortex CPU at 48 MHz. Its main purpose is to read throttle position using an ADC and generate the duty cycle output switching the IGBT on and off. It's also driving a LCD display on the handlebars. The red PCB on the right is a relay board that the micro can use to control other stuff on the bike. Toward the back of the box is the IGBT drive and a blank board that will provide 5 volts for the micro.


No worries, the LCD is now securely zip-tied in place. I'd like to get more Plexiglas to mount the display behind, that'll help with waterproofing too. This displays 0 - 255 throttle position for now, but I'd like to add battery voltage, speed, and motor current as well. 




Saturday, October 19, 2013

Update 101913

I built the gate driver, adding a 18v LDO regulator - I initially planned to run it straight off the first battery (~12 volts) but the gate driver IC (HCPL-3120) requires 15 - 30 volts. My IGBT can have up to 20 volts on the gate, so 18 leaves some safety margin.

The driver is limited to 1.45 amps out. The LDO can deliver 1 amp with a good heat sink, which it doesn't have, but the IGBT gate will only draw ~1.45 amps for a short time. With a 47 uF capacitor on the 18 volt rail, it shouldn't be an issue.


I also finished up the ammo box mount and bolted the heat sink and IGBT together. I'll be able to fit the rest of the electronics in the ammo box as well.



It's upside-down, the electrons will fall out!

It looks fast! I won't tell people how slow it is.



Saturday, October 12, 2013

Motor Driver

Here's my planned motor controller. I've tested it without the gate driver and relays installed, so hopefully it'll work.

The HCPL3120 also optically isolates the gate of the IGBT from the microcontroller IO. It's basically a half h-bridge that can drive up to 2.5 Amps to quickly charge and discharge the capacitive IGBT gate.

The precharge relay is used to slowly charge the large capacitance across the 48 volt battery bank, avoiding a large current rush into the caps. This is easier on the main power switch as well. I haven't decided whether to use a main relay or just a large mechanical switch. I like the idea of a big red button.


The IGBT will have a 3 volt drop across it, and at 100 amps will need to dissipate ~300 Watts worst case. I'll mount the IGBT inside an ammunition can with the heat sink on the outside.