Saturday, February 28, 2015

Assembling the Drive Unit

Over the last few weeks, and particularly this week of school vacation, I've put a lot of time into the bike and it's all coming together. What I'm calling the drive unit, the aluminum box to which the motor, jackshaft, pulleys, and controller mount to, is almost done. The assembly process is more complicated than I ever imagined, because each component blocks another from being installed, and so it took me a while to figure out the order to install them in. Although the CAD software helped me make sure everything actually fits, there is very little room inside for your hands to, say, tighten a screw. Tonight I needed to enlarge two of the holes with the drill press, and in order to have the drive unit sit flat, I had to almost completely disassemble it. An assembly guide like this is a good way to convey all the details that went into this design and construction, with the added benefit of being a reference for me and anyone who builds a bike based on mine to look back on. First, the end product.


To assemble the unit, you have to start with screwing the precharge button and the master switch onto the front of the box. They connect to each other with a JST-SM connector, which I use for all my signal connections, and are great except for the fact that they're not waterproof. The LED in the button is connected across the precharge resistor, so that it lights up in proportion to the current going through the power resistor. That is, it would light up when you first press it, and then fade as the controller's capacitor charges, except that I made the assumption that the button had a resistor built in for the LED, which it does not, and so it's burned out now.

Next come the bearings, which are mounted with #4 screws, instead of the #6 they were made for, to allow them to be aligned and make up for my inaccurate machining work.

After that, you install the intake fan, which blocks the switch from being removed. First you install the grill onto the output side of the fan, which keeps wires from getting in the blades, and then bolt the fan into the enclosure, with a filter to keep the dust and mud out.

The shaft goes through one bearing, you slip on the thrust bearings and shaft collars, and then you push it through the other bearing. I plan on adding wave washers to the sandwich to reduce the vibration of the thrust bearings. The shaft blocks some of the nuts on the fan, making that a pain to install or remove without removing the shaft. This is as far as I disassembled tonight, and so I should have pictures from here on down.




The negative wire gets routed between the fan and the enclosure wall, and then a piece of solid 22AWG wire is pulled through two holes in the aluminum and around the wires, keeping them in place and from touching the spinning outside of the motor. I just switched to the silicone jacketed wire from Hobbyking, and it's amazing. Extremely flexible due to it's hundreds of tiny strands, each of which is nickel plated to prevent corrosion, and the insulation is thick, similarly flexible, and rated for high temperatures. Seriously, I'm never going back to the terrible hardware store stuff again. It was surprisingly difficult to get the solder to flow through all the little strands, but the crimps came out strong.



After routing the wires, the first half of the HDPE clamps get attached, because the screws can't be inserted once the motor is in place.


Next, the motor. Can we take a moment to enjoy those beautiful copper windings?


It gets secured with a few Allen screws, which need to get replaced with flat heads and countersinked. I can't find my countersink bit, I think I have to get a new one. They're just so useful.


The brackets for the controller get attached with 4 #6 screws tapped into the box. Yes, I know the screws don't match, I didn't have enough pan heads.
Then the controller, which unfortunately covers the holes for the brackets, so removing the brackets is a two step process involving screws into the controller whose threads are barely holding. Aligning the brackets is even more of a pain.
I don't have a picture of the before, but the controller has very few of its original wires left on it. I opened it up and cut off all the wires I don't need at the circuit board, cut the power on and mode selection wires to an inch long and soldered them within the case, and replaced all the connectors on the wires I want with, from top to bottom, XT90 for the battery, 4mm gold plated bullet connectors for the motor, and JST-SM again for the throttle. The Hall Effect Sensor wires, which I don't need now but might later, were stripped of their connector, heat shrinked, and taped to the controller.

To protect the electronics from road spray, I used a 4" fence post cap to cover the bottom, with a hole in it for the wires to pass through.  I have to drill some more holes in this cap, to act as exhaust for the fan in order to route the air past the motor, and then cover them with a filter to keep the dust out. Unfortunately, there's not enough room between the top of the box and the bike's top tube to put a fence post cap on top, so I'll have to make a flat cover. The bottom cover is connected with 4 #6 screws, tapped into the aluminum. Did I mention I have come to love tapped holes? Not having to deal with nuts is amazing, particularly in situations like this where there is no way to hold them in place.
The final steps of assembling the drive unit are attaching the pulleys and sprocket. I got a #40 sprocket and chain when I should have gotten #410, so I'm waiting for the new one, and I still need to get the small pulley machined, but the large pulley attaches to the jackshaft with a a key and two set screws.
The drive unit fills the space inside the frame of the bicycle almost perfectly, and with some finagling, the other halves of the HDPE clamps fit over the screws to keep the drive unit in place. In theory, at least, because HDPE and painted aluminum are both very slick, and so I'm getting some grip tape to put over the seat tube to keep the drive unit from moving side to side.
  
That battery box is still precariously balanced on top of the bike rack, I'm going to bolt it down with wire rope clips. And I'm debating how to get the battery connections between the two boxes while keeping the waterproof seal on the battery box. The two options I can think of are bulkhead connectors, basically copper bolts that pass through the wall of the box that you can bolt wires to both sides, or a cord grip, basically a block of rubber with holes in it to waterproof the cables as they go through.

Although I haven't exactly been keeping to the schedule I set, the bike has been going surprisingly well. I hit a number of stumbling points where my plan didn't quite work out, but it feels almost done. I had a fun moment earlier today of sitting on the bike, gunning the throttle, and hearing the whine of the motor.

As far as what's left, there's just a few things. The big one is that I need to get the pulley machined. I also need that #410 sprocket, and a longer bottom bracket so that the chain doesn't hit the side of the drive unit. I need to secure the battery box to the bike, and then I should be able to ride it.

