How to run a brushless motor ESC with Arduino

Written by: admin@makezilla

Picture of How to run a brushless motor ESC with Arduino

This instructable will show you how to configure and run a brushless motor ESC with an arduino and run a brushless motor at different speeds. It will go through the materials, setup of hardware, and the software coding. It will explain what each step in the coding does. Don't get hurt and have fun!

Here is a video of the motors working.

 

Step 1: Obtain Your Materials

Picture of Obtain Your MaterialsIMG_2729.JPGIMG_2724 (1).JPGIMG_2725.JPGIMG_2730.JPGIMG_3376.JPG

You will need to get:

Arduino (Any will do, I used an Arduino Mega)

Computer with Arduino Coding program on it.

USB connector

ESC (Any will do, I used a generic brand at 30 AMPs)

A 10 AMP brushless motor,

Connector wires

Soldering iron w/ Solder

Battery (Any battery that is 12 volts, is 2 or more cells, I used a 3 cell 11.1 volt battery)

Step 2: Wiring and Hardware Setup

Picture of Wiring and Hardware SetupIMG_2732.JPGIMG_2726 (1).JPG

 Plug in the soldering iron to warm it up then line up the ESC with the motors wires (The ESC’s wires should have three of the same exact wires on one side, the other side is for the battery and Arduino)

Once the soldering iron is heated, put the motor control wires going out of the ESC together with the wires going out of the motor. The middle wires have to go together, but the 2 side wires can be switched to reverse the direction of the motor. Finally, you need to use the soldering iron to warm-up the wires, this should take about 5-10 seconds, then melt the solder on the wires to bond them together.

Take the input wire from the esc (The one that looks like a servo wire) and attach the ground to ground and the signal (white) to pin 9. The positive wire should be connected to vin ONLY if the arduino is not connected to the computer. If it is connected to the computer, do not attach the positive wire to anything or it will burn out your your computer

The thick red and black wires coming out the bottom should be connected to the battery.

Step 3: Software/Coding

- You will need to plug your arduino board into the computer with the USB connector first. Then, you can download the below program. After the program is downloaded, press the reset button on the arduino before plugging the battery into the ESC. The motor will make a start up noise, then it will wait. After a few seconds, the motor will beep 3 times and then gradually move to the speed programed. It will then gradually move back down to zero speed. You can edit the program for how fast the motors go and how long they stay on. Do not set the motors to a speed above 85% power or the ESC will burn out.

Code) 
//This code can be used for any purpose.

#include Servo ESC1;

int pos = 0; //Sets position variable

void arm(){

setSpeed(0); //Sets speed variable delay(1000);

}

void setSpeed(int speed){

int angle = map(speed, 0, 100, 0, 180); //Sets servo positions to different speeds ESC1.write(angle);

}

void setup() {

ESC1.attach(9); //Adds ESC to certain pin. arm();

}

void loop() {

int speed; //Implements speed variable

for(speed = 0; speed <= 70; speed += 5) { //Cycles speed up to 70% power for 1 second

setSpeed(speed); //Creates variable for speed to be used in in for loop

delay(1000);

}

delay(4000); //Stays on for 4 seconds

for(speed = 70; speed > 0; speed -= 5) { // Cycles speed down to 0% power for 1 second

setSpeed(speed); delay(1000);

}

setSpeed(0); //Sets speed variable to zero no matter what

delay(1000); //Turns off for 1 second

}

Leave a Reply