loading

Greetings fellow Instructables Readers,Makers,Geeks,Hobbyists,Electronics Enthusiasts and Beginners;

For quite some time now, I had been wanting to make a Wireless R/C car using Brushless Motors and Arduino.It was now that I got over with my school exams that I actually decided to make it.During the finalisation of the control method i was going to use in order to make the R/C car, I came across a problem:Controlling Brushless Motors With Arduino.

While controlling a (Technically) AC motor with Arduino seems a bit intimidating,worry not, since in this instructable,I am going to show you how easy it is to control a Brushless Motor Using Arduino using any kind of Switch/Potentiometer/Joystick, basically anything that can vary a parameter in such a way which can be recorded by the Arduino,whether its directly voltage or resistance.

Step 1: The Material Required

To Try This Project Yourself, you are going to require a few basic things:

(I have provided International Purchasing Links for most of the products I have used)

  • Brushless Motor(any will work, I have used a Generic 1000Kv Motor)
  • Brushless ESC(Make sure the ESC amp rating is 5-10amps more than that rated on the motor you will be controlling) LINK[Both Motor and ESC]
  • Arduino(Any flavor will work, I will be using the UNO) LINK
  • Battery(To power the Motor) LINK
  • Potentiometer or a Joystick (I will be using a my own soldered,gamepad style joystick) Get a premade one here: LINK
  • Jumper Cables LINK
  • Optional:Power source for the Arduino(I will be using the laptop to power the arduino)

You wll also require some basic tools:

  • Laptop with Arduino IDE(Sketch) Installed and Running
  • Arduino Programming USB Cable(USB A to USB B)

Once you get your materials in order,lets go ahead and Start our Project!

Step 2: The Connections (Hardware)

Before we jump in to write the code, first lets make the connections from the arduino to the ESC and the Motor.The connections for this project are fairly simple and straightforward.

Acoording to the code i have written,the connections are as follows:

The Out Pin From your Potentiometer/Joystick is connected to the analog Pin A0 on the Arduino.

The schematic for using the potentiometer and analog joystick is given.

(I am using self made joystick, the schematic for which is given)

The ESC to Arduino:

Black Wire(Ground)---> Ground Pin on the Arduino

White Wire(Signal)---> Digital Pin 10 on the Arduino

Red Wire(Power)-->Vin on the Arduino (This is to Power the Arduino)

The ESC to the Brushless Motor:

Just connect the three wires from the Brushless Motor to the ESC.The order does not matter.(In case the motor doesnt spin in the desired direction,just switch any of the two wires from the esc to the brushless motor)

Step 3: The Code

Now that the Hardware connections are done, we can work on the Arduino Code.The code is fairly simple and I have tried to explain the function of each and every line using comments.

However,if you run into any problem,feel free to contact me:

hrithikbansal70@gmail.com

hrithikbansal.com

The Code:(.ino file is also attached)

/*
ESC Calibrate ESC data pin attached to Digital Pin 10 on the arduino. A potentiometer/a Joystick input attached to Analog Pin A0 on the Arduino.

Compile and upload the code.Then hold the joystick/potentiometer at its max position and connect the external power source to the ESC. You will hear a few beeps then put the potentiometer/joystick in its lowest position.This will set the endpoints on the ESC.

This example code is in the public domain.

modified 20 March 2017 by Hrithik Bansal www.hrithikbansal.com */

#include <Servo.h> //Include The servo library for the functions used

Servo esc; //Declare the ESC as a Servo Object int input;

void setup() { esc.attach(10); //Attach the ESC to Digital Pin 10 Serial.begin(9600); //Begin Reading/Open Serial Monitor }

void loop() { input=analogRead(A0); //Value of input is analog input on pin A0 Serial.print("Original Input Value:"); //Serial print the original input value Serial.print(input); Serial.print(" | "); delay(1); input=map(analogRead(A0), 0, 1023, 0, 180); //Map the input values from the joystick on analog pin 0 to correspond to max and min values for the servo output: 180 and 0 Serial.print("Mapped Input Value:"); Serial.print(input); //Serial print the mapped input value Serial.print("\n"); delay(1); //Delay determines your resolution/smoothness and responsiveness of Motor to the movement of Potwntiometer/Joystick. esc.write(input); //The state of ESC will be the same as the state/position of Joystick

}

Step 4: Calibration and Testing

After you have uploaded the code to the arduino and rechecked all the hardware connection, plug in the battery to the ESC and then immediately reset the arduino(press the small reset button).Then immediately, put your potentiometer/joystick in either of the two extreme positions, this will be your high end point(where the motor will spin at the highest speed). You will again hear a few beeps,after which put the potentiometer/joystick fully towards the other/opposite end.This will be your low end point(the motor will be stationery at this point).Again, you will hear a few beeps and the calibration will have been done. {This has been demonstrated in the Video}

Demonstration of The Project:Video Link

Now, when you will move the potentiometer knob/analog joystick towards the upper/lower end point, the brushless motor will speed up/down accordingly.

Tip:While testing,tape down/secure the motor temporarily since the whole body of it spins(outrunner motor) and you won't be able to hold it in your hands,also it is dangerous.

While testing it out, the paper spinner accidently flew out as the motor was spinning very fast :p

If you run into any kind of problem, contact me:

hrithikbansal70gmail.com

hrithikbansal.com

I hope that this solves your problem and that you learnt something new today.

Thank You!

nice project and very nice instructable .tfs
Thank You!
<p>Is the thumping noise in the video when the motor starts up caused by the motor vibrating against the table? </p>
Yes, I didn't secure the motor well enough,which caused a lot of vibrations due to its high speed and thus made the thumping noise :p

About This Instructable

8,051views

124favorites

License:

More by hrithikbansal70:Controlling Brushless Motor With Arduino Hand Mimicking Robot DIY STOVE/WARMER 
Add instructable to: