web analytics
Arduino

Brushless DC Motor with Arduino

Controlling the Brushless DC Motor using Arduino it’s an easy process we will study ways to control the Brushless DC Motor. but it is necessary to know that the Arduino provides only 5 volts and 40mA so the motor will work but not efficiently!. So to solve this problem we use extra components called by Electronic Speed Controller (ESC). So we will build projects based on ESC we will build Brushless DC Motor Direct connection with potentiometer and connection with Ultrasonic Sensor.

Control Brushless DC Motor with ESC using Serial Monitor 

At first, we will learn how to connect the motor directly with the Arduino Board and ESC to control using Serial Monitor window, in this project we need these components as shown in the following table:

Component Number
Arduino UNO R3 1
Brushless DC Motor 1500 kv & 20A / 60 sec 1
Mini breadboard (optional) 1
Electronic Speed Controller (ESC) – GH-30A 1
Lipo Battery – 3s (11.1v) 1
Wires and Connectors 10

We will connect the Brushless DC Motor with the ESC piece so that the electrodes must be correct (if they are wrong the motor will rotate in the opposite direction) and we will connect the Lipo battery to the correct electrodes.

 

 

We will input ESC to the pin D11 PWM then user enter the readings from the serial monitor,  Then value 0 will generate 0% PWM and value 180 will generate 100% duty cycle. Any values above 180 will make nothing. So we use map the value from 0-180 by using the map function, Connections of Brushless DC Motor and ESC with Arduino UNO R3 it will be as follows:

Code

Make sure your connections are correct then connect Arduino with ESC and connect USB then upload this code to Arduino Uno board (Pin 11 PWM) or any board you own:

/* www.tocircuit.com
 Prepared by Fawzi Al-azraq 
 admin@tocircuit.com
 */
#include <Servo.h> //Use the Servo librarey
Servo ESC; //Here name of the DC motor
void setup()
{
ESC.attach(11); //Connect with 11 PWM Pin of Arduino
Serial.begin(9600);
while (! Serial);
Serial.println("Speed 0 to 180");
}
void loop()
{
if (Serial.available())
{
  
int throttle = Serial.println(); //Read the voltage signal from Serial monitor
if (throttle >= 0 && throttle <= 180)
{
}
ESC.write(throttle); //based on the value of throttle generate PWM signal
}
}

Brushless DC Motor & potentiometer

Potentiometer it is variable resistance but its value can be changed manually using knob since the increase of resistance will reduce the current, this piece is used for example in the control of the volume in radio, in our project we use to control the speed of Brushless DC Motor so This project needs Potentiometer. We will build a project to make the user enter the speed manually using the Potentiometer instead of the serial monitor.

 

 

We have to generate a PWM signal of a varying duty cycles from 0% to 100%. For 0% duty cycle the Potentiometer will output 0V (0) and for 100% duty cycle the Potentiometer will output 5V (1023). Here the Potentiometer is connected to pin A1, so we have to read the analog voltage from the Potentiometer by using the analog read function Then we have to convert the value from 0 to 1023 to 0 to 180. Connections of Brushless DC Motor, ESC and potentiometer with Arduino UNO R3:

Code

Make sure your connections are correct then connect Arduino with ESC (Pin 11 PWM) and Potentiometer  (Pin A1) then upload this code to Arduino Uno board  or any board you own:

/* www.tocircuit.com
 Prepared by Fawzi Al-azraq 
 admin@tocircuit.com
 */
 
#include <Servo.h>
Servo ESC; 

void setup()
{
ESC.attach(11); 
}

void loop()
{
int throttle = analogRead(A1); 
throttle = map(throttle, 0, 1023, 0, 180); 
ESC.write(throttle);
}

Brushless DC Motor & Ultrasonic Sensor

We previously studied and Ultrasonic sensor and learned about the principle of its work and how we use it to measure distance, now we will use this sensor with Brushless DC Motor (Good choice to design basic aircraft). We will make the motor speed (RPM) proportional to the distance so This project needs an Ultrasonic sensor. Connections of Brushless DC Motor, ESC, Ultrasonic sensor HC-SR04 with Arduino UNO R3:

Code

 We will connect the ultrasonic sensor to the digital input and output 12 and 13 we connect GND and 5V from the Arduino board and ESC to the pin D11 PWM. Make sure your connections are correct then connect Arduino with PC using USB then upload this code to Arduino Uno board or any board you own:

/* www.tocircuit.com
 Prepared by Fawzi Al-azraq 
 admin@tocircuit.com
 */
#include <Servo.h> //Servo librarey to support ESC

//First Defines pins numbers for trig & echo 
int trigPin = 13;
int echoPin = 12;

// now Defines variables
long duration;
int distance;

Servo ESC; //Here name of the DC motor

void setup()
{
  // here we defines output and input
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT); 

ESC.attach(11); //Generate PWM in pin 11 of Arduino
Serial.begin(9600); // Starts the serial communication
}

void loop()
{

digitalWrite(trigPin, LOW);
delayMicroseconds(3);

digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor

Serial.print("Distance is: ");
Serial.println(distance);

int throttle = distance; //Read the distance from Ultrasonic sensor
throttle = map(throttle, 100, 0, 1000, 1500); //Map works only from 0-180 so convert distance in cm to new map range
ESC.writeMicroseconds(throttle); 
}

Now you can add more motors, for example, to build a quad (Drone) aircraft without human control.


Leave a Reply

Your email address will not be published. Required fields are marked *

Adblock Detected

Please consider supporting us by disabling your ad blocker