Electric MTB

My electric MTB. I forgot to mount the battery pack for the photoshoot.

I’ve got a 6 km bike ride to work, the route is mostly flat but there is a high bridge I need to pass and the wind is not your friend when biking westward in Gothenburg. Despite this it is quicker for me to go by bike than public transport. The problem is that I do not want to be all sweaty when i arrive to work.

The solution: Put a motor on the bike

My bike is an Crescent Balder 24 speed mountain bike with front suspension and aluminum frame. Here in Sweden there are some regulations limiting an E-Bike to 250 W of power and a maximum speed of 25 km/h. That is not enough for me but I need a drive train that is possible to limit when driving on public roads.

After several hours of reading at the Endless Sphere forum I settled for a Nine Continents conversion kit including a 2809 rear wheel motor, 48 V 27 A motor controller, twist throttle, regeneration break handles and some other parts needed for the conversion. This kit has what is called an Infineon controller (based on the Infineon XC846 chip) and is programmable and possible to limit within legal limits.

E-Bike controller
E-Bike controller mounted behind the saddle

This is a 12 MOSFET version of the controller with a somewhat splash proof aluminum case that i mounted on a luggage rack from Biltema. One of the reasons that i choose the Nine Continents kit was that someone wrote on the web that it was one least bad china made E-bike kits regarding weather resistance.

E-Bike kit delivered
E-Bike kit delivered

The motor comes already laced in a 26″ rim and has mounts for disc brakes and a 7-speed freewheel, the only thing missing is a tire.

The 2809 means that the stator and magnets are 28 mm wide and each stator tooth have 9 turns of wire wound around it. There are different configurations of this motor, for example 2807 which have 7 turns wind resulting in a faster motor. The 2809 has a top speed of 35 km/h, on flat ground with 48 V battery voltage, which is enough for me. The slower speed means that the motor will be more efficient than the faster one at slow speed, for example uphill or with strong headwinds.

To power the motor I use Lithium Polymer (LiPo) batteries made for electric RC airplanes. At the moment I have 4 Turnigy 5000 mAh 6S 20C LiPo Pack batteries with 6 cells @ 5.0 Ah each. These are connected together as two 12s1p (12 cells in series and one paralell) packs like the one below.

Battery Module
One of my two 12S1P battery packs. These can be connected in parallel as well for a 12S2P pack. The serial wiring contains a 30A automotive fuse and a Anderson SB50 connector.

But the two packs can also be paralleled for a 12S2P pack with twice the range. The serial/paralell harness is made out of HXT 4mm Gold Connector for the battery, 10 AWG (~5,27 mm²) wire, a 30 A automotive fuse and a Andersson SB50 connector.

12 cells, at 3,7 V nominal voltage, in series results in a battery voltage of 44,4 V. 2 cells, of 5,0 Ah in parallel results in a total 44,4 V 10 Ah battery or 444 Wh of energy. My plan is to, at a later stage, extend this to 3 packs in parallel to 666 Wh of energy. Commuting to and from work with the bike has shown a energy usage of ~12-14 Wh/km. Mostly dependent on the amount of pedaling from me and wind speed/direction.

The battery specs say that they will deliver 20C continusly which means 20 times the capacity. My current battery with 10 Ah capacity will hence deliver a maximum of 200 A @ 44.4 V which is almost 9 kW of power.

There are a couple of different types of batteries used for electric bikes LiPo (which I use) has the highest power- and energy-density. The downside with LiPo is that they can be quite dangerous if you mistreat them, for example overcharge or puncture them in which case they will explode in a ball of fire. There are other lithium chemistrys for example LiFePo4 which are more stable but have lower energy density and much lower power density. There exists LiPo batteries that can deliver up to 90C while I haven’t seen LiFePo4 batteries capable of more than 10C. There are nickel and lead based batteries as well but they belong to the last century IMHO. Maybe I’ll write a more in-depth post about batteries, battery management and chargers in the future.

