Hi Everyone,
In this work, we will give movement to our brushless dc motor using arduino. For doing this experiment we need:
- Brushless Dc Motor
- Electronic Speed Controller (ESC)
- Potentiometer
- Jumper Cables
- Power Supply (Feeding the motor)
- And of course Arduino
First of all we should do connections correctly, wrong connections gives problem for controlling the brushless dc motor. As a picture below we try to connect all cables, and also we should give power for electronic speed controller to control the brushless dc motor. If you do not give this voltage to ESC, motor also try to turning but this turning speed level depends on arduino 5 volt. Of course this is not effective.
If we handle the connections, lets begin to coding.
Open the Arduino IDE for write the control codes, firstly we will determines our constant values. Potentiometer pin will be A0 on analog pins on Arduino. Secondly electronic speed controller output digital pins marked as 9. In the void setup() part we define the input output situation as you can see on picture below.
In the void loop() part we will write main part of control mechanism, firstly reading the analog input on defined potentiometer pin. Secondly we should mapped this values for writing by esc. After this mapping, we are using analogWrite command.
Also giving the delay for clear control.
You can reach the code clearly :
const int potpin = A0;
const int escpin = 9;
int val;
void setup(){
pinMode(potpin, INPUT);
pinMode(escpin, OUTPUT);
}
void loop(){
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 179);
analogWrite(escpin,val);
delay(15);
}
Thanks a lot brother.....
ReplyDelete