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.


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.

Wednesday, October 9, 2013

Electric Motorcycle

How difficult could it be to build an electric motorcycle!?

Kind of difficult.

I bought this 2002 ZX6E from a salvage shop, which had been selling parts off of it for a few years. Salvaged for rod knock rather than crash damage, and for $275, it's a good candidate for the electric conversion. Its aluminum frame is strong and light, and has room for batteries.

Purchased as-is!
With the engine removed and the frame stripped, it's ready for the next step - mounting a motor!

I've got to mount this 4.2 kW motor in the frame, getting the output shaft of the motor as close to the position of the original as possible.

It should sit about here?

I used the rear engine mounts in the frame to mount the motor. I cut and ground and filed 1/4 inch steel to make a mount to accommodate the motor. I bought an old drill press at a yard sale for this job.

I have very little welding experience and no welding equipment, but I was able to fit the bike in my car and my brother taught me how to use his gas-shielded MIG welder.
Pieces cut, prior to welding
Welded and painted!
If it looks good, it doesn't have to do anything, right?
The next step is to build and mount the motor controller. Controllers on the market cost >$300, so I'm hoping to make my own. I found a used 300 amp IGBT module on Ebay, and starting building the controller using copper plate as bus bars with Nippon capacitors across the power rail and a snubber capacitor across the IGBT. The module has two IGBTs in it, and I'm using the EMF protection diode of the second IGBT to control back EMF from the motor.

The capacitors were difficult to solder to the 1/8th inch copper plate, I had to use two soldering irons for enough heat capacity.
Bus Bars and capacitors mounted
With the controller quickly assembled, I tested it for the first time. I don't have a proper gate driver yet, so I'm just driving the IGBT from an IO pin. This test is using 12 volts only, this will be a 48 volt system.

Next is to build the gate driver, mount the IGBT driver in a waterproof box with a heatsink, and install batteries!

Tuesday, October 8, 2013

1500 km

I took 12 days off of work to go to Taiwan. After very little research I booked the trip, bought tickets, and applied for my passport. As the trip got closer I got more apprehensive - I can't speak a word of Chinese, I've never traveled on my own, I don't know the other people on the tour, I can't leave work for so long... let's just get it over with.

Milpitas, walk, bus, train, plane, bus, walk, Zhongli. Somewhere in that vague travel plan I left everything familiar behind.

All the bad photos were taken by me, with an iPhone.

All the good ones are taken by another guest on the tour, with a Nikon DSLR.

Waiting at SFO to board the Boeing 777
I arrived at the Kuva Chateau Hotel, the nicest in Zhongli (Jhongli/Jungli/Chungli, pinyin seems to be pretty *meh* close enough). I met the other people on the tour - apparently I'll like anyone else willing to go on the same adventures I am, the six other tour guests were all great people. One less thing to worry about!

View of Chungli from the 11th floor of Kuva
We bummed around a few hours waiting for the 5 PM tour start - our host, M13, sent a van to pick us up at the hotel and drive us to the motorcycle shop, where we rented our scooters.

Outside the motorcycle shop.
M moved to Taiwan from Canada 16 years ago. I won't say much about him since he'd like to remain fairly anonymous on the internet, but here's his youtube page (all my photos of him will be edited). We met him for the first time at the scooter shop. He's weird.

This was the first scooter I rode, a Yamaha Cygnus 150
After signing "you might be injured or die, don't sue" waivers, we got on our scooters (some of us for the first time) and bombed off into the night traffic, trying to keep up with M. We got gas, dinner, and headed back to the hotel.

The second day we toured around Chungli looking at temples and getting used to the scooters. We visited a racetrack (just watched) and someone's half-finished castle. We rode through a few (comparatively unimpressive) mountains to a street market, which was interesting.

This is us! The coolest scooter gang I saw.
Some temple in Chungli.
They were welding this together from several big sheets of metal.

This was at the race track. Renault, mid engine, 4 cylinder.
A fortune teller told this guy he could be king if he built a castle, so he did. He also ran out of money.
Street market.

Suspension bridge we didn't go across. I was impressed by these mountains at the time.

Riding a scooter in Taiwan isn't as bad as you might think. They're the dominant vehicle, and all cars and trucks are aware of them and use turn signals. You pass on the right shoulder and ride to the front of traffic lights to a scooter box. You generally don't look to your right or left, just signal and move over slowly. With that said - we didn't go slowly. All the scooters were modified with exhaust systems, fancy suspension, and Brembo brakes. Not fast compared to a motorcycle, but faster than all the other scooters and pretty loud. We certainly had a presence.

We visited an aboriginal festival. People in Taiwan love foreigners, we were dragged into lots of photographs.

The next day we woke at 5 AM to start our lap of the island. This was the longest riding day, most of the west coast of Taiwan.