If you have any sort of experience repairing bicycles the install is easily made in a couple of hours, the most difficult thing was that the dropout has to be filed a little to suite the large axle on the hub motor. Since all torque from the motor is transfered through the dropouts the axle is 14 mm instead of the ordinary 10 mm bike wheel axle. The hub motor axle is flat on two sides making it fit in the 10 mm dropouts. Since the bend radius on the non-flat sides is 2 mm larger than on a regular bike wheel the frame dropouts has to be filed to a bend radius of 7 mm for a good fit.

Original dropout and axle to the left, hub motor dropout and axle to the right.

Since an aluminum frame is not as strong as a steel fram I decided to use what is called a torque arm to strengthen the dropouts. When using a hub motor that delivers a considerable amount of torque to the small flat sides of the wheel axle this is a must if the dropouts should survive. For example a powerful hub motor on an aluminum front fork without torque arm could end bad if the motor manage to twist itself out of the dropouts and the wheel comes loose. The rear wheel is probably less dangerous but I still don’t want the bike to break.

Torque arm
Torque arm. Note that the rear derailleur isn't used.

In the picture above you can see that there is no wire to the rear derailleur. The bike is originally a 24-speed bike but the hub motor only has room for 7 sprockets. Since the gear lever was mounted on the handbrake lever on this bike the rear 7 gears had to leave room for the regenerative brake lever supplied with the conversion kit making this a 3-speed bike. The left gear and handbrake lever is still intact controlling the front derailleur and brake.

I have used the bike to commute to work for a couple of months now and it works perfect. I have some future upgrades I want to make:

  • Move controller to water bottle mount
  • Replace phase wires to 12 gauge
  • Create fiberglass battery box
  • Tidy up cabling

This time of the year the weather in Gothenburg usually not invite to biking so I’ll have the winter to perform these upgrades on the bike.

Output voltage adjustment on 240W Kingpower charger

Kingpower 240 W charger
Kingpower Charger

I week ago i bought a bulk charger for my E-Bike, the idea is to use this to charge the battery fast and then once a week or so use a slower balancing charger to assure that the cells are in balance. I bought the charger from www.bmsbattery.com and they set it up for your requirements.


This is a pretty common china made charger sold at various places under different names. I have seen names link Ping-charger and King Pan charger as well as Kingpower.

The charger uses a CC/CV (Constant Current/Constant Voltage) charging algorithm and i requested the charger to have the current set to 4 A and the voltage 49V with an Anderson SB50 connector for the battery and an European wall outlet contact. They got the current and the high voltage connector right but the voltage were set to 48.8 V and the battery connector was an Andersson Power Pole instead. I had a spare SB50 connector so that one was easy to fix

48.8 V for a 12 cell battery will result in 4.07 V per cell. Since this charger doesn´t monitor each cell independently a safety margin is required but that is a bit to much. I was aiming at somewhere between 4,10 V and 4,15 V per cell. I needed to set the voltage to somewhere above 49 V.

Four screws on the sides held the lid on and after exposing the PCB i was faced with 3 potentiometers.

Charger voltage adjustment
Three potentiometers where the voltage setting is identified.

I would have guessed that there should be one for voltage and one for current. Two of the potentiometers were located next to the current shunt so I guessed that they were for setting the current. Maybe one is for coarse and one for fine adjustment, if anyone knows please leave a comment. The third potentiometer were located below the output fuse holder and that one was my first guess for output voltage. With the charger powered up and a voltmeter connected to the output I tried the last potentiometer and I was right. I adjusted output voltage to 49,5 V resulting in 4,125 V per cell.

Be extremely careful while touching the insides of the powered up charger with a metal screwdriver!!!

Some catching up to do

No posts for a couple of days since I’ve been busy with other things. As you may have noticed, to this point, I have only written about some old projects I’ve done in the past. There is some catching up to do but I will mix old projects with new stuff until all my old projects are well documented here (at least the interesting ones).

