Archive for the ‘Uncategorized’ Category


Android Bluetooth

Wednesday, July 28th, 2010

Once the Arduino board had a Bluetooth module attached, it was time to make it talk to another device.  We chose our Nexus Ones– Android 2.2 powered smart phones.  Briefly, prior to Android 2.0, Bluetooth support in the Android OS was really awful and generally not worth bothering with.  Even today, it’s still kind of weird.  Now with 2.2, it seems stable, but there are many programming pitfalls.

Although there are sample applications online to implement Bluetooth, it wasn’t easy and took several days of persistence to get it working reliably.  It’s quite easy to cause the application to lock up or crash.  You’re going to need multiple threads, so you’d better get used to that.  The Bluetooth read() function is blocking, so if you were to try and read using the same thread as your UI, the UI would appear unresponsive.  We wrote the application so that the main thread creates the UI.  This thread then spawns a communication thread which runs independently.

Managing the communications thread can be tricky.  After all sorts of experimentation, we realized that all we really needed were to handle the onResume and onPause events.  onResume fires whenever the phone wakes up (plus a big gotcha: also when the display changes orientation– though luckily you can turn this nuisance off in the manifest.xml).  onPause fires when it goes to sleep.

We set up the application so that onResume it creates the communication thread.  onPause, it stops it (both to conserve battery and because Android might shut the Bluetooth radio off on its own).

The communication thread searches all paired devices for the device with the name of our bluetooth module.  It gets its MAC address and then connects to it.  It then goes into a loop that reads data and uses inter thread to communication to send a string back to the UI thread.

The UI thread has a handler for accepting messages.  It parses the string it receives and updates the UI.

The communication thread also has a send() function which the buttons in the UI are programmed to use.

The last gotcha was that pairing & connection in Android can be weird.  Originally, we’d hard coded a MAC address into the program, and when the comm thread attempted to connect, the pair password box would sometimes appear, other times it would pop up under our application.  The only way to tell it was there was to look in the notification tray.  This wasted hours and hours of our time until we figured out the solution:  if the device isn’t paired correct already, forward the user to the built in Android OS Bluetooth settings screen with a pop up warning message to go pair from that screen.  When they’re done and they hit the back button, the application searches the list of paired devices again; if it finds it, it continues onwards.

High Level Home Automation Standards

Monday, May 3rd, 2010

For some time now, I’ve contemplated the possibilities of smarter home automation.  There’s a lot of focus on low level protocols for home automation– X10, ZigBee, etc.  These are often called “high level” protocols, which they sort of are from the point of view of, say, an electrical engineer.  But they’re not high level for a software architect point of view.

What I’m thinking about is something like DeviceNet for the PLCs used in manufacturing equipment, or  SNMP for networking equipment, or JMX for application servers.  These standards focus on exposing to management software various variables that are readable or configurable on each device.  With SNMP, applications can post statistics to the SNMP daemon running on a network router and then an administrator can monitor the device and adjust settings– all remotely from a unified console that monitors the whole network.

What seems to be happening so far is everyone has their own interface for each device.  I can see my PG&E smart meter settings if I log into the PG&E website.  I can see the settings for my Linksys router, if I go into that interface.  I can see how much power my server is using by walking over to the Kill-a-watt meter on the power strip and reading the display.  That’s fine for 3 devices, but as the number of smart devices grows, it’s not going to cut it.

Have I missed something?  Or is it time to brain storm ideas for the home automation projects I have in my head?

Maker Faire 2010

Thursday, April 29th, 2010

I’ll be at the Maker Faire Bay Area 2010.  More details available here.

Converting a Children’s Bike to a Folder

Sunday, June 21st, 2009

After looking at some tiny folding bikes like the Strida, I decided to spend an afternoon creating my own tiny folding bike. I had a 16″ wheeled kids bike from a garage sale. I figured all it needed was a heavy duty door hinge in the middle to fold in half and some seat and steering extentions.


The bike is a bit “springy” thanks to its old school thin walled steel construction


The biggest door hinge I could find

I have to give myself credit for the quality of work I did. I prepped all joints very well and the welding was of high quality. If only I had done some measurements before I got the tools out…

