Hi,
First of all sorry to ask such a popular question regarding the esc and Arduino. I'm new with the Arduino and still trying to understand how these device works. My objectives are trying to control two bldc motors using two unidirectional esc 30A with Arduino Uno. Since I do not have any rc receiver yet, however, I manage to send the PWM signal (to duplicate the receiver's pulse signal) using two servo testers. Before going further, I measured the min. and max. pulse width signal from both testers using an oscilloscope and I obtained 916us (min) and 2106us (max). I'm using a Lipo battery 11.7V 5200mAH battery to power up both esc. The connections for both esc and servo testers are as follows. Sorry I do not have any schematic software installed in my computer.
Form the servo testers:
Servo tester 1 (signal pinout) to pin 3 (Arduino Uno); +5V supply taken out from Arduino +5V output pin.
Servo tester 2 (signal pinout) to pin 5 (Arduino Uno); +5V supply taken out from Arduino +5V output pin.
(both -ve inputs/outputs from servo testers are tied to Arduino's ground)
Form the ESCs:
ESC_R (signal pinout) to pin 9 (arduino uno)
ESC_L (signal pinout) to pin 10 (Arduino uno)
(both -ve outputs from esc are tied to Arduino's ground and +ve (5V) outputs are left unconnected).
For the Arduino dc power, I'm using usb port from the computer.
When done compiling and uploading the program, there was a beep...beep sound (probably the esc is armed) . However, the speed of the motors are way out of control. I'm expecting the output/ speed of the bldc motor at pin 9 & 10 can be controlled from the adjustments at pin 3 and 5.
Regards
type or paste code here
//Control two BLDC motor with two unidirectional ESC
#include <Servo.h>
#define Ch1 3 //Servo-tester#1
#define Ch2 5 //servo-tester#2
int Ch1Value, Ch2Value;
int mapCh1, mapCh2;
// Create Servo Objects as defined in the Servo.h files
Servo R_DCMotor; // Servo DC Motor Driver
Servo L_DCMotor; // Servo DC Motor Driver
//****************** Setup ************************************
void setup() {
pinMode(3, INPUT); //connect to the to servo_tester#1
pinMode(5, INPUT); //connect to the to servo_tester#2
pinMode(9, OUTPUT); //signal pin to ESC_BLDC#1
pinMode(10, OUTPUT); //signal pin to ESC_BLDC#2
R_DCMotor.attach(9); //Pin 9 to Sig ESC_BLDC#1
L_DCMotor.attach(10); //Pin 10 to Sig ESC_BLDC#2
// calibrate the esc
R_DCMotor.writeMicroseconds(1000);
L_DCMotor.writeMicroseconds(1000);
delay(7000);
R_DCMotor.writeMicroseconds(2000);
L_DCMotor.writeMicroseconds(2000);
delay(7000);
Serial.begin(9600);
}
//****************** Main Loop ********************************
void loop()
{
Ch1Value = pulseIn(3, HIGH); //calculate the HIGH pulse width
Ch2Value = pulseIn(5, HIGH); //calculate the HIGH pulse width
mapCh1 = map(Ch1Value,915,2106,1000,2000); //map from min.916us and max. 2106us pulse width to values between 1000us and 2000us
mapCh2 = map(Ch2Value,915,2106,1000,2000); //map from min.916us and max. 2106us pulse width to values between 1000us and 2000us
R_DCMotor.writeMicroseconds(mapCh1); //send pulse width value 1000us~2000us (Ch1Value) to pin 9
L_DCMotor.writeMicroseconds(mapCh2); //send pulse width value 1000us~2000us (Ch2Value) to pin 10
//**************** Display pulse width 1000-2000 us on serial monitor *****************************
Serial.print("Ch1: ");
Serial.println(mapCh1); //display ch1(pin 4) pulse width value 1000-2000us
Serial.print("Ch2: ");
Serial.println(mapCh2); //display ch2(pin 7) pulse width value 1000-2000us
Serial.println("");
}