I have 4 brushless motors and one of them starts rotating earlier then the other ones

So I'm building a RC drone , I have 4 esc and 4 brushless motors connected to 3,5,6 and 10 pins.
The brushless motor connected to the 10 pin is starting to rotate much earlier then the other one.
I know the pin 10 has a diffrent frequency but how can i fix this issue?


#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>



Servo esc2;
Servo esc3;
Servo esc4;
Servo esc1;

RF24 radio(7, 8); // CE, CSN

const byte address[6] = "00001";

struct Data_Package{
  byte joyrightx;
  byte joyrighty;
  byte joyleftx;
  byte joylefty;
};

Data_Package data;

unsigned long lastReceiveTime = 0;
unsigned long currentTime = 0;



void setup() {

  esc2.attach(3,1000,2000);
  esc3.attach(5,1000,2000);
  esc4.attach(6,1000,2000);
  esc1.attach(10,1000,2000);
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.setPALevel(RF24_PA_LOW);
  radio.startListening(); //  Set the module as receiver





}




void loop() {

  if (radio.available()) {
    radio.read(&data, sizeof(Data_Package));
    lastReceiveTime = millis(); 
  }
  currentTime = millis();
  if ( currentTime - lastReceiveTime > 1000 ) { 
  };

  
  Serial.println(data.joyrighty);

  esc2.write(data.joyrighty);
  esc3.write(data.joyrighty);
  esc4.write(data.joyrighty);
  esc1.write(data.joyrighty);
}

If you can, running the motor on a different pin is a quick check to make sure it's not something with how the current pin functions.

I will try that, but you think maybe its the frequency for pin 10?

SPI uses pin 10 for SS/CS. I think use of SPI would make pin 10 active.

So how should I connect 4 motors then?

You use the servo library to control your motors. This library is not restricted to pwm capable pins, and it does not use analogwrite. It always creates pulses of 1..2ms length with a repetition rate of 50Hz. There is no different frequency at pin 10. You can use any digital output pin to control your motors.

1 Like

Oh thank you very much bro!
I will try it right now.

The motor that was connected to pin D10 i connected it to D4 but it still rotates earlier.

Didn't see it anywhere, so I'll ask. What microcontroller are you using?

Arduino nano

Maybe check for an ESC issue? (swap out the one driving the late motor and use a different one) see if it's any different.

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