Here are a list of projects I will try to write all little about in the near future.

  • One more Depron RC aircraft. (SAAB J-35 Draken)
  • More about my quadrocopter
  • At least two electric bikes, one MTB and one Puch Maxi Moped conversion
  • Electronics for electric bikes, controller and motor modifications, BMU, DC/DC converter, LED-lights…
  • Mechanics for electric bikes, motor mount, battery box…
  • Maybe some pure programming projects for either Android, Windows or the web

Quadrocopter controller

Since my first control theory class at the university I’ve been thinking about building a quadrocopter. There are several “off the shelf” kits you can buy that handles stabilization of the quad, KKMulticopter being the most popular one. As usual I did not want to use anything someone else made so I started building my own controller. This post will focus on the electronics of this controller but there will be more posts later on about the controller software and the mechanic construction of the quad.

Starting by defining the requirements on the controller

  • 4 PWM inputs from the radio receiver
  • 4 PWM outputs to the ESC
  • Power supply from one ESC
  • Processor capable of handling floating point Kalman filter
  • 3-axis Accelerometer & Gyro sensors (digital)
  • Capable of flashing several LED
  • Capable of measuring battery voltage

The ESC (Electronic Speed Controller) is a controller for running 3-phase BLDC (BrushLess Direct Current) motors. It takes a standard RC radio PWM pulse as input and outputs a synchronous 3-phase trapezoidal voltage to the motor. Most ESC of the size used in this project includes a 5 V 2-3 A linear voltage regulator to power the receiver from the main battery. This power will be used to power the controller as well through a 3.3 V LDO regulator.

The three axis accelerometer and two axis of the gyro are needed to estimate the pitch and roll of the quadrocopter using a Kalman filter. The third axis of the gyro is used to implement a simple heading hold control loop.

Let’s just say that I’m more of a software, than electronics, guy. Electronics is really fun and interesting but I’m no professional. If someone sees any errors or strange things I’ve done in this design, please tell me and let me learn from this.

If i start with the processor, I have previously used the Microchip dsPIC line of processors and like them very much. They are easy to work with and the student version of the C30 compiler works fine for my needs. I had some dsPIC33FJ32MC204 laying around at home from an old projects and these have a motor control PWM module with 4 outputs and 4 input capture modules capable of reading the signal from the RC receiver. A simulation of the Kalman filter code I’ve written told me that performance wasn’t an issue either.

I used the Free Version of Eagle Layout Editor to draw up a schematic


And create a PCB layout from this schematic. The layout was adapted to a 50 mm x 50 mm pcb since I found the extremely cheap PCB manufacturer ITead Studio which could make 50 mm x 50 mm PCBs for less than $10. The layout used two layers and looked like this.

Top Layer
Top Layer
Bottom Layer
Bottom Layer

The sensors are from Sparkfun and mounted on breakout boards, since this is my first PCB order I played it safe and didn’t want to solder the extremely small packages of the sensors.

ADXL345 on breakout board
ADXL345 on breakout board
ITG3200 on breakout board
ITG3200 on breakout board

ITead Studios is based somewhere in China and it took several weeks to get the PCBs but when they arrived the all seemed to be of good quality

Quad PCB from ITead Studios
Quad PCB from ITead Studios

I have a couple of these boards left, contact me if you want one.

I used a toothpick to apply solder paste from dealextreme to the PCB, placed the components and heated with an ordinary soldering iron. Quite time consuming but I’m pretty sure that the end result was better than if I would have used ordinary solder. Not the prettiest soldering job but it was my first using this technique.

Quad PCB Top
Quad PCB Top
Quad PCB Bottom
Quad PCB Bottom

Now the “only” thing left to do is build the mechanical part of the quadrocopter and create the software. But I save that for another post…

Repair of Humax CXHD-1000 cable decoder

A couple of weeks ago our cable decoder decided to give up. There was no signs of life other than a couple of horizontal thin red lines on the display when the power were plugged in. I bought the decoder from the cable company ComHem when i registered for their services about three years ago.