I welded a pipe on to the original seat tube to extend it. I ground the weld down, sanded it, and painted it all black. I also created a cool extention for the steering. I took the original handle bar clamp, which was designed to clamp a horizontal tube, cut it off, and welded it back on turned 90 degrees to clamp a vertical tube. I then welded another clamp in the usual orientation to a piece of pipe which I then stuck into vertical clamp. I placed the original handlebars into this extended tube.

The hinge was a bastard to weld on, and I create a strange jig to hold it all together while I welded, utilizing an old piece of furniture and the garage’s ceiling joists. I used the biggest door hinge I could find.

Then I decided to go for a ride. I was slightly alarmed when I got on the seat. The children’s seat post is maybe 3/4″ OD. When it is a foot long, it doesn’t flex much. But when it’s been extended by another two feet, it suddenly gets very springy. Banishing all fear of my weld breaking and a seat post violating my most prized organs, I set off down the driveway. The short wheelbase was a bit… “nervous”. I had a hard time tracking in a straight line. This drunken weaving might have been ok if the pedal to ground clearance was not so low, and not decreasing like it was because the hinge was bending apart. My oscillations became so wild that the pedals started to drag on the concrete. By the time I reached the end of the driveway, with neighbors looking at me like a madman, I was ready to give up. The bike took care of that however by throwing the chain. I was unceremoniously dumped into the street.

I remembered Billy Bob Thornton in Bad Santa. “Well, they can’t all be winners kid…”

Lithium Batteries and Generator Testing

Saturday, March 1st, 2008

I dropped by Halted and GreenEmotor. Allen Chen had a lithium battery pack ready for me, so I went home and tried to charge it. Unfortunately the charger blew up the moment I attached it to the battery pack. Not quite sure what happened there, so instead I took the pack of 8x 3.2v 12ah cells and charged them with the old UPS by charging 4 at a time. The lithium ion cells are rated at 3.2v, but they actually top off at about 3.9 or 4.0 volts, and some had dropped to 2.8 or so. I left these charging for several hours

March 2nd

I made some rough tests of the generator motor. They reveal a bit of a problem.

Pedaling Cadence (rpm) Current (A)
50 0
60 0
90 1
150 5
burst 10+

FYI, 60rpm is a nice leisurely pace. 90 is fast paced, while 150 is frantic. These results are not surprising. The battery voltage is 24v, so below that, there is no current flow. In some earlier testing, I was able to generate 36v by pedaling hard. That’s 12v at roughly 10a (actually a bit more, as the meter topped out at 10), or 120watts. Since the LWB recumbent took 350w of energy to travel at 25mph, and that was about as fast as I could go on it, that gives an efficiency of less than 50%. Not good, but not surprising.

First Test Ride!

Saturday, February 16th, 2008

I had about an hour before noon to work on the bike, so I put the batteries in the battery “boxes” (actually just the frame from an old UPS) and used a motor cycle tiedown to secure the batteries to the frame. I wired the motor up to the batteries. I used my dishwashing fluid covered chisel trick to remove the old, stuck handgrips and place the magura throttle on the bike. Now, it was totally operational. I took it out for a ride and found it works well! The hand grips are actually too high up and my arm gets tired operating the hand brake.

It’s a great feeling when a project works! and when it gets done quickly too!

The removable gym equipment seat makes accessing the batteries easy

The serial hybrid bicycle ready for its first test ride

After attending to some other chores, I returned to the bike for another hour or so. This time I decided to go all the way and get the generator rigged up. I bolted the motor plate down and attached a multimeter to the output. The output is actually “backwards” in relationship to the color of the leads. At full pedaling cadence, I could generate about 35 volts. Success! It was fairly easy to exceed 24 volts.

After some discussion on the Endless-Sphere forums, Fechter suggested the simplest arrangement would be to attach the generator in parallel with the batteries with a diode on the positive lead. The batteries would prevent the voltage from exceeding the safe levels for the motor controller. Fechter expected pedaling to be easy until output from the generator exceeded 24v.

Supercapacitors are horribly expensive and I didn’t feel like making a buck boost converter. So…

