Hello,
I’m writing some code for the BlueBoat using the Navigator Lib, refactoring some code from an AUV. The AUV uses the basic ESC – and the arming/disarming procedure works fine and is reliable. On the BlueBoat however, I went to follow the same procedure, but as soon as the pwm chip is disabled, the Basic ESC 500’s start beeping, and when I go to re-run the application to re-arm them, they spin up rapidly and the boat browns out.
Is there a more proper disarming procedure beyond what I have, for the Basic ESC 500?
I’m attaching some select code which works on the AUV, for the bring up and bring down procedure.
void safePwmShutdown()
{
// Set all servos to a neutral position before disabling PWM
AftCtrlV1::setPinPulseWidth(PwmChannel::Ch1, 0);
AftCtrlV1::setPinPulseWidth(PwmChannel::Ch2, 0);
AftCtrlV1::setPinPulseWidth(PwmChannel::Ch3, 0);
AftCtrlV1::setPinPulseWidth(PwmChannel::Ch16, 0);
// Ensure the PWM values have been applied
std::this_thread::sleep_for(std::chrono::milliseconds(500));
set_pwm_enable(false);
}
void signalHandler(int signum)
{
safePwmShutdown();
exit(signum);
};
...
AftCtrlV1::AftCtrlV1()
{
signal(SIGINT, signalHandler); // Interrupt from keyboard (Ctrl+C)
signal(SIGTERM, signalHandler); // Termination signal
signal(SIGABRT, signalHandler); // Abnormal termination (abort)
signal(SIGQUIT, signalHandler); // Quit from keyboard
signal(SIGSEGV, signalHandler); // Invalid memory access (segmentation fault)
signal(SIGFPE, signalHandler); // Floating point exception
signal(SIGHUP, signalHandler); // Hangup detected on controlling terminal or death of controlling process
signal(SIGPIPE, signalHandler); // Write to a pipe with no one to read it
signal(SIGALRM, signalHandler); // Timer signal from alarm()
signal(SIGUSR1, signalHandler); // User-defined signal 1
signal(SIGUSR2, signalHandler); // User-defined signal 2
atexit(safePwmShutdown);
...
//including initialize, since it works fine on the BB and AUV.
void AftCtrlV1::initializeESC(PwmChannel pin)
{
// Set to Maximum Throttle
setPinPulseWidth(pin, 100); // Assuming 100% corresponds to 2000 microseconds
this_thread::sleep_for(chrono::milliseconds(500)); // Wait for 2 seconds
// Set to Minimum Throttle
setPinPulseWidth(pin, -100); // Assuming 0% corresponds to 1000 microseconds
this_thread::sleep_for(chrono::milliseconds(500)); // Wait for 2 seconds
// Optional: Set to Neutral Throttle (e.g., for ESCs that need this)
setPinPulseWidth(pin, 0); // Assuming 50% corresponds to 1500 microseconds
this_thread::sleep_for(chrono::milliseconds(250)); // Wait for 1 second
// The ESC should now be initialized and ready to accept normal operational commands
}
static void setPinPulseWidth(PwmChannel pin_num, double target)
{
double max = 409.5; // at 50 Hz, corresponds to 2000 microseconds pulsewidth
double min = 204.75; // at 50 Hz, corresponds to 1000 microseconds pulsewidth
double center_pwm = min + (max - min) / 2;
double range_pwm = max - min;
double pulse_width = center_pwm + (target / 100.0) * range_pwm / 2;
set_pwm_channel_value(pin_num, pulse_width);
}
Is there a special procedure to disarm them safely and similarly to the regular basic ESC?
Best,
Ray