How to use ESC?

Arduino-ESC-brushless DC motor.

I want to control ESC speed by using potentiometer (variable resistor).
1.5ms at brake position.
1.56ms (minimum speed) to 2.0ms (maximum speed) for forward rotation.
1.44ms (minimum speed) to 1.0ms (maximum speed) for backward rotation.

Problem

  1. When increase forward rotation at 1.8ms the motor will automatic stop after 9 second.
    Why? It is safety at ESC?

  2. Brushless DC motor cannot do backward rotation.
    why?

ESC need to calibrate with potentiometer?

  1. When increase forward rotation at 1.8ms the motor will automatic stop after 9 second.
    Why? It is safety at ESC?

Not enough information. When you say 1.8ms what does this represent? Is the motor or ESC hot after 9 seconds?

The lack of reverse rotation is built into the controller (ESC) because a vast majority of applications do not need reverse. The added $$ and weight (think planed) is an issue for many.

There is no reason a brushless motor cannot go in reverse if you had a controller with this capability.

@danialmazlee, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project :wink: See About the Installation & Troubleshooting category.

Hello
Post your sketch and schematic to see how we can help.

CODE
#include <Servo.h>

byte servoPin = 6; // signal pin for the ESC.
byte potentiometerPin = A0; // analog input pin for the potentiometer.
Servo servo;

// Define the number of samples to keep track of. The higher the number, the
// more the readings will be smoothed, but the slower the output will respond to
// the input. Using a constant rather than a normal variable lets us use this
// value to determine the size of the readings array.
const int numReadings = 10;

int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average

int inputPin = A0;

const int led =7; // GPIO 7 for the LED

void setup() {

servo.attach(servoPin);
servo.writeMicroseconds(1500); // send "stop" signal to ESC. Also necessary to arm the ESC.

// initialize serial communication with computer:
Serial.begin(9600);
pinMode(led,OUTPUT); // define LED as an output
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}

void loop() {
// subtract the last reading:
total = total - readings[readIndex];
// read from the sensor:
readings[readIndex] = analogRead(inputPin);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;

// if we're at the end of the array...
if (readIndex >= numReadings) {
// ...wrap around to the beginning:
readIndex = 0;
}

// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits
int val = map(average, 0, 1023, 1000, 2000);
Serial.println(val);
delay(1); // delay in between reads for stability
servo.writeMicroseconds(val); // Send signal to ESC.

if (val>=1450&&val<=1500) { // and the status flag is LOW
digitalWrite(led,HIGH); // and turn on the LED
}

else {
digitalWrite(led,LOW);
}
}

Problem
The flow cannot go from brake to reverse. I need to do from brake (1500 ) to max reverse (1000) to brake (1500) again, after then the motor can do reverse (1450 to 1000).
So the problem of my flow right now cannot go reverse from brake. Need to turn potentiometer to maximum reverse first then back to brake, after that can run reverse smoothly.
Brake > Max Reverse (motor not running) > Brake > reverse to max (reverse can run)

I want to do Brake > Reverse (motor can run). Anyone know how to solve it?

Position of potentiometer
1500 - 2000 = Forward rotation
1500-1450 = Brake
1450 - 1000 = Reverse rotation

Hi paul, I already share my new problem.
Hope you can help. :smiley:

Please tell us the make and model of the ESC.

Post a link to where you got it, and any links that you are using to inform your programming.

It is possible that your ESC is capable of bidirectional control of the motor, perhaps already, after having some settings changed, perhaps after flashing new firmware to give it that capability.

a7

https://shopee.com.my/Ready-Stock-Waterproof-Brushless-ESC-WP-10BL60-RTR-60A-2-3S-Lipo-RC-Car-i.21165536.931820671

This is my ESC model wp-10bl60-rtr.

There's this thing called google.com where you can search for information on all kindsa things.

This manual shows how set up you ESC for bidirectional operation and may also answer your other questions. I found it googling, which is what we call it when you use that google.com website. Very handy!

HTH

a7

This looks like a regular PWM control with a 50 Hz signal and duty cycle from 5% to 10%

Try this one out. The signal output would be on PORTB2 or pin D10 on the UNO

int analogPin = A0;
int val = 0;
uint16_t duty = 0;

void setup() {
  // put your setup code here, to run once:
  PWM_init();
}

void loop() {
  // put your main code here, to run repeatedly:
  val = analogRead(analogPin);
  duty = map(val, 0, 1023, 250, 500);
  OCR1B = duty;
}

void PWM_init(void)
{
  /***************************
  Initialize the PWM hardware
  ***************************/

  // set OC1B output pin
  DDRB |= 1<<PORTB2;

  // set TIMER1 for Fast PWM mode, non-inverted output on OC1B pin
  TCCR1A = 1<<WGM11 | 1<<WGM10 | 1<<COM1B1 | 0<<COM1B0;
  TCCR1B = 1<<WGM13 | 1<<WGM12;

  // disable interrupts
  TIMSK1 = 0<<OCIE1B | 0<<OCIE1A | 0<<TOIE1;

  // set TOP value to generate 50 Hz [250 KHz / 5000]
  OCR1A = (5000 - 1);

  // set initial duty cycles at 7.5%
  OCR1B = 375;

  // start TIMER1 at 250 KHz [DIV64]
  TCCR1B = 1<<WGM13 | 1<<WGM12 | 0<<CS12 | 1<<CS11 | 1<<CS10;

  return;
}

Thanks, but I already know the user manual. This is my first time using ESC.

What I want to know this ESC from forward to reverse, need brake. From reverse to forward need brake first. Example,

  1. Brake > forward (1500-2000). Run well.
  2. Reverse > brake > forward. Run well.

The situation problem,

  1. Brake > reverse.
    I need to maximum reverse first, then go back to brake. After that, I can run properly the reverse.

  2. Brake > forward :white_check_mark: > brake > reverse max first (motor did not run) > brake again > reverse (motor can run).

Do you understand my problem? I did not know, my code problem or ESC setup like that.
From brake I need to go maximum reverse (motor did not run), then go to brake again, after that I can go to reverse again (motor run).

I didn't study the entire manual as you have done.

Where you may have learned that this is just how it works as a matter of safety by design.

If that is what the manual sez, that is what the ESC will enforce.

There does not appear to be any way around that, and it is not clear that there is any alternate firmware or an ability for the end user to flash the ESC and use it differently.

Use that google thing. My sense is that what you got is what is.

There are many inexpensive ESCs that will do bidirectional and braking and operate with open source firmware even if they didn't arrive at your door ready to be configured, calibrated and used.

If you can't make the one you have work, ditch it.

a7

That is correct.
This is the way most reverse type esc work.
Neutral stick to full reverse, then back to neutral, then one can drive reverse.
It is designed to stop people from running any forward motion and instantly going to reverse.
Perhaps an esc for a boat or a robot rather than a car may have the no-brake arrangement.

Unless you need the Arduino to do some clever automatic forward-back manipulation at startup, it makes no sense at all to use an Arduino.

Just get a "servo tester" and re-wire the potentiometer to it.

Why the need to re-wire anything........
Op needs pot operation and servo tester does just that.
ESC would still require initial programming so the esc knows the extent of the signal levels but that is the same whatever.

Of course. :+1: I was kind of assuming he wanted or would want to use a potentiometer already in some other sort of mounting.

1 Like