ESC Calibration Erratic, Calibrated Correctly

electronics

#1

Hey,

I’ve been working on doing some customer work to my ESC software controlled via PWMs.

I have the ESC (AFRO 12A) wired to an arduino. I have 7.2V 3500MaH Lithium Ion batteries powering the ESC. All the connections are tight and double checked. I’m sending throttle controls to esc via a radio controller at 433 MHz.

I followed these instructions for the 30 A Afro ( I couldn’t find 12A but assume they’re the same). https://hobbyking.com/media/file/314791443X94785X6.pdf

The ESC and MOTOR works GREAT when I follow instructions by applying 1860 BEFORE connecting power to ESC, then 1060. I send these variables via serial command via arduino suite. Calibration worked. Everything working as expected.

I then move to my radio controller code and upon green light start, the motor’s acting crazy. Variable speeds, random stops and starts. I’ve checked what my radio’s sending and it’s sending exactly what I expect, between 1060 and 1860. I have changed to 1200 (since <1200 the ESC does nothing anyways) to 1700, still same behavior. Now, when I apply more throttle power the motor stop acting crazy and just fly ahead. But when I release the throttle (expecting it to stop because it’s sending 1060) it starts acting crazy. I’ve also set the minimum to 0 to ensure no power’s coming through, still same results. set it 500, still results persist. I’ve also started with throttle at 1860 and then released, still no change in behavior.

Anyone have any ideas why calibration works, then when I try to control via wireless controller it’s acting nuts?


#2

@pdw2732,
The OROV Afro 12 amp ESCs are expecting a 1500us PWM input at startup so they know where neutral is since they can provide forward and backwards outputs to the brushless motors.
Regards,
TCIII AVD


#3

Does one follow the same calibration as that 30A manual? I feel as if it is a 2 directional ESC, there will be different calibration steps. Would you have a link to calibrating an ESC 12A from OPENROV? I’ll try finding something too.


#4

Latest update, no such luck. I have it start at 1500 mu seconds - but now won’t turn green.

I think I’m missing something fundamental regarding calibration of a 12A Afro?


#5

Here’s a clearer look at what I’m doing.

Here’s the code that WORKS (everytime) to calibrating my 12A Afro ESC.

Step 1: ESC disconnected from power
Step 2: Ensure Arduino connected to USB with code running and set at 1860
Step 3: Connect power to ESC, wait for double beep saying that it has memorized wavelength for top speed pulse
Step 4: Enter in 1060, the bottom speed or stop and watch it turn green and BOOM! Done!
Step 5" Enter into serial any number 1200 - 1864 and watch it run. It ONLY moves forward. There is NO neutral at 1500.

The last step makes me think I’m calibrating incorrectly? But how, if the manual says it to do it this way? I’m lost, appreciate any help.

WORKING CODE:
#include <Servo.h>

int speed = 1860; // set to zero speed
Servo motor; // Motor servo object

void setup() {

motor.attach(9);
Serial.begin(9600);

//delay(3000); // time to plug in cone
// Calibrate ESC
//motor.writeMicroseconds(1864); // Calibrate top speed

/*
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);

delay(2000); // LED off 5seconds

motor.writeMicroseconds(1064); // Calibrate stop
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
*/

}

void loop() {

if(Serial.available()){ // get serial command / replace with radio comms
speed = Serial.parseInt();
}

// Output check
Serial.print(“speed: “);
Serial.print(speed);
Serial.print(”\n”);
delay(2000);
motor.writeMicroseconds(speed);
delay(1000);

}

NOT WORKING CODE

#include <Servo.h>

// Joystick Controls
int throttle=0; // aka rx

// ESC Connection
Servo prop;

void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
prop.attach(9);
Serial.begin(115200);
prop.writeMicroseconds(1500);
delay(1000);

rf22.init();
rf22.setTxPower(RH_RF22_TXPOW_20DBM);
rf22.setModemConfig(RH_RF22::GFSK_Rb125Fd125);
SoftPWMBegin();

}

void loop()
{

if (rf22.available())
{

lastcommand=millis();
uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);

if (rf22.recv(buf, &len))
{
  
  //Grab LY
  //int leftY=buf[0]<<8 | buf[1];//unpack new packet
  //Grab RY
  //int rightY=buf[2]<<8 | buf[3];//motor control integers
  
  //Grab LX
  //int leftX=buf[4]<<8 | buf[5];
  //Gragb RX
  int rightX=buf[6]<<8 | buf[7];

  /*      
  Serial.print("unpacked integer left: ");
  Serial.print(leftY);
  Serial.print("\n");
  Serial.print("unpacked integer right:");
  Serial.print(rightY);
  Serial.print("\n"); 
  */
  
  /*
  if(abs(leftY)<100)leftY=0;//add a big deadband for the analog control
  if(abs(rightY)<100)rightY=0;//so the motors don't buzz when sitting
  if(abs(leftX)<100)leftX=0;
  */

  if(abs(rightX)<100)rightX=0;
  
  rightX/=2;
  

  // map to 1064 to 1864 RANGE
  throttle = map(rightX, 0, 195, 1060, 1860); // Actual max seen 194 but go higher to stay under 1864 threshold

  
  Serial.println("\n");
  Serial.println(throttle);

  /*
  //Utility polling to pack and send to controller
  uint8_t data[3];
  int voltage=getVCClevel();
  data[0]=abs(rf22.lastRssi());//pack the RSSI and voltage
  data[1]=voltage>>8;
  data[2]=voltage;
  rf22.send(data, 3);//send return packet ot transmitter
  rf22.waitPacketSent();
  */


}

}

/*
if(millis()-lastcommand>timeout){

prop.writeMicroseconds(1060);
//setMotor(2,0);//if there hasne't been a packet during timeout, stop motors
//setMotor(4,0);
lastcommand=millis();

}
*/

}


#6

I’ve now used tywo different ESCs. They act in the same way. I’ve come to the conclusion that there must be an issue with the fundamental way I’m using the escs in practical use. It’s almost like you have to have a seperate battery to turn on the receiver before you turn on the motor power of the esc to calibrate everytime?


#7

Here’s another clear understanding of what’s happening.

Scenario that works:

  1. push high signal to ESC without power connected to esc. Arduino’s on, applying the high pulse
  2. I attach power to ESC, beeps confirm high pulse remembered
  3. Send low pulse, beeps confirm it’s remembered
  4. Motor works perfectly fine

Scenario that does NOT work:

  1. Attach ESC to arduiino and battery.
  2. Turn on power to ALL, arduino and esc at once
  3. jitters, left, right, fast, flow

I’m starting to think that one must ALWAYS start an R/C or ESC via the calibration each time they start? Or they have to ensure it’s at neutral, but I’ve done that (the stop pulse) and it’s still jittering.

Much appreciate any help.

Thanks!


#8

So…

The joystick was too sensitive and was sending it volatile PWM pulses. That volatility mimic’d a broken wire of a motor or loose connection.


#9

@pdw2732,
Glad to hear that you figured it out.:slight_smile:
Regards,
TCIII AVD


#10

Hey pdw2732,

What kind of controller are you using? Glad you were able to find the issue.


#11

Tinyduino by Tiny Circuits.


#12

So it was the Tinyduino itself outputting inconsistent / coarse PWM commands?


#13

Yes, since the joystick was very small the ramp up / down was very jumpy. This made the motor act erratically similarly to a broken wire or failed to calibrate result. Once I smoothed out the signals or better, changed my code to reflect a switch case to make sure only one esc write was sent when I intended to speed up or slow down, the problem was fixed.