I grabbed a large diode and attached the generator to the batteries in parallel. I took the bike out for a spin and it behaves like Fechter predicted. Pedaling at low speed is easy, but at higher speeds the load increases, though not much. The point at which it gets harder to pedal depends on how hard the drive system is loaded. I tried going from a full stop to open throttle and also up hill. The effect of the generator is most noticeable at low speeds. Going up a steep hill, the 300w motor struggles to get the vehicle moving from a dead stop and pedaling helps.

The bike gets a lot of looks. Little kids loved it. It’s even funnier to sit at an intersection and pedal in place.

I’ll be traveling for work this coming week, but when I get back I plan to attach my bicycle computer and some other test equipment to figure out just how well this system works.

Not only did I finish the bike, but I got the ride around and enjoy the sunny day

First Recumbent Electrification: The Controller

Sunday, December 30th, 2007

So you’re looking at a stock Crystallyte controller. It’s $150. You’ve heard they blow their FETs easily. So, you think, “I can build one better.”

Maybe not, but I thought so. I thought I might be able to pull it off cheaper. If not, at least it would be worth the experience.

Well six months later I’m not quite done and I can tell you that it might be better, it was definitely not cheaper, and the jury is out on the experience :) I am still currently working out the bugs in the controller. The parts did indeed cost less than the controllers out there; but the trial and error of assembling it meant spending more. If you’re only going to build one or two, it’s not cost effective. It takes unusual requirements or volume to make it worth the effort.

Getting Started

The general idea is to use the Pulse Width Modulation features of a microcontroller to drive six MOSFETs attached to a brushless DC motor. This is the most practically efficient set up.

There is a wealth of information on the internet about using PWM to control motors. Just start Googling; you’ll find some simple explanations.

Since I have familiarity with the Atmel microcontrollers, I went with those. Atmel has several application notes for motor control that include code that makes getting started easy. I recommend AVR447, as this uses the cheap and commonly available ATMEGA88 and 168 (the note says it works on the ATMEGA48 too, but I could never load the included code into the small program space of that chip). Also, the notes are superior to some of the other examples. Unfortunately the source is written for an expensive commercial compiler; but editing it to work with AVR GCC is not too difficult. The greatest problem is in changing the syntax for storing arrays in flash memory into the format expected by AVR GCC, then using pgm_read_byte to read from flash memory (the commercial compiler is smart enough to automatically do the read for you). Also, the ISR names differ. I’d post the code here, but I’m not sure of the licensing.

AVR447 is based on using the Atmel motor control evaluation board. Since I haven’t got one, and anyway, it is built to drive a small fan motor, it would not work for us anyway. So we are on our own there.

But there are a lot of schematics you can find on Google too. Just search for “H bridge schematic.” An H bridge uses two MOSFETs linked end to end. The motor connects in between the two MOSFETs. One MOSFET is connected to supply positive, the other to ground. Control circuitry alternates which of the two is on. This alternation creates a wave that makes the motor spin. Many of the H bridge schematics use circuits with high parts counts. The easiest way to go is to find one that uses an integrated high/low side driver. International Rectifier makes a slew of these. Look for IRF2101 for example. You can substitute other chips, just make sure the logic input level matches your chip. On the supply side, all the chips seem to be rated up to 200V or 600V, so that should not be a problem. The only other differentiation among these chips that I can see is that some have inverting inputs. You can use these, but then your software must be written for it.

Here is a list of IRF hi/lo side driver parts: http://www.digchip.com/datasheets/parts/ir/parts_ir02.php

Get DIP package ICs if you can. These converters from SOIC to DIP cost $5 each. I clicked on the wrong item at Digikey…

First Recumbent Electrification: Batteries

Sunday, December 30th, 2007

You can really go off the deep end trying to investigate batteries. There are many choices, but they are often limited in many ways, so that making the ‘right’ decision is confusing. There are several popular routes for electric bikes.

Note: adding batteries in ’series’, meaning, connect the + of one battery to the – of another, then use the two unconnected terminals, adds their voltages. Connecting batteries in parallel adds their capacity together. This means connect the – terminals of each battery together and the + terminals, same as jump starting a car.

Discharge rate is how fast a battery is being discharged. This is usually written as a multiplier of ‘C’, the battery’s capacity. So if a 7 Amp hour battery is being discharged at 2C, then 14 Amps is being drawn from the battery.

Cycle life is how many times a battery can be discharged and then charged again.