I'm probably going to have to build a belt tensioner, for which I have the design and the idler pulley, but I'm going to wait and see if it's necessary first. Lithium Ion batteries are probably in this bike's future, although the initial tests of the laptop cells are not looking too good. Freewheels on the crank and jackshaft would be nice, because they would allow me to motor without spinning the pedals, and pedal without spinning the motor, respectively, but like I've said about the batteries and many aspects of this project, I think I'm just going to get it working first.

I also recorded a video of me showing how to turn on the bike, and that the motor does in fact spin when I turn the throttle, but it came out shaky and the audio was poor. I'll try again tomorrow.

Monday, February 9, 2015

Batteries!

For a long time now, I've been trying to decide what kind of batteries to use on my bike. I started out with some old 12V, 7.2Ah batteries I pulled from UPSs at my Dad's office. They are heavy, can't supply very much power, and don't store very much charge, but you can't beat free.
I even got a plastic ammo can that fits them perfectly.

At one point, when I thought I had some money to spend, I made a spreadsheet comparing various kinds of batteries in terms of cost, range on my bike, and the most useful metric, $/Wh. You can always take smaller packs and put them together into a large battery pack, so it's not the cost that matters, but how much you're paying per unit of energy. It's also useful for comparing between different types of batteries. You can look at this spreadsheet here, or like almost all the document for this project, it's in the Google Drive folder linked in the sidebar.

Lead acid batteries, as I said above, are pretty poor batteries in almost every way, except that they are incredibly cheap. I won't get into the other kinds of lead acid batteries, but the most common sizes of sealed lead acid batteries are around $0.10/Wh.

Most home-built electric vehicles built now use Prismatic Lithium Ion cells, because they are very large (ranging in size from paperbacks to telephone books) and thus fewer are needed, making them easier to work with. They usually use Lithium Iron Phosphate (LiFePo4) based chemistries, because they are extremely stable and can't catch on fire unlike the other Li-on chemistries. The gold standard right now are the CALB CA cells, which are around $0.40/Wh.
Most commercially built electric vehicles use much smaller, cylindrical cells, such as the 18650, 26650, and 32600 batteries. They can store more energy in a smaller volume than the prismatic cells, the small size provides redundancy in case a few fail, and a number of other advantages in mass production of vehicles, such as easier cooling.The numbers refer to the physical size, for example an 18650, commonly used in laptop batteries and high end flashlights, is 18mm in diameter and 65mm long, which looks like a larger AA battery. The Tesla Model S, for example uses Panasonic NCR18650B cells, which cost $0.49/Wh in medium volumes. Some cylindrical cells, such as the very high quality LiFePo4 18650 cells made by A123, cost upwards of $2/Wh.
The NCR18650Bs I use in my flashlights
For the maximum amount of charge in a given volume and weight, the metal shell must be dropped. The batteries in our phones and many new, ultra-slim laptops are known as Lithium Polymer, or pouch cells, because they literally make the battery into a polymer gel and put it in a plastic pouch, making them lightweight, soft, and fragile. Depending on the chemistry, a sharp impact or puncture to a LiPo battery can easily start a fire. These, however, are the smallest, lightest, and most powerful batteries possible, which is why the remote control industry uses them almost exclusively now. The proliferation of this type of battery in phones, as well ass the explosion of the hobby industry and drones in the last few years, has caused prices to drop quickly. I made a Python program to scrape the Hobbyking website (the only decent place to buy LiPo) and find the cheapest batteries per watt hour, you can see the output spreadsheet over here. Someday I'll get around to to making a website so you can filter the results. I've seen prices as low as $0.32/Wh, including a protective housing, wiring, and connectors. If I went with LiPo batteries, I was going to buy six of these, for only $0.36/Wh.
You may have noticed that I said the cells used in the Tesla are the same as a laptop. And you've probably had an old computer whose battery life just went to zero one day. What you probably didn't know is that most of the cells in that battery were just fine. Most laptop batteries have 6 cells in them (3 in series, 2 in parallel, 3S2P), although a few are 9 (3S3P), or even more rarely, 8 (4S2P). When your battery stops holding a charge, it's really just the weakest of those six cells that won't work. It damages the one it's paired to and the other four are totally fine. And so what people do is open up the batteries, figure out which cells are any good, and then reuse them. This type of battery recycling is surprisingly easy, as long as you don't mind destroying the plastic enclosures that are glued shut around them. There are even factories making good money in China slapping a new label on these used cells and selling them as new (looking at you Ultra/Trust/Sure/UranusFire). You can buy old laptop batteries off of eBay for around $10 a piece, which if you assume you will get an average of 4 working cells at 2Ah a piece, is $0.34/Wh, about the same price as RC LiPo.
However, most people treat these as trash, a hazardous waste to be disposed of (even though they're not toxic, only flammable), instead of as a valuable asset. Of the two local computer stores I visited, one said they already have a contract to give all of their electronics waste to someone, and the other, Computers for Change in Burlington, was happy to give me both dead batteries they had on hand, and said they would bring more from their repair shop. For anyone else thinking of doing this, I should make a guide at some point, but every removable non-Apple laptop battery I've seen has 18650 cells in it. These laptop cells are optimized for energy, not power, by saving space with thinner plates for their electrodes, and so I need a lot of batteries just to get the bike working. I'm going to make a pack that is 10 cells in series, and a minimum of 10 cells in parallel. That's 100 cells or 25 laptop's worth just to get started, with the ultimate goal of around 200 cells. I really should make sure that'll fit in the box. Until I get to that 100 cell number, and have the materials I need to put the pack together, I'm going to keep using the lead acid.
Cracking open a Toshiba laptop battery.
Six Sanyo Cells 
Most of my laptop salvaged batteries
Up next, all the work I've done on the rest of the bike.