400 years old.
I got to ride this a few hours. CPI is a Taiwanese brand. It was fun!
We finally arrived in Kaohsiung after 14 hours. I was tired and dirty. We only had the night in Kaohsiung, we saw the giant rubber duck, had dinner, and left the next morning.

In Kaohsiung
I'm happier than I look
View from Kaohsiung hotel the morning we left
The ride on this day was pretty short, we rode to Kending, which is a resort town and bit of a tourist trap. It was a Chinese holiday, so there were lots of people from the mainland visiting. We spent two nights in Kending, hiking and touring the amazing coast line. It rained the first night we were there, while we were hiking in a forest.

One of many gas stops.
Stopped on the coast for a while.
This town was walled for defense.
Hotel in Kending. It was a reproduction of traditional housing, but still pretty cool.

This cat was actually very friendly, he just didn't like M's dog.
Of course I climbed it! Now how do I get down...
By this time there were only 5 guests on the tour. Two dropped out for various reasons.

Us! Clockwise from top left, Danil (Russia), Me (USA), Doug (Quebec), Pasi (Finland), Stephan (Trinidad)
Don't tell me what I can and can not climb!
We left Kending and headed up the east coast. This side of Taiwan is much less populated and has amazing scenery. I switched scooters with another tour guest since his wasn't very comfortable. The Yamaha SMax 150 is FAST (for a scooter). It was faster than the 180cc and even had a "R" button that lit up and strobed when you opened the throttle (not sure if it did anything other than that). The Brembo brakes were amazing, it could stop on a dime with one finger. I rode this the rest of the trip, comfort be damned.

The SMax!
We ate at 7/11 a lot. They're every few blocks in Taiwan, and always have fresh food for cheap.

7/11 stop. BaoBao ate sausages (sassages?) the entire trip.
After a mountain pass I checked my rear tire - down to the cords! Must be all that SMax power... and also why it handled so poorly. We found a scooter shop and had both front and rear tires replaced. That's M's dog, BaoBao. 15 years old, but she rode with him the entire trip.


I would've had much more trouble replacing those tires myself.
Even after talking about scrubbing in new tires gently before doing anything stupid, I promptly slid the rear end out the moment we pulled away from the shop. Yes I'm an idiot, but didn't crash.

Not so good in the mud.

The next morning we headed up the east coast, passing over the tropic of cancer. We stopped in Hualian for the night. Not much to do in this city, though they did have a night market.

Tropic of Cancer

Hotel dog. Not so friendly.
Awake early again, and after a few hours up the coast we started inland, through and up the mountains. I was blown away by the scenery, which just got better and better. We went on the highest road in Taiwan, about 3,000 meters/10,000 feet elevation. All the scooters were fuel injected, but with the thin air we were crawling along at 25 km/h. I've never seen mountains so incredible.

The road was blasted through the mountains
Some people shouldn't take selfies

Waiting for roadwork. Exhausted, as usual.

We reached the peak. Breathtaking, indescribable, and impossible to photograph.
Actually Danil photographed it pretty well.

Probably my best photo from the trip. Climbed up a peak to get it, difficult to breath!

We rode back down the other side of the mountain (getting a little carried away on the twisty road) to our hotel in a mountain town, where we stayed for two days. We ate a lot, went to a horse show, and explored an incomplete and abandoned hotel across from ours.

Our hotel - modeled after English architecture?
Lobby dog.
I think it says it's the highest 7/11.

We woke up at 3:30 AM to ride back up the summit and see the sunrise. It was freezing, but worth it. Some of the local young people had the same idea, they played a game called "push someone on the ground and pretend to beat them up." They seemed to enjoy it.

Breathtaking, it can't be captured.

We headed out of the mountains. There was a typhoon coming in on the west coast, which we were riding back to. We were flying along the roads. The SMax scraped its center stand before using all the tire.

One last unexpected sight in the mountains
Sun Moon Lake. Amazing road.
Almost back to Chungli

We rode right to the scooter shop to return the scooters. It was a relief - 10 days, 1500 km, no crashes!
They take their scooters very seriously. This one had $25,000 of modifications.
We had one day left after completing the lap and returning the scooters. We took the HSR to visit Taipei, where M's friend Donny showed us around. We saw Taipei 101 and some other stuff.

Taipei 101 - we went up it.
Taipei 101 mall

Our last dinner together. Donny on the left, and Doug managed to not be in a lot of our group photos.

Before this trip, I thought I'd look forward to coming back home to the familiar. I didn't. I dreaded it! I checked out of the hotel and arrived back at home 24 hours later. I keep feeling joy for the amazing experience and sadness that it's over. Everything at home feels pointless, and compared to riding a scooter 1500 km over Taiwan, it IS pointless!

But I have hope - I can do whatever I want, and I want to do something else. There are so many other things to love!

Don't look so sad BaoBao... I have to come back!

1500 km! This scooter hit its top speed of 100 km/h at 10,000 RPM.