Does ESC for BLDC motor require a PWM pin?

Using an Uno r4 Minima, I got a BLDC to spin with an ESC by switching the signal pin from D7 (non-PWM) to D9 which is PWM-enabled. I don't understand why this worked.

I wrote my own 50Hz PWM sketch using digitalWrites HIGH and LOW and never using analogWrite. When I use a pin purely digitally, I prefer a non-PWM pin to leave room for things that might need it.

When using pin 7, I got a 180-degree servo and a continous servo to work as expected, but it would not work with an ESC. I used the Servo code and switched the pin to 9 and the ESC worked.

I then switched my pin in my sketch to 9 and it worked.

If all I am sending to the ESC is LOW or HIGH, why does it need to be connected to a PWM pin?

Thanks

What creates the "need"? You have a way to do what You want it looks like?

Please read and use this: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Words and telling about about several different attempts, it takes a book to sort things out.

That was the question. I boiled it down to the relevant issue -- with a non-PWM pin, fail; with PWM pin, success. I made absolutely no other changes to the circuit or the code.

I was hoping that someone with knowledge and/or experience with ESCs could explain why a device that expects a digital signal of 50Hz needs to be connected to an Arduino PWM pin which runs at a much higher frequency.

Post that code, You don't seem to understand how servo signals work, they are not the typical PWM waveform.

Ok, here is my code. I understood that the ESC is expecting a 50Hz PWM signal with where the on phase is 1 to 2 ms. (1000 to 2000 us).

This code didn't make the motor spin when the pin was 7, but did when the pin was 9.

Please tell me what I don't understand. Thanks

const int SERVO = 9;
uint32_t currTime, prevTime;
const uint32_t intv50Hz = 20;

String buf = "";
int pulse;

void setup() {
  Serial.begin(115200);
  prevTime = millis();
  pinMode(SERVO, OUTPUT);
  digitalWrite(SERVO, LOW);
  pulse = 1500;
}

void loop() {
  currTime = millis();

  if(currTime - prevTime >= intv50Hz){
    digitalWrite(SERVO, HIGH);
    delayMicroseconds(pulse);
    digitalWrite(SERVO, LOW);
    
    prevTime = currTime;
  }

  if(Serial.available() > 0){
    buf = Serial.readStringUntil('\n');
    
    pulse = buf.toInt();

    if(pulse < 500){
      pulse = 800;
    }
    if(pulse > 2500){
      pulse = 2200;
    }
  }
}

Servos and ESCs do not have to be connected to a PWM pin. Did you try it with the Arduino Servo library? Did you "arm" the ESC? Which ESC? Post link to datasheet or brand name and EXACT part number or seller's web page.

Servos and ESCs do not have to be connected to a PWM pin. I thought so, too. I was looking for insight on why this appears to not be true.

Did you try it with the Arduino Servo library? Yes, it worked with the code as written. For my homemade PWM, it did not work when SERVO was pin 7, but did work when it was on pin 9. (Uno r4 Minima)

Did you "arm" the ESC? Yes

Which ESC? Post link to datasheet or brand name and EXACT part number or seller's web page.
It is one of these.
30A_BLDC_ESC_Product_Manual.pdf (172.0 KB)

The current Servo library has issues with the Uno R4.
Post 13 in this thread seems to solve it.
Leo..

1 Like

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