Calendar life is how fast the batteries degrade over time, regardless of usage.

Life is usually rated in how many cycles or years it takes to drop to 80% of rated capacity.

Capacity is usually rated at the “C20” rate, or how much capacity is available if the battery is discharged over 20 hours. For vehicle applications, this means the rated capacity is usually optimistic, as the batteries get drained much faster. This is explained later in this document.

Depth of discharge or DOD is how much of a battery’s capacity is used before charging. Cycle life tends to drop really quickly after roughly 50% discharge. The Toyota Prius discharges its pack down to something like 40% to increase it’s life.

Here’s a quick rule: as of the summer of 2008, reasonably priced batteries cost $1 per watt-hour for about 700 cycles. I’ll explain this later in the document too.

Lets move on to battery types.

Lead Acid

Sealed Lead Acid batteries (SLA) are lead acid batteries that are sized about the same as motorcycle batteries. They are used in uninterruptable power supplies. They will not spill acid if turned upside down. Instead of being filled with liquid like a car battery, they are usually filled with gel. 12 Volt, 7.5Ah batteries can be had for $16-$20 from Mouser.com and some other sources. Four batteries will power a bicycle. However, they weigh about 20-30 pounds. They are easy to charge (just apply about 14 volts). If you connect the batteries to each other using connectors rather than permanently soldering them together, you can just use a car battery charger to charge each set of parallel cells. Normal car batteries have very poor cycle life and should not be used. Plus they are super heavy. You need deep cycle batteries.

Pros

  • Cheap (~$0.35 cents per Watt-hour)
  • Easy to create a battery pack and charge it

Cons

  • really heavy
  • cannot support high discharge rates (max is about 4C), so you need to carry more Amp hours of batteries to deal with acceleration and the extra weight
  • low cycle life (100-300 cycles)

Thoughts: appropriate for vehicles that are going to be heavy anyway or for those who want very low initial cost.

Nickel Metal Hydride

Nickel Metal Hydride rechargeable batteries are used in digital cameras and many other consumer goods. 1.2v 2.6Ah Sub C (slightly smaller than C cell) can be purchased for about $3 each. It takes about 30 of these cells to equal one 7.5Ah SLA battery. However, thanks to the weight savings and higher discharge rates that are possible, you won’t need as much spare capacity.

Pros

  • Much better performance than lead acid batteries
  • Light weight
  • Sub-Cs have high discharge rates (10C-20C)
  • Safe
  • Proven – NiMH cells have powered cars and consumer products for years and they keep on working. Hard to argue with that.

Cons

  • Charging in parallel is almost impossible. Each series string must be charged separately
  • Building the pack means connecting lots of small batteries together.
  • Costs just about as much as lithium, which has better performance

Thoughts: if you want rock solid reliability, probably your best choice. But you’ve got to deal with the packaging headaches.

Lithium Ion Cobalt

Lithium ion batteries are mostly used in laptops, but are also popular for newer RC vehicles. They’re also making it into some next generation hybrid cars. The nice thing about lithium ion cobalt cells is that they are usually rated for around 3.6v– so even though each cell costs between $5 and $10, you only need 1/3 as many as with NiMH to get the same voltage. Capacities are comparable with NiMH. Additionally, Lithium ion batteries allow much higher discharge rates.

Pros

  • high energy density (3.6+v per cell)
  • high discharge rates
  • light weight

Cons

  • melting laptop batteries anyone?
  • Older cells have a calendar life of 3 years or so
  • Cycle life is OK compared to NiMH (700-1400 cycles)
  • Expensive up front
  • Lithium ion cobalt cells are very sensitive to the conditions under which they are used. Their capacity drops with time. Additionally, if they are abused, the cells will turn into a resistor, heating up with use until they rupture. “Battery management” is required to monitor that the batteries won’t suddenly die. Charging is also more complicated.

Thoughts: unless you get a good deal on these, you might as well go with LiMn or LiFePO4.

Lithium Ion Manganese

Used in many power tool packs. Not as good as A123’s Lithium Iron Phosphate batteries performance wise.

Pros

  • Relatively stable – not as good as A123s, but pretty good
  • reasonable life – about 700 cycles
  • high energy density (3.2v/cell)
  • high discharge rate
  • light weight
  • much more reasonably priced than the A123s (about half the cost up front)
  • If you use the stock power tool chargers you won’t void the warranty on the batteries

