How to Buy and Control Brushless Motor

by Simonexc in Circuits > Arduino

17135 Views, 217 Favorites, 0 Comments

How to Buy and Control Brushless Motor

whole project.JPG

If you would like to make your own rc plane or copter you have to learn how to control brushless motor. Most of work will ESC(Electronic Speed Control) do for us, but not all. Someone have to control ESC(I will use Arduino).

I used it to make plane but you can use it to whatever you want.

Ok, it seems easy. Let's get to work!

Parts List

whole project.JPG

All you need is:

Arduino(I use Nano),

brushless motor,

ESC,

battery(I use three 800mAh 3.7V Li-po connected in series),

potentiometer,

some wires,

wooden plank,

some screws

and propeller(optional).

How to Choose Wisely

motor.JPG
esc.JPG

Let's start by choosing motor(you can see some on HobbyKing). First, enviroment - where will you use it. If your robot(or drone) will be used inside use inrunner, but if it will be sed outside choose outrunner. Second, size(you can skip this if it doesn't matter but if you are making for example plane it's really important to look at it) - choose size proper to your requirements. Next, Kv(RPM/V) - rotates per volt. If you would like to make fast plane you should have about 2000 RPM/V or higher but if you would like to make a quad copter you should have lower than 1000 RPM/V(check some examples to match yours). Last one(but not least important), power - so how strong should your motor be. For copters your motor should have more power than for planes and of course for bigger planes it should have more power than for smaller.

Now if you choosed your motor go to its datasheet and check number of cells(there also you can check model weight). There you can check to how many li-po(or either type you use but I strongly recomend you to choose li-po battery) cells in series(I'll tell you more about batteries later) you can connect your motor. Check also what's your max current(in A) and choose a little bit bigger ESC(it's to avoid burn of your ESC). In ESC's datasheet check if number of celles is the same or bigger than in your motor(for example if you can connect your motor to 2-3 cells you can buy ESC which you can connect to 2-4 cells like I did).

OK. You've got motor and ESC, now batteries. You can buy whole battery pack or buy single cells and connect it together to create a pack(like I did). If you would like to buy pack you have to note some things. First, S - how many cells are connected in series. As I mentioned before you cann't connect as many cells in series as you want becouse it will burn your motor or ESC. So if you can connect your motor to 2-3 cells you have to buy 2S or 3S battery pack. Second, capacity(mAh) - in really big shortcut it's time of flight. If you get bigger(more capacity) batteries you will fly longer. To estimate which capacity is the best multiply average motor current by flight time in hours. Also check the letter C. In batteries datasheet there is number and after that big letter C. It means how much bigger current you can take from li-po batteries. For example if current(current = capacity/time) of your battery is 1000mA and there is 20C that means you can take from this battery 1 000mA * 20 = 20 000mA = 20A. So you can connect motor which it's max current is equal or lower than 20A.

If you didn't choosed battery pack and you have to make one. Buy as many cells as you need(for this example I use 1S cells but you can do this with whole packs) and connect it in series and by that I mean plus(anode, red wire) to other battery minus(cathode, black wire). Now you've greate a pack. It has S as many as you have cells(S is the number of cells), capacity and C is identical as single cell, so if one cell has 1000mAh 20C whole pack has 1000mAh 20C, but voltage is equal single cell voltage(about 3.7V but it could be lower or higher - if you fully charge it its voltage increase to about 4.2V and under load(if you connect to it motor) it would decrease to 3V) * number of cells(you can mesure it using voltmeter). Now you can calculate max rpm: Kv(RPM/V) * voltage. Remeber - if you connect batteries in series capacity stay the same but voltage increase. If you want to increase capacity you should connect batteries parallel. Connect whole pack's(or single cell) minus to other pack's minus and plus to other pack's plus. Now capacity will be equal pack's(or single cell) capacity * number of packs. IMPORTANT: capacity and voltage of all packs that you connect in parralel should be the same. Now if you connect it in parallel capacity increases but voltage stay the same as in single pack. OK, let's connect it together.

Wiring

bldc motor diagram.png
esc-motor wires.JPG
batteries.JPG
motor mounting.JPG

First connect your motor to ESC. From motor goes three wires: black, red and middle yellow(or other color), and from ESC goes three thick wires but the same color. Connect(using special connector or just solder) middle one from ESC to middle one from motor. Two left is to change direction of motion so you have to experiment with it(if you have propeller) to switch it to right direction. So motor is connected to ESC. Now let's connect Arduino.

Because I'm using Arduino Nano it's easier for me to use breadboard and plug Arduino into it but you don't have to use breadboard(it's just easier). Now as on diagram connect potentiometer to your Arduino: middle pin to A0, and to left to GND and +5V(order doesn't matter). OK, now ESC connection. You control ESC using thin wires much like servo(if you didn't use servo try to play with it a little bit, here is good instructable for it). So as on diagram connect yellow(or white) pin to any PWM pin on Arduino and black(or brown) pin to GND. Middle(red) pin is NOT CONNECTED to Arduino(not like on diagram) if Arduino is connected to computer. Some says that it could destroy your USB port. I didn't check this and I don't encourage you to check this. You should connect this pin to VIN as power supply only if Arduino is not connected to computer. But now don't connect it because soon you'll have to send program to Arduino.

Now you have to get connector to your battery pack to easily connect and disconnect your battery pack. If you've got one connect its wires to power wires from ESC(red and black) and connect as normal - red to red and black to black. If you bought battery pack to cut off power supply to motor(it could be useful in some situations) just disconnect whole pack but if you made it(I assume that you didn't done any parallel connections. If you done it I suggest you to connect switch to easily cut off power) you have to disconnect just one cell and it will open circuit.

