Brushless Motor Control

Hi all,
I am new to the forums and have a quick question. I have been doing some research and forum searching but have not been able to find an answer to my problem.

Right now i am attempting to interface a Brushless motor to an ESC which will be controlled by an arduino micro controller. I am using the PWM pins on my arduino mega to send a 1ms to 2ms signal to my ESC to attempt to control the motor. I go through the throttle ranging appropriately, get all the necessary beeps and then i attempt to run the motor say at quarter speed and all that happens is the motor wabbles back and forth and sadly some smoke comes out. Is this a problem with my code or something else. Any help would be appreciated my code is below:

#include <Servo.h>

Servo motor1;
char throttleUp;
char throttleDown;
int  maxThrottle=2000;
int quarterThrottle=1250;
int halfThrottle=1500;
int tquarterThrottle=1750;
int minThrottle=1000;
int currentThrottle;
char input;


void setup() {
  motor1.attach(10);
  Serial.begin(9600);
  currentThrottle=minThrottle;
  Serial.println("Use I to Throttle Up and K to Throttle Down");
  
}

void loop() {
  // put your main code here, to run repeatedly: 

  while (Serial.available() == 0){delay(10);}
  while (Serial.available() > 0){
      input = Serial.read();
     if(input == 'i' && currentThrottle <=1950){
         currentThrottle=currentThrottle+50;
         motor1.writeMicroseconds(currentThrottle);
         Serial.println(currentThrottle);}
     if(input == 'k' && currentThrottle >=1050){
         currentThrottle=currentThrottle-50;
         motor1.writeMicroseconds(currentThrottle);
         Serial.println(currentThrottle);}
     /*if(input == 'a'){
       Serial.println("Throttle Adjustment will start in 3 seconds, Disconnect throttle wire and apply power to ESC, press n for next");
       while(input != 'n'){
         input = Serial.read();
       }
           Serial.println("Attach PWM signal to ESC");
           Serial.println("Max Throttle");
           motor1.writeMicroseconds(maxThrottle);
           delay(5000);
           Serial.println("Min Throttle");
           motor1.writeMicroseconds(minThrottle);}
           delay(2000);
           Serial.println("done");
         
         }*/
      if(input == 'a'){
         motor1.writeMicroseconds(minThrottle);
         Serial.println("Min Throttle");}
      if(input == 's'){ 
         motor1.writeMicroseconds(quarterThrottle);
         Serial.println("25% Throttle");}
      if(input == 'd'){
         motor1.writeMicroseconds(halfThrottle);
         Serial.println("50% Throttle");}
      if(input == 'f'){ 
         motor1.writeMicroseconds(tquarterThrottle);
         Serial.println("75% Throttle");}   
      if(input == 'g'){ 
         motor1.writeMicroseconds(maxThrottle);
         Serial.println("Max Throttle");} 
     }
}

past post

https://www.google.com/search?hl=en&as_q=esc&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Farduino.cc%2Fforum&as_occt=any&safe=off&tbs=&as_filetype=&as_rights=

Hi zoomkat i am not sure if that is the complete link as it ends with "rights="

Yes, it's a complete link.

Then i am confused as to which post he is referring to from that search.

Now that the smoke has left your motor, it may be beyond help anyway.

Do you have some standard RC Equipment to check your motor/ESC with ?

Duane B

rcarduino.blogspot.com

Yea thats what i was afraid of, as i do not wanna test another motor with bad programming and kill that one as well. I dont currently have standard RC equipment to check the motor/ESC with. Is there any other test methods say using an oscilloscope?

Hi,

Connecting the ESC to your Arduino and the servo library is unlikely to harm it, it is more likely something wrong in your circuit which an oscilliscope will not help with.

One test you can do it to use a servo instead of an ESC, its going to be cheaper to replace and accepts the same commands - just gives different results, left and right instead of forwards and reverse.

Duane B

rcarduino.blogspot.com

If you only connect 2 of the 3 windings of a BLDC to an ESC, it usually burns out. You must use very low resistance connectors as the peak currents are large - one dodgy connection to one of the windings and same failure mode.

Sometimes cheap ESCs explode anyway - smoking from the motor means a winding has cooked, it may still work (to some extent!). Measure the interwinding resistances accurately to check they are the same (you'll need to put say 100mA through each winding and measure the voltage).

Then i am confused as to which post he is referring to from that search.

The intent is for you to actually start reading post similar to yours and doing some independent learning.

ahhh yea zoomkat if you actually read my post i said i had already done research into this and the reason i made a post was cause well i couldnt find what i was looking for. so thanks for your consideration but if you have nothing to contribute please dont post. Thanks.

wondahbread: ahhh yea zoomkat if you actually read my post i said i had already done research into this and the reason i made a post was cause well i couldnt find what i was looking for. so thanks for your consideration but if you have nothing to contribute please dont post. Thanks.

Well, if " sadly some smoke comes out" is true, you are correct that I don't have much to add.

again your post has no information to help me towards my problem and is unwelcome. I came on here looking for some ideas to a possible answer of a problem i have and got the stupid answer of do a search. I am looking for some actual information which Duane and Mark have helped give me a couple of ideas to continue testing which i appreciate. to them i say thank you.

Just wanted to say i figured out my problem, it turns out the ESC i had was burnt out, after taking a look at its signal this weekend on an Oscope, i could clearly see that it was an erratic incorrect looking sinusoidal wave. Using another ESC i was able to get the correct sinusoidal wave and operate the motors with my posted code. Thanks for the help.

ESCs don't output a sinusoid - perhaps you saw the trapezoidal waveform that results from the combination of output drive and back-EMF during the idle phases.

Figure 3 in here shows the normal BLDC drive waveforms: http://e2e.ti.com/cfs-file.ashx/__key/telligent-evolution-components-attachments/00-171-01-00-00-14-23-21/Trapezoidal-Control-of-BLDC-Motors-Using-Hall-Effect-Sensors.pdf

I saw both, the trapezoidal waveform which results from the 3 different phased sinusoidal waves and the single sinusoidal wave on the one line i was measuring.