Can't Reverse Aerostar ESC

I'm working on a project with my dad where we're creating our own self-balancing "onewheel". We're using a MPU6050 tilt/gyro sensor, 80a ESC, brushless motor and arduino uno to power and control the vehicle. I'm sending pwm signals to the esc from one of the arduino's digital pins between 1000 & 2000ms

The problem is, we can't figure out how to engage the reverse on the esc. The ESC has 4 cables coming out of it: +5v, ground, signal and reverse signal. I've tried grounding the reverse cable, giving it 5v and giving it a pwm (throttle) signal with no luck.

If anyone has any suggestions, please let me know.

The ESC is an Aerostar 80a WiFi brushless ESC

You need to provide a link to the datasheet for the ESC.

The name "Aerostar" suggests to me that it might be intended for model aircraft and they normally don't need reverse.

...R

If this is the ESC you're talking about then it does say that the default is Reverse is OFF. So have you done the ESC programming needed to switch it ON?

Steve

From the page that slipstick linked:

Reverse function supports to reverse the motor rotation during the flying for deceleration (AeroStar WiFi 80-130A have this function).

That makes me wonder if the reverse function is available in the 80A unit.

I read that as "the 80A to 130A versions have this function"...but it will be interesting to find out.

Steve

Yes this model is for model aircraft but it does have the reverse function. I have turned the function ON in programming using the tones since i don't have the wifi module. The ESC doesn't come with a data sheet as such but the included "manual" says that to reverse you need to connect it to a two stage switch module on a reciever, but i don't have much experience with RC vehicles so i don't really get what that means

Kearsley_15:
but the included "manual" says that to reverse you need to connect it to a two stage switch module on a reciever, but i don't have much experience with RC vehicles so i don't really get what that means

Post a link to the manual and someone may be able to help.

...R

Kearsley_15:
the included "manual" says that to reverse you need to connect it to a two stage switch module on a reciever, but i don't have much experience with RC vehicles so i don't really get what that means

I have many years experience with RC...but I still don't know what that means. It may need a servo style signal, perhaps write(0) to go one way and write(180) for the other direction. Or it could be many other things.

Steve

I've read through the manual and it really doesn't give much useful information. I will still post a picture of it when i can.

I've tried giving it a servo signal but it doesn't make any difference. It doesn't seem to pick up throttle signals through that cable.

ESCs usually need an arming sequence before they will respond. Did you apply the arming suequence?

We need to know what you have done (code, wiring) before we can offer any real help.

Ok no probs. I'll post everything when i get home, in under an hour or so

Photo1

Here are the photos of the manual. I’ll send pictures of the code in a sec.

Here is the code I have used. It’s only set-up at the moment for programming and testing purposes so that’s why some values are wrong.

To test I’m just using this code and manually making connections between the wires coming out the ESC and the arduino
:

#include “I2Cdev.h”
#include <PID_v1.h> //From Arduino-PID-Library/PID_v1.h at master · br3ttb/Arduino-PID-Library · GitHub
#include “MPU6050_6Axis_MotionApps20.h” //https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050
#include <Servo.h>

Servo ESC;
Servo RVS;
int val = 0;
MPU6050 mpu;
int sensorPin = A1;
int sensorValue = 0;

// MPU control/status vars
bool dmpReady = false; // set true if DMP init was successful
uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU
uint8_t devStatus; // return status after each device operation (0 = success, !0 = error)
uint16_t packetSize; // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount; // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars
Quaternion q; // [w, x, y, z] quaternion container
VectorFloat gravity; // [x, y, z] gravity vector
float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector

/Tune these 4 values for your BOT/
double setpoint= 180; //set the value when the bot is perpendicular to ground using serial monitor.
//Read the project documentation on circuitdigest.com to learn how to set these values
double Kp = 25; //Set this first
double Kd = 0.8; //Set this secound
double Ki = 80; //Finally set this
/End of values setting***/

double input, output;
PID pid(&input, &output, &setpoint, Kp, Ki, Kd, DIRECT);

volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high
void dmpDataReady()
{
mpuInterrupt = true;
}