Cons

  • still expensive up front
  • The best source is power tool battery packs, and you have to find them and then rip them apart, which is time consuming, or buy connector blocks if you want to maintain the warranty (which also means charging each pack separately, which can get annoying)

Thoughts: Good compromise choice. If Makita and Milwaukee have gone with these, they’re aren’t crap, but the new generation of tool packs is only a few years old, so we’ll see.

Lithium Iron Phosphate

The A123 LiFePo batteries are making quite a big splash. They are expensive when purchased alone, but can be obtained by buying DeWalt 36v power tool battery packs or Ping Battery packs on eBay.

Pros

  • Stable – they won’t catch on fire and they’re tolerant of abuse (eletrical and mechanical)
  • Long life – A123 claims 1000+ cycles
  • high energy density (3.2v/cell)
  • very high discharge rate
  • light weight

Cons

  • expensive up front
  • 3.2v is less than 3.7v– so you need more batteries to get the same voltage
  • The best source is DeWalt battery packs, and you have to find them and then rip them apart, which is time consuming

Thoughts: If you are after high performance and reliability, go with the A123s.

Other Lithium Ion Chemistries

There are quite a few other chemistries in existance. Use Wikipedia for more informatiom.

Lithium Polymer

These batteries are used mostly in RC airplanes and helicopters because they have very high energy density and discharge rates and are very expensive. If you have the money, you could power a bike with these.

Pros: the best performance you can get

Cons: can catch on fire with abuse. Very expensive!

First Recumbent Electrification: Theory

Sunday, December 30th, 2007

Lets design an electric bicycle.

Our bicycle will have a number of components:

  • the bike
  • an electric motor, linked to the wheels somehow
  • battery pack to provide power
  • motor controller to regulate how much power goes to the motor
  • Charger

Where do we start? We will start by calculating how much energy is needed to propel the bicycle. From there, we will know how much power we need to feed our motor. This will define requirements for our battery pack, which will help us design a battery pack. Because battery cell voltages and sizes are fairly standard, we’ll find that certain voltage motors will decrease the number of batteries we need. They will work better with our battery pack (this makes choosing the motor easier!). Our controller can then be chosen. We need to find one that can link our battery pack to the motor. With all this put together, choosing a charger mostly involves finding a suitably sized quality charger on the market.

Power Required to Propel Our Vehicle

The Power Output (Po) required by our vehicle is made up of four componenets:

  • Power to overcome aerodynamic drag
  • Power to overcome road drag
  • Power to overcome inertia (when accelerating)
  • Power to overcome gravity (when going uphill)

Go read this link, because it covers each part of the equation: link. I really like that page because it actually says what each term means! Can you believe it? If this revolutionary idea made its way into textbooks, maybe people would enjoy science, rather than feeling left behind… but anyway… Here’s another link that’s more theoretical but has a useful picture, and the beginning of this explains power and torque.

Note that the v3 term in the aerodynamic part of the equation grows much faster than any other term as velocity increases. This is why it is so important to have an aerodynamic vehicle. There are two main parts to the drag portion of the formula– coefficient of drag, which describes how aerodynamic the surface of our vehicle is, and frontal area. A Hummer, which has a drag coefficient half as great as a brick wall and a frontal area larger than most other cars, will get terrible mileage because at higher speeds it needs to output a lot of energy to overcome aerodynamic drag (at low speeds, it is heavy and the inertial term is large!). Compare the hummer to a jet airplane to understand the coefficient of drag. The jet is sleek and has nothing jutting out abruptly. Everything is smooth.

Now realize that we will actually need to input more power into this system. Why? Because we lose some energy in the drivetrain, some in the controller, and mostly, a chunk in motor efficiency. A survey of motor data sheets shows that motor efficiency falls between 70% and ~95%, with DC brushed motors being least efficient, brushless DC motors slightly more efficient, and 3 phase AC motors most efficient, though this is a vast simplification (small AC motors can be as inefficient as brushed DC motors). Controllers are roughly ~95% efficient, losing some energy as heat in the transistors that deliver power from the batteries to the motor. Drivetrains vary greatly. A simple chain drive is 98% efficient when clean and well maintained (Bicycle Science, 3rd ed, and one other source available online), whereas an automobile automatic transmission, because it has so many moving parts, can be quite a bit less. There are many other classifications of motors and some other technologies, but they are out of the scope of this work.

