1
\$\begingroup\$

I got the following code from the video. However, I encountered an issue that, the motor tended to stop working at maximum value.

#include <Servo.h>

Servo ESC;     // create servo object to control the ESC
int potValue;  // value from the analog pin

void setup() {
  ESC.attach(9,100,2000); // (pin, min pulse width, max pulse width in microseconds) 
  ESC.writeMicroseconds(1000);

}


void loop() {

potValue = analogRead(A0);  
potValue = map(potValue, 0, 1023, 1000, 2000);   
ESC.writeMicroseconds(potValue);
}

The ESC I used was BL Heli ESC. This issue appear to be some what general. Is there any particular reason to stop ESC and motor operating at 100%?

Question part 2: The webpage and online resource usually said "The ESC accept pulse from 1 ms and 2 ms." and "... operated at 50 Hz"(every 20ms), which represented the operation from 0% to 100%.

2a. Can we send 5V constant signal to ESC? Does it represent 100% operation?

2b. What if we send 1.5/2 ms for every 10ms signal to ESC? Does that represent 50%, or some value between 25% to 50%?

\$\endgroup\$
0

1 Answer 1

4
\$\begingroup\$

You made a few errors in your code:

ESC.attach(9,100,2000); should be ESC.attach(9,1000,2000);, so, 1000 instead of 100.

and

potValue = map(potValue, 0, 1023, 1000, 2000); should be potValue = map(potValue, 0, 1023, 0, 180);
because the next line, the command writeMicroseconds(angle) only accepts a value to write to the servo, from 0 to 180

Have a look how servo control works:

enter image description here

2b. What if we send 1.5/2 ms for every 10ms signal to ESC? Does that represent 50%, or some value between 25% to 50%? Does it represent 100% operation?

You should send a pulse each 20 ms, because that is how (this) servo signal/BLDC motor control signal is defined. You cannot change that to 10 ms.
For your convenience:

  0 degrees corresponds a pulse witdh of 1.00 ms corresponds to   0% of max RPM*
 45 degrees corresponds a pulse witdh of 1.25 ms corresponds to  25% of max RPM
 90 degrees corresponds a pulse witdh of 1.50 ms corresponds to  50% of max RPM
135 degrees corresponds a pulse witdh of 1.75 ms corresponds to  75% of max RPM
180 degrees corresponds a pulse witdh of 2.00 ms corresponds to 100% of max RPM

*or 1% (I'm not sure how it is implemented)

2a. Can we send 5V constant signal to ESC?

This pulse width should be between 1 ms and 2 ms. A pulsed signal is not a constant signal, so, no, you cannot send a 5V constant signal.
That's also the reason the min and max values of ESC.attach(9,1000,2000); should be 1000 resp. 2000.

\$\endgroup\$
4
  • \$\begingroup\$ arduino.cc/en/Reference/ServoWriteMicroseconds It seemed to indicate that it can accept value below 1000 at least until 700. \$\endgroup\$ Commented Jan 6, 2020 at 10:47
  • 1
    \$\begingroup\$ The next line of your quoted line is: Note that some manufactures do not follow this standard very closely so that servos often respond to values between 700 and 2300 The command is to also cover non-standard servo control. The website/video you were refering to is quite clear it should between 1000us and 2000us. \$\endgroup\$
    – Huisman
    Commented Jan 6, 2020 at 10:53
  • \$\begingroup\$ Good job Huisman. >shout... the implmentation differences between target devices might react differently when going beyond stds. Although a wider PW50 or pulse width might translate into finer resolution for some servos , it might have be detected as noise or have no effect on others. \$\endgroup\$ Commented Jan 6, 2020 at 12:29
  • \$\begingroup\$ Shouldn't the function be ESC.write(), not ESC.writeMicroseconds() if you're passing an angle? (0 to 180 per your answer) That would match the documentation. \$\endgroup\$
    – Mandias
    Commented Mar 14, 2023 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.