Go Down

Topic: Problem getting 3-phase motor to work with ESC (Read 2523 times) previous topic - next topic

the_g

Hi all,

Background:
I am using Arduino Uno to make a 3-phase motor run through an ESC, powered by a 3-cell LiPo battery. The circuit is wired exactly like shown in the image link, except with the components as linked above:


I do not need a throttle for this project. I merely want it to run as if it was running on PWM. This is for a camera stabilizer gimbal project. (If you have had any experience making one, please PM me, would greatly appreciate it!)


Problem:
The problem is that my motor seems to run very randomly. Here is one of the code I used:
Code: [Select]
#include <Servo.h>

Servo esc;

void arming(){
  Serial.println("Arming");
  setSpeed(30);
  delay(2000);
  
  setSpeed(90);
  delay(2000);
  
  Serial.println("Armed");
  setSpeed(30);
  delay(2000);
}

void setSpeed(int speed) {
  // speed is from 0 to 100 where 0 is off and 100 is max speed
  // the following maps speed values of 0-100 to angles from 0-180
  
  int angle = map(speed, 0, 100, 0, 180);
  esc.write(angle);
}

void setup(){
  Serial.begin(115200);
  esc.attach(9);
  arming();
}

void loop(){
  Serial.println("Sweeping up");
  int speed;
  for(speed = 37; speed <= 90; speed+= 1){
    setSpeed(speed);
    Serial.println(speed);
    delay(1000);
  
  }
}


Before running, when everything is connected except the Arduino, the motor beeps once periodically (which seems to be normal behavior to me). When running, during arming, the motor seems to be running fine. During the for loop, the motor runs for a while, but then stops running. When the for loop runs back again, the motor doesn't run again, even at the same speed values it ran the first time. There is no beeping whatsoever, and the program continues to run (as I see on my Serial Monitor).


Another thing I tried was using writeMicroseconds with the following code:
Code: [Select]
#include <Servo.h>

#define MAX_SIGNAL 2000
#define MIN_SIGNAL 700
#define MOTOR_PIN 9

Servo motor;

void setup() {
  Serial.begin(9600);
  Serial.println("Program begin...");
  Serial.println("This program will calibrate the ESC.");

  motor.attach(MOTOR_PIN);

  Serial.println("Now writing maximum output.");
  Serial.println("Turn on power source, then wait 2 seconds and press any key.");
  motor.writeMicroseconds(MAX_SIGNAL);

  // Wait for input
  while (!Serial.available());
  Serial.read();

  // Send min output
  Serial.println("Sending minimum output");
  motor.writeMicroseconds(MIN_SIGNAL);

}

void loop() {  

}


When running, the motor turned successfully when MAX_SIGNAL was sent, but not when MIN_SIGNAL was sent. It still didn't work even when I changed MIN_SIGNAL to 2000.


Another behavior I noted used to happen, but now does not: The motor beeped 2, then 3, then 4 times, after a code has run, especially with the 2nd code in this post. However, this only happens occasionally.



God bless you if you can help me through with this. :')


P.S. I hope my 1st post is clear and concise.

jasontwd

HI @the_g,
Did you get this to work??

Im having similar probelm, looking at you 1st lot of code, trying to make the motor shut off after a delay to 0 then back on again.

cheers
jason

ballscrewbob

@jasontwd

DO NOT HIJACK / NECRO POST !

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google (who would have thunk it ! ) or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up