Batteries

Now with that worked out, lets talk about batteries.

Let me cover a little theory about batteries first. Batteries store energy. They are rated by their voltage (in volts) and capacity (in amp hours). Motor power is rated in watts, which is Volts x Amps. Note that the motor rating has no time component- there are no volt hours or amp hours in the equation. If you have a 12 volt battery that is rated at 10 Amp hours, it stores 120 Watt hours of energy. Hypothetically we could use 120 Watts of power from this battery for one hour, or 60 watts for two hours. It’s actually not this simple, but I’ll cover that later.

Now, you will probably be unable to find one battery that has both the right voltage and capacity to meet the needs of the vehicle. Luckily, we can link batteries together in two different configurations: series and parallel.

In a series connection, the negative terminal of one battery is connected to the positive terminal of another. The bike motor is then attached to the remaining terminals. In series, voltage adds. Two 12v 10ah batteries become a 24v 10ah battery.

In a parallel connection, the positive terminals are linked together and the negative terminals are linked together. The bike motor can be attached to either battery. In parallel, the capacity adds. Two 12v 10ah batteries become a 12v 20ah battery.

There is a short hand notation for the series-parallel arrangement. A 2p2s pack has 2 sets of batteries in parallel. Each set of batteries is made up of two cells in series. Some people write the shorthand backwards, i.e, 2s2p.

There are a number of battery chemistries out there, but Lead Acid, NiMH and NiCd, and Lithium Ion are the most popular. Lithium Ion describes several similar chemistries. For example there are lithium iron and lithium cobalt chemistries.

Lead acid batteries are used in today’s cars to start batteries, but they are heavy and do not store much energy. They also do not have long shelf life (how long they can be stored before they won’t charge) and cycle lives (the number of times they can be charged and discharged before they wont charge to more than than some percentage of their original capacity). They are, however, relatively cheap. You can find 6 volt, 12 volt, and 24 volt batteries at automotive stores.

NiMH batteries were used in production electric vehicles in the 90s. They have long life spans if not discharged too quickly or too ‘deeply.’ They are more expensive than lead acid batteries, and very expensive except in small sizes (like AA cells, C cells, etc) for numerous reasons, including a patent on ‘large format’ batteries. This means you have to link many batteries in series and parallel to get the desired voltage and capacity. The one difficulty there is that NiMH batteries don’t charge well in parallel. It works, but they need to be balanced periodically. This might be more effort than some people are willing to take.

Nickel Cadmium batteries are used in power tools and watches. They are similar to Nickel Metal Hydride batteries, but contain toxic cadmium. They’re getting a little harder to find these days, so the price for a cell varies widely.

Lithium Ion cells are even more expensive than NiMH, but a cell comparable to a AA NiMH has 3x the voltage of a NiMH cell. I will explain why this is important later. Lithium Ion cells suffer from one other problem– like lead acid cells, they degrade over time. The degredation depends on how hard the cells are used and the environmental conditions under which they are stored and used. Heat is bad, and laptop cells lose about 20% of their capacity per year. Tesla Motor’s water cooled Lithium Ion battery pack is projected to lose 30% capacity over five years. A lithium ion pack needs to be sized appropriately to account for this loss of capacity. Lithium Ion cells hold a lot of promise because of their widespread use in electronics. Many industries would greatly appreciate better lithium ion batteries. Oh, and they charge in parallel just fine. One additional note: the cases of ‘exploding’ lithium cells has to do with ‘abuse’ of the cells. When a battery starts failing, it becomes less a source of energy than a resistor. A resistor with current flowing through it heats up. Lithium cells generally do not like heat, it’s one of those environmental factors that decreases their life span. So when one possibly flakey cell starts to go bad, and a battery pack has no safety measures to shut down if excessively heated, that cell heats up, which heats up the other cells around it, which start to fail too, until a cell gets so hot that it ruptures. Simply adding a thermal cutoff prevents this situation from escalating.

