Control BLDC motor with ESC and power supply instead of battery

I'd like to use the Power Supply Unit (PSU) instead of battery to control the BLDC motor through ESC with the below configurations:

  1. ESP8266 NodeMCU 1.0
  2. PSU (Model S-60-12; AC Input: 220V; DC Input: 12V 5A)
  3. BLCD: 2212/10T/1400KV
  4. ESC 30A

Connections like the photo (Servo connector: GND to ESP8266 GND, Throttle Input Pin to ESP8266 D1)

And this is my code:

#include <Servo.h>

Servo m1; 

void setup(){
  m1.attach(D1); // D1

  m1.write(180);
  delay(2000);
  m1.write(0);
  delay(2000);
}

void loop(){ 
  int pos;

  for (pos = 0; pos <= 180; pos += 1) {  // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    m1.write(pos);  // tell servo to go to position in variable 'pos'
    delay(15);           // waits 15ms for the servo to reach the position
  }

  for (pos = 180; pos >= 0; pos -= 1) {  // goes from 180 degrees to 0 degrees
    m1.write(pos);                  // tell servo to go to position in variable 'pos'
    delay(15);                           // waits 15ms for the servo to reach the position
  }
}

When i plug the AC power connector, the motor can run as expected. However, if i repeatedly plug and unplug it, sometimes the motor doesn't work.

Could anybody support me to solve the above issue so that the motor always runs when i plug/unplug the power connector multiple times?

Thanks

Connections like in schematics is preferred. How do You power the ESP8266? Schematics would tell..

Link to the datasheet of the BLDC please.

When unplugging the power give the things a minute to completely discharge. Else it will get close to intermittent contact and that can make any equipment go wrong.

That sounds like a relative simple problem to solve, probably in hardware. Post an annotated schematic showing exactly how you wired it, include all connections, power, ground, power source(s) etc. Links to the hardware devices also help.

Hi, @namhn
Welcome to the forum.

Thanks for using code tags.

Can you please post a copy of your circuit a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Tom.. :grinning: :+1: :coffee: :australia:

ESC's typically require to be "armed" at each power up.

This is to protect the user against inadvertent prop runs at power up causing injuries.
That plus the user usually craps themselves which can be embarrassing.

Operation is usually ...throttle low....power up.....throttle high then back to low......esc beeps to confirm......although yours may be different.
Care must be taken as the above can also enter "program mode" under certain circumstances.

As a side note, I would not use a pc power supply, use batteries as it was designed for.
Several reasons.......... :thinking:

Put a fuse in the main ESC power supply wire.

Tom.. :grinning: :+1: :coffee: :australia:

All: Thanks for your feedbacks.
I'd like to provide the board, schematic and the ESC manual.

@Railroader, @gilshultz :
I plug the power cable to AC 220V as the input source, PSU will output the DC 12V 5A which is then connected to the ESC power.

I'm assuming the user uses the product, they don't have any knowledge, just plug and use, don't care to wait for a minute.

bluejets : Yes, as you can see, I armed it in the setup part.

ESC Manual: 30A BLDC ESC Product Manual 2012 06 08


Good luck.

Yep. Really need support from all you guys.

Most, as I already said, require low...then high...then low to arm.
This is not what you have.

@bluejets : Can you explain more clearly why it should be low-high-low to arm?

Btw, as per your suggestion "ESC's typically require to be "armed" at each power up", i think i find the solution.

As per ESC manual 30A BLDC ESC Product Manual 2012 06 08 , "armed" or "calibrated" or throttle range setting step requires the following instructions:

That the reason why i set it high (corresponding with step 1 in throttle range setting), and delay 2 seconds (step 3) then set to low and delay 2 seconds (step 4: > the minimum of 1 second waiting).

However, I only arm it in the setup part as in a normal guidance which i think it is not enough because the ESP8266 doesn't know when I plug the power connector (step 2). It is very easy for us to do manually steps with the outside remote control, but to make ESP8266 do the steps automatically i must to move the throttle range setting to the loop part so that ESP8266 doesn't care when the power connector is plugged and will try to loop several times until the throttle range setting is fulfilled.

So my schematic is kept the same, just move the arm code from the setup part to the loop part as below

#include <Servo.h>

Servo m1; 

void setup(){
  m1.attach(D1); // D1
}

void loop(){  
  m1.write(180);
  delay(2000);
  m1.write(0);
  delay(2000);

  int pos;

  for (pos = 0; pos <= 180; pos += 1) {  // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    m1.write(pos);  // tell servo to go to position in variable 'pos'
    delay(15);           // waits 15ms for the servo to reach the position
  }

  for (pos = 180; pos >= 0; pos -= 1) {  // goes from 180 degrees to 0 degrees
    m1.write(pos);                  // tell servo to go to position in variable 'pos'
    delay(15);                           // waits 15ms for the servo to reach the position
  }
}

A disadvantage for this solution is that we need to wait 4s to run the throttle range setting step before the motor can rotate for every loop but at least it can resolve my issue.

As a side note, as per the above manual, entering the "programming mode" requires the following steps:

It means we set high for step 1, delay 2s for step 2 and wait for another 5s for step 3 to enter the programming mode. This setup will be different with the "armed" or throttle range setting so i think we won't enter the "programming mode" under certain circumstances.

For the using batteries as it was designed for, it will order the battery and test and made feedback if the issue does not happen even the armed step is put in the setup part.

Thanks @bluejets and all you guys for your support.

As I said.
To begin with, most transmitters will not turn on unless all sticks are in an appropriate position and for throttle that means "LOW".
Then you need to arm and back to low.

Try giving the esc more time, that might be a bit short at 2 seconds......(try 5 seconds)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.