Now attach holder(should be included with motor) to motor and attach it to wooden plank.

One WARNING: if you do it for first time don't attach propeller to motor. It could be dangerous. Motor would sometimes turn on unexpectedly. Always if you connect motor to power hold wooden plank motor to avoid overturn of motor and don't touch the motor while there is power supply connected to it.

Coding

Controlling brushless motor

Now let's go to code. If you looked at this you now that we will control ESC by PWM. If you controlled servo you probably used function write(angle) and servo rotates to writen angle. So if you write for example write(0) you actualy send pulse which width is 1ms so 1000us(micro seconds). To do the same work you can use writeMicroseconds(pulse width in microseconds). It's easier to understand in this use. So instead of setting angle you set RPM(rotates per minute). Great tutorial about ESC is here. It's really great but it didn't worked for me. So what's now? You have to do it manually. Read your ESC manual and see what signals send from your ESC means. I don't know how it's with your but my ESC is read when there's starting melody like on video or 1 2 3 and high tone(where 1 is low frequency tone, 2 higher and 3 higher than 2, last high tone is higher and longer than 3). If something is wrong last tone is the same as 3. There you can also reprogram it(I didn't done this but you can if you want). In my ESC I had to write high signal for more than 2 secs. OK. Download my code(now you set ESC, not use - it might be confusing but I couldn't invent something smarter :), set everything as in comments and send it to Arduino. Open Serial Monitor. Now you have to set throttle. Move potentiometer to the highest position that on Serial Monitor you will see 2000. Now turn on power supply. You should hear wrong melody. Go back to 1000 and you should hear right melody(if it doesn't work disconnect power and go back to 2000 and repeat process, try go faster to 1000 or slower until you hear right melody). Now you set throttle(you can change it later in the same way) but watch out! If you move potentiometer up motor will start rotating. You can play a little bit with it. Now you can go to using ESC and change properly code. Now you will see RPM in %.

That's the end. Hope you run your motor :) Soon I'll end my RC plane and I'll make an instructable about it.

Hope to see you soon,

Simonexc