Now that we’ve covered all that, let’s get onto the one nasty detail. Discharge current is measured in amps. Discharge rate is measured as a multiplier of the battery capacity (a number followed by the letter ‘C’). What does that mean? The 10ah battery from above, if discharged at 10 amps, is being discharged at a 1C rate. If it’s being discharged at 20 amps, then the discharge rate is 2C. This also applies for charging. A battery can be charged at 0.5C rate, or 2C, whatever.

Supposedly, an ideal 10 amp hour battery should also be able to provide 1 amp of current for 10 hours, or 10 amps for 1 hour. No. hours x Amps = Capacity then, right? But this is actually an approximation. Real life batteries are not ideal, and their useful capacity decreases with increasing discharge rate.

A German scientist named Peukert in the late 19th century devised an equation to express the actual capacity of a battery based on the discharge rate. You can read about it on Wikipedia. There’s a Peukert number for batteries. This number is an exponent in Peukert’s equation and it describes how far batteries deviate from this ideal when discharged. Go ahead and look up the data sheet for a NiMH AA cell. The manufacturer will state the capacity, and then an ‘apparent’ capacity when discharged at a certain rate. This apparent capacity is always lower. What this means is that when you work your batteries hard, they will discharge faster than you’d think. To minimize this problem, you can add more capacity to the system, use batteries that have a better Peukert number, or increase the voltage of the system. The latter works because remember power = voltage x current. If you keep the power requirement the same but raise the voltage, the amount of current you need drops– so for the same battery, the discharge rate is lower.

Lead acid batteries perform very poorly when discharged quickly. NiMH and NiCd allow higher discharge rates, but they are still not too great. Lithium Ion cells have the best Peukert number and can endure very high discharge rates. Expensive lithium polymer cells do even better.

The consequence of all this is that to make lead acid battery packs, you have to build in a lot of spare capacity. Since the cells are so heavy, this adds additional weight, which requires additional power to move, which means you need more power from the batteries, which means more batteries… the problem escalates.

NiMH and Lithium Ion cells are considerably lighter. Lithium ion cells, however, have almost 3x as much voltage per cell as NiMH. This means you need less of them overall if you build the pack right. However, they also cost more than 3x as much as NiMH cells.

To figure out which batteries to use, we need to consider the following factors:

  • Cost per Amp hour
  • highest practical system voltage
  • Cost/difficulty to charge
  • We can then determine a suitable pack size and its cost

One easy solution to the NiMH parallel charging problem is to charge each series set of cells with a separate charger. If our pack uses 20 cells in parallel, then we would need 20 chargers, which would be too expensive. If we use only four cells in parallel, having four chargers would probably be practical.

It’s tempting to increase the voltage up, up, and away because then Peukert’s Law has less effect. However, practically, 500V would be great, but we’ll never find a bicycle motor or a controller that uses 500v. Common motor ratings are 24v, 36v, and 48v. Some motors can be run over their rating, up to about 72v. So you’ll want to head for higher voltages, but make sure to weigh the cost of these components. If a 24V motor and controller costs $40, and a 48v costs $300, yes, you will have some savings by going to 48v, but could you get the same benefit by spending less than $250 on more batteries?

Controller

The most popular brand of controllers are manufactured by Crystalite. I believe these cost roughly $150. From what I have seen on the bike forums, these do NOT survive going up to 72v. To reach those voltages, you have to open the controller up and replace the transistors (MOSFETs) with models that can survive such voltages.

Kollmorgen 300W to 400W motors have a built in controller, but they must absolutely not exceed 24v.

Another consideration is whether the controller allows regenerative braking. This is when you let off the throttle and apply the brake– the motor is run ‘backwards’ and generates energy which it pumps back into the batteries. One other much simpler variation of this braking scheme does not charge the batteries (as this can be complicated) and instead dumps the energy into a coil of wire. The coil of wire resists the flow of energy, and heats up. In either case, you end up having a brake that doesn’t need to have pads adjusted or maintained. You can always make your own braking setup with a coil of wire, a permanent magnet motor controller, and a relay. The motor controller is wired up backwards– taking its input from the motor, and outputting to the coil of wire. The relay is necessary so that the braking controller and motor controller aren’t on at the same time.

Chargers

I haven’t quite gotten here yet.