Humax CXHD-1000
Humax CXHD-1000

A quick google told me that the warranty for these units were extended to 3 years because of problems with the power supply. This gave me some hope so I called the customer service at ComHem who told me that I ordered the box 3 years and 7 days ago, and there was nothing they could do about it. Instead they tried to get me to sign up for another year of their most expensive cable service, register for a broadband connection and buy a new decoder from them. I decided to try a repair instead.

Since the warranty already was out I happily ripped open the “warranty void” seals and opened up the box.

Humax CXHD-1000 Disassembled
Disassembled with the PSU removed

The design was modular and the PSU were easily removed with a couple of screws. Like all broken electronics, the first to look for is swollen capacitors. As you can see in the picture below there are one capacitor which definitely is swollen at the top and one that shows some signs of giving up. Is there someone selling capacitors with a timer that destroy them a couple of days after the warranty runs out?

Humax CXHD-1000 Power Supply
Power supply, note the bulging capacitors.

I decided to replace three of the capacitors that looked suspicious.

  • C101 – 2200 μF 10 V
  • C104 – 2200 μF 10 V
  • C106 – 1000 μF 16 V
Two of the capacitors are clearly swollen but I change all three just in case

I noticed that the decoder were broken when i got home from work so the local electronics shop were closed when I realized I needed new capacitors. Lucky enough i had some old ones, that I salvaged from a broken motherboard, with the right capacitance and voltage rating. Make sure that the capacitors used as replacement are good quality low-ESR capacitors.

Heating up the soldering iron and replacing these large through-hole-mounted parts were easy, and we didn’t have to endure an evening of analog television. The decoder has been working flawlessly ever since.

First try on depron RC aircrafts

This will be my first project post on this blog starting with something I made a year ago. A RC aircraft made out of depron.

Depron is a foam material intended for insulation and sound dampening of floors. I bought a 10-pack of 6 mm and a 10-pack of 3 mm at Hornbach, a local hardware store, which will be enough for several planes. At this store the foam was actually called Ebisol instead of Depron, but I guess those are just two different brands of the same stuff.

There are thousands of freely available plans for such a model only a google search away but I had to design my own. Some time behind a CAD program I ended up with this.

Final CAD model of depron aircraft
CAD drawing of depron aircraft

If I were to build this model again i would definitively make some changes to the plans. Some parts of the model were very hard to assemble due to their complex shapes.

A couple of evenings of assembly and some inspections from the chief engineer

Wing inspection
The chief engineer inspecting the wing construction

The model were done.

Foamie done
The aircraft is done, waiting for electronics to be installed
Topside done
Electronics installed
Ailerod servos installed
Aileron servos installed
Elevator servo
Elevator servo installed

Almost all parts I used for this were bought from Hobby King

Radio – Hobby King 2.4Ghz 6Ch Tx & Rx V2 (Mode 2)
Motor – Turnigy 2217 20turn 860kv 22A Outrunner
ESC – Hobbyking SS Series 25-30A ESC
Servos – HXT900 9g / 1.6kg / .12sec Micro Servo
Battery – Turnigy 2200mAh 3S 20C Lipo Pack
Horns & hinges – Plastic Parts Set 29pc (horn hinge)

Apart from this i bought some carbon rods and some piano wire from a local RC store.

The only thing left to do were the test flight

That was the end of that aircraft. I’ve heard people say that the center of gravity was off making the plane unstable. I believe Murphy was trying to teach me a lesson that I should try to walk before I run. Maybe I should have used one of the existing plans known to work with a well defined spot for center of gravity.

As I said this was a year ago. Two weeks ago I visited Aeroseum which is an aircraft museum here in Gothenburg. By now my emotional wounds, from seeing hours of work crashing to the ground, have healed and i feel ready to make a new try.

More about that in a future post…

Test post

This is a first test. Later on I will post about my DIY projects here.

Trying a little code: