Problem with ESCs and Serial communication

Hi Everyone :slight_smile:

I’m currently working on a control software for my ROV and ran into some problems, which i can’t resolve myself.

I control my ROV with an topside software that sends a constant stream of strings over Serial to the Arduino.
These strings look like this → “1500;1200;1400” They contain the signals for each one of 3 ESCs

This script on the Arduino chops these strings up and sends them to the ESCs. It also sends the topside computer a “ping” signal to tell it that it is still there.

#include <Servo.h>
#include <Wire.h>

Servo servor;
Servo servol;
Servo servov;

unsigned long pingTimer;
boolean pinged;

void setup() {

servol.attach(9);
servor.attach(10);
servov.attach(11);

servol.writeMicroseconds(1500);
servor.writeMicroseconds(1500);
servov.writeMicroseconds(1500);

delay(1000);

Serial.begin(4800);

pinged = false;
pingTimer = millis();
}

void loop() {

if (pinged) {
pingTimer = millis();
pinged = false;

}

if (millis() - pingTimer >= 1000UL) {
Serial.println(“ping”);
pinged = true;
}

String servo1 = Serial.readStringUntil(’:’);
String servo2 = Serial.readStringUntil(’:’);
String servo3 = Serial.readStringUntil(’:’);

int int_servo1 = servo1.toInt();
int int_servo2 = servo2.toInt();
int int_servo3 = servo3.toInt();

servol.writeMicroseconds(int_servo1);
servor.writeMicroseconds(int_servo2);
servov.writeMicroseconds(int_servo3);

}

My problem is that, when no serial communication is established between topside computer and arduino all 3 ESCs spin up to full throttle until the communication is established. The script runs on an Arduino UNO and and the ESCs are Afro-ESCs with reverse firmware.

Has anyone an idea why this happens and how i could work around it?

Thanks in advance for your efforts :slight_smile:

Cheers,
Chris

ROV_Control_REV3.ino (1.03 KB)