When experimenting or using parts from different sources, we frequently find the color codes on brushless motors and controllers do not correspond correctly. Just because the right colors are present does not mean they will match correctly, though that would be a good first guess.

Most brushless motors used on bikes, scooter, and motorcycles have 3 phase wires (the fat ones that take the power) and 5 hall sensor wires (the skinny ones). Some motors may also have a temperature sensor or shaft speed encoder (more wires).

The problem is how to determine which wire goes where without blowing anything up...

Motor Wires 3.jpg (65 KiB) Viewed 64953 times

If full power is applied to the controller and the wires are not properly connected, there is a very good chance of destroying the motor, controller or both.

There are typically 3 hall sensors in the motor that tell the controller the position of the rotor.
Each sensor has a + and - power lead and a signal output. The first thing to sort out is the hall sensor power. The controller will supply a votage to the sensors that is typically between 5v and 12v. The most common color coding for the hall power is red= positive, black= ground.

If there are no black and red wires, or it is not clear which are the power wires, it may be necessary to open the motor and trace the wires going to the hall sensors. The hall supply wires will branch off and go to all three sensors. If + and - are not black and red, then it may be necessary to look up the datasheet for the hall sensor to determine the power connections.

Here is the most common style of hall sensor used in motors. This one is a Crystalyte:

HallSensor.jpg (30.69 KiB) Viewed 64834 times

Here's what the hall sensors look like in a Kollmorgen motor:

Kollmorgen hall and phase wires.jpg (64.39 KiB) Viewed 64930 times

Now, once the hall supply wires are sorted out, it's a matter of matching the phase and signal wires. If the colors of the remaining wires seem to match, that would be the obvious first try.

When testing unknown wiring combinations, it is important to somehow limit the current that the controller can get during testing. If one wire is out of place, the current in the controller could be very high and cause the controller to blow. Testing with the batteries connected to directly to the controller is very risky.

The best approach is to use a bench power supply capable of enough current to run the motor at no load. This is the one I like to use:

Power Supply.JPG (153.83 KiB) Viewed 64831 times

If you do not have access to fancy, expensive test equipment, then you should put something in series with the batteries to limit the current, but still allow enough to run the motor at no load without tripping the low voltage cutout on the controller. At no load (wheel off the ground), most bike motors will draw around 2 amps or less. Larger motors may be up to 5 amps or more.

You could use a 5 amp fuse or circuit breaker if you have nothing else. A large resistor, like a car headlamp may suffice in a pinch.

You also need to measure the battery current while testing. This is very important, since you want to back off the throttle immediately if the current starts going too high, and it's about the only way to tell when you have the right wiring combination.

For the 3 phase wires, there are 6 possible combinations of wiring to the controller. It is good to use a piece of paper to write down the combinations so you can keep track of which ones have been tried. For each phase combination, there are 6 possible hall signal combinations. This gives a total of 36 possible configurations that may need to be tested.

If we label the motor wires A, B, and C and the controller wires Y (yellow), G (green) and B (blue), the combination table looks like this:

Phase combinations.jpg (16.5 KiB) Viewed 64796 times

For each attempted combination, apply power and slowly advance the throttle while watching the current.

Incorrect combinations will have different effects depending on the combination.
Some combinations will result in the motor vibrating or not moving, but the current rises rapidly with throttle... bad.

Some combinations will result in the motor running, but the current will become excessive at higher speeds... bad.

Some combinations will result in the motor running backward... bad.

When you get the right combination, the motor will start from any position, run forward and the no-load current will be in the 'expected' range.

Be very careful when swapping the hall signal wires around. If a hall signal wire makes contact with the hall supply, there is a good chance of blowing the hall sensor. Best disconnect all power before swapping wires.

When swapping wires around, I found it very handy to use a barrier strip terminal block to hold the wires. In this setup, I used some connector pins from a serial connector to make swapping even quicker.

So you just received a new controller and need help wiring it up.
Here is my procedure for installing a controller on any BLDC motor.

Installation Tip:
The colors of BLDC motors, controllers, throttles and e-brakes may not always match up.
There is no industry standard for matching the wire colors. A real 'pain-in-the-neck' but a reality.
This may seem confusing at first but it is very easy to find the correct combination.
I created a xls spreadsheet to assist you in finding the correct wire combination. http://endless-sphere.com/forums/downlo ... p?id=11560

Safety:
When testing your controller, use a low amperage fuse (2 or 3 amp) on the positive (+) power supply lead.
For INFINEON controllers, the low voltage cutoff (LVC) will be set for a specific battery voltage. You must test your wiring with a (nominal) power supply GREATER than the LVC or the controller will not work.
Always use great care when working with the power supply (batteries and/or chargers).
Test your controller with your motor "no load" (motor/wheel off the ground and free to spin easily).

NOTE:
You may need to try all thirty-six combinations in the spreadsheet to be sure you have the correct hall and phase wire configuration.

For Direct Drive BLDC motors, at least one of these thirty-six combinations will produce a Ã¢â‚¬Å“smoothÃ¢â‚¬Â forward motor rotation (and another one of these thirty-six combinations will produce a smooth reverse motor rotation).

For Geared BLDC motor (with an internal freewheel), at least one of these thirty-six combinations will produce a Ã¢â‚¬Å“smoothÃ¢â‚¬Â forward motor rotation (geared motors with an internal freewheel will not spin the hub in reverse).

When you find a wiring combination that produces a "smooth" rotation is in the "forward" direction then you are done testing and can keep this configuration.

If the "smooth" rotation is in the "backward" direction then switch 2 hall wires (move to the next column in spreadsheet). Then try the six possible phase wire combinations in the next column of the spreadsheet.

Most of the Hall/Phase wire combinations will produce no rotation at all and some combinations will produce "rough" rotation in either the forward or reverse directions.

IMPORTANT: A correct Hall/Phase wire combination will run very smooth and draw very little current (1 or 2 amps) under no-load testing. A wrong Hall/Phase wire combination will generally run very rough and draw much higher current under no-load testing. Using the wrong wiring combo under a full load (on the road) can and will damage the controller and/or your motor.

Although this may sound complicated, it really is not so bad.
Take your time and try all 36 hall-phase wire combinations in spreadsheet until you are satisfied you have it correct.
Here is a completed spreadsheet example for a 'mystery motor' of unknown origin ... http://98.131.176.65/endless-sphere/Pha ... ations.xls

Once you are satisfied you can 'hard wire' the controller and begin to enjoy it.

Here is a completed spreadsheet for the Bafang Motor and the Schenzhen (Infineon) Controller.

Here's a little test gadget you can build to test hall sensors. This should work with virtually any brushless motor that uses hall sensors. It will tell you if all the sensors are working properly, and whether your motor has 60deg. or 120deg. hall spacing. This connects directly to the motor, with the controller disconnected. The resistor values are not critical and pretty much any LEDs will work.

Hall Sensor Tester.jpg (17.42 KiB) Viewed 64021 times

Joey built one on a small piece of perforated board and used test hooks. If you have a mating connector for your motor's sensors, you could use that also. Nice job Joey..

Hall_Sensor_Tester.jpg (40.06 KiB) Viewed 63892 times

With the tester attached, slowly rotate the motor and you should see each LED blink on and off. If any LED does not blink, there is a problem.

If there are some positions where all 3 are lit and some positions where all 3 are off, your motor has 60 degree spacing. If there is a maximum of 2 on or off at any time, then your motor has 120 degree spacing.

Now the next step is to figure out how to use the tester to eliminate the trial and error guesswork...