Arming a BLDC motor with RCESC library

Hello, I am trying to make a rc airplane with arduino and nrf modules. I have a brushless motor with a 30A ESC and i am trying to arm it.
This is the Transmitter code:



#include <SPI.h>// nrf communication 
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); //CE CSN
struct channels {//Data to be sent
  int ch1 = 0;
  int ch2 = 0;
  int ch3 = 0;
};
channels ch;
const byte address[6] = "10000";//address to send data 
int x = A0;// potentiometer pins
int x2 = A1;
int y = A2;


void setup() {
  Serial.begin(9600);
  pinMode(x, INPUT);
  pinMode(y, INPUT);
  pinMode(x2, INPUT);
  radio.begin();//Beginning the radio communication
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MAX);
  radio.stopListening();//Setting the nrf to transmitter mode
}

void loop() {

  ch.ch1 = map(analogRead(x), 0, 1023, 1000, 2000);// mapping the values
  ch.ch2 = map(analogRead(x2), 0, 1023, 0, 180);
  ch.ch3 = map(analogRead(y), 0, 1023, 0, 180);
  radio.write(&ch, sizeof(channels));//Sending the data
  Serial.println(ch.ch1);
  Serial.println(radio.isChipConnected());//Checking if the nrf module is connected
}

This is the receiver code:

#include <ESC.h>//Include the RC ESC library 



#include <Servo.h>// Servo library


#include <SPI.h>//nrf communication libraries
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(8, 7); // CE CSN
Servo s1;//Servo 1
Servo s2;//Servo 2
const byte address[6] = "10000";//address to communicate with the other nrf module
ESC bldc (6,1000,2000,690);// ESC(Pin Number,Maximum value,Minimum value,Arm value)
struct channels{//data to receive
  int ch1;
  int ch2;
  int ch3;
  
};
channels data;
void setup() {
  Serial.begin(9600);
  radio.begin();//Beginning the radio communication
  radio.openReadingPipe(0,address);
  radio.setPALevel(RF24_PA_MAX);
  radio.startListening();//Setting the nrf to listen mode
  s1.attach(5);
  s2.attach(3);
  
bldc.arm();//Function to arm the ESC
 delay(5000);//Delay to wait for the arming
}

void loop() {
  if(radio.available()){
  radio.read(&data,sizeof(channels));//Reading the data 
Serial.println(data.ch1);
 if(data.ch1>1010){//setting a speed to start the motor
  bldc.speed(data.ch1);//Starting the motor at the instructed speed

 }

 }
  else{//to stop the motor
    bldc.stop();
  }




}

This worked for some time and while i was about to test the airplane it wouldn't arm at all.
At first I thought it might be the code. So i tested an example code, It didn't work either.
Then I thought it might be the arm value but do arm values change?
Can anyone tell me how to solve this?
Thank you in advance for the help! :slight_smile:

Please post the schematics. Hardware issues are suspected.

However you figure out how, restore the components to their default states, and perform any calibration required.

Then if you can, turn off any ability the ESC has to be programmed through manipulation of its normal control signals.

The ability to configure or adjust in the field through stick gestures is useful, but it is a dual edge sword in the sense that inadvertent control sequences such as might very probably be delivered whilst tinkering with driving software can mean placing the ESC in an inoperable or at least undesirable condition.

In the Belheli Configurator, for example, this is called Programming by TX and can be explicitly unchecked to prevent such accidents, which as I say are only more likely when you are messing around without knowing what the code might be doing what you didn't anticipate.

I would not try to do what you are doing in,escs I had developed a certain amount of experience using one or the other of several mature flight control ecosystems like Betaflight, along with the parts that have been working well with it for a decade.

I could say the same thing about flying. I would not try to fly something DIY unless I had a certain anoint of experience flying aircraft I had zero no part nothing to do with the design of either the hardware, software or mechanical aspects.

Life too short.

a7

I found the solution to the problem. I had powered the arduino by the VIN pin and when i changed it to the 5v pin it started to work. But now the main IC of the arduino is heating up to first degree burn levels and i can't even establish radio communication. Probably need to get a new nano.

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