void setup() {
Serial.begin(115200);
ESC.attach(3);
RVS.attach(5);

// initialize device
Serial.println(F(“Initializing I2C devices…”));
mpu.initialize();

// verify connection
Serial.println(F(“Testing device connections…”));
Serial.println(mpu.testConnection() ? F(“MPU6050 connection successful”) : F(“MPU6050 connection failed”));

// load and configure the DMP
devStatus = mpu.dmpInitialize();

// supply your own gyro offsets here, scaled for min sensitivity
mpu.setXGyroOffset(220);
mpu.setYGyroOffset(76);
mpu.setZGyroOffset(-85);
mpu.setZAccelOffset(1688);

// make sure it worked (returns 0 if so)
if (devStatus == 0)
{
// turn on the DMP, now that it’s ready
Serial.println(F(“Enabling DMP…”));
mpu.setDMPEnabled(true);

// enable Arduino interrupt detection
Serial.println(F(“Enabling interrupt detection (Arduino external interrupt 0)…”));
attachInterrupt(0, dmpDataReady, RISING);
mpuIntStatus = mpu.getIntStatus();

// set our DMP Ready flag so the main loop() function knows it’s okay to use it
Serial.println(F(“DMP ready! Waiting for first interrupt…”));
dmpReady = true;

// get expected DMP packet size for later comparison
packetSize = mpu.dmpGetFIFOPacketSize();

//setup PID
pid.SetMode(AUTOMATIC);
pid.SetSampleTime(10);
pid.SetOutputLimits(1000,2000);
}
else
{
// ERROR!
// 1 = initial memory load failed
// 2 = DMP configuration updates failed
// (if it’s going to break, usually the code will be 1)
Serial.print(F(“DMP Initialization failed (code “));
Serial.print(devStatus);
Serial.println(F(”)”));
}

//Initialise the Motor output pins

pinMode (3, OUTPUT);
pinMode (5, OUTPUT);

}

void loop() {

// if programming failed, don’t try to do anything
if (!dmpReady) return;

sensorValue = analogRead(sensorPin);
Serial.print(sensorValue);

// wait for MPU interrupt or extra packet(s) available
while (!mpuInterrupt && fifoCount < packetSize )
{
//no mpu data - performing PID calculations and output to motors
pid.Compute();

//Print the value of Input and Output on serial monitor to check how it is working.
Serial.print(input); Serial.print(" =>"); Serial.println(output);

if (sensorValue > -1){//If the Bot is falling

if (output<800) //Falling towards front
Reverse(); //Rotate the wheels forward
else if (output>800) //Falling towards back
Reverse(); //Rotate the wheels backward
}
else //If Bot not falling
Stop(); //Hold the wheels still

}

// reset interrupt flag and get INT_STATUS byte
mpuInterrupt = false;
mpuIntStatus = mpu.getIntStatus();

// get current FIFO count
fifoCount = mpu.getFIFOCount();

// check for overflow (this should never happen unless our code is too inefficient)
if ((mpuIntStatus & 0x10) || fifoCount == 1024)
{
// reset so we can continue cleanly
mpu.resetFIFO();
Serial.println(F(“FIFO overflow!”));

// otherwise, check for DMP data ready interrupt (this should happen frequently)
}
else if (mpuIntStatus & 0x02)
{
// wait for correct available data length, should be a VERY short wait
while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();

// read a packet from FIFO
mpu.getFIFOBytes(fifoBuffer, packetSize);

// track FIFO count here in case there is > 1 packet available
// (this lets us immediately read more without waiting for an interrupt)
fifoCount -= packetSize;

mpu.dmpGetQuaternion(&q, fifoBuffer); //get value for q
mpu.dmpGetGravity(&gravity, &q); //get value for gravity
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); //get value for ypr

input = ypr[2] * 180/M_PI + 180;

}
}

void Forward() //Code to rotate the wheel forward
{
ESC.writeMicroseconds(1200);
Serial.print(“F”); //Debugging information
val = 0;
}

void Reverse() //Code to rotate the wheel Backward
{

ESC.writeMicroseconds(1000);
RVS.writeMicroseconds(output);
Serial.print(“R”);

}

void Stop() //Code to stop both the wheels
{
ESC.writeMicroseconds(1000);
Serial.print(“S”);
}

If you are trying to get the ESC to work, I would suggest that you forget the IMU part and write a short sketch that just deals with the ESC.

Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask a good question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Yeah that's probably a good idea, but i don't have too much time to work on it and i don't know arduino that well. I'll give it ago at some point though.

Sorry but I can't follow all that complicated stuff.

Why not try a simple test program that just runs the motor forward for a second or two and then runs in reverse for the same time. I think that, even if the reverse wire does take a PWM signal, you're trying to use it the wrong way round. You're right the "manual" isn't much help but I'd guess the reverse wire (RVS?) is a switch, 1000 probably sets forward and 2000 sets reverse but the normal ESC input still sets the throttle speed in either forward or reverse. You seem to be setting the throttle to zero (1000) then writing some odd number to RVS.

Try something really basic like:

RVS.writeMicroseconds(1000);
ESC.writeMicroseconds(1200); //or any other throttle value

delay(2000);

RVS.writeMicroseconds(2000);
ESC.writeMicroseconds(1200); //or any other throttle value

delay(2000);

See what that does, if anything.

Steve

I did try this not too long ago, it didn't work. I might try again though. I really need to re-do the soldering on the "shield" i made to plug into the arduino headers because my test at the moment is a bit temperamental.

O.k. well I’m getting fed up of wading through your stuff and trying to make suggestions only to be told “Oh I’ve already tried that”. I give up. Good luck.

Steve

Sorry if i come across like that. I really don't mean it. It's just incredibly frustrating since I've got so close to finishing and yet i still can't fix this problem.