BlueBoat ESC Disarming / Navigator-lib

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

Hi @rturrisi -

AftCtrlV1::setPinPulseWidth(PwmChannel::Ch1, 0);

It seems you’re setting a PWM of 0 - this is not the neutral position, which corresponds to 1500 microseconds… That may be the only change you need!

Hey @tony-white - thanks for the reply.

I don’t know if you caught it previously or if I’m missing something else, but this isn’t 0 micro seconds. 0 is normalized to 1500 microseconds in setPinPulseWidth.

Best,
Ray

Hi @rturrisi -
Can you share more context on your goals for the BlueBoat and this code? When using the Navigator library, the autopilot process should be disabled I think, or this could lead to conflicts…
I’m also not sure where your 409.5 and 204.75 max/min values are coming from in setPinPulseWidth?

I’m attempting something similar (albeit not using the navigator-lib). I’m also looking for a method of safely disarming the vehicle independent of our navigator driver, which I have been doing by controlling the OE pin on the PCA9685.

I see the same behavior as Ray. Setting the OE pin high, stopping PWM, I get rapid beeping from the ESCs. I’d love to know how to un-initialize the ESCs, turning them off until they receive the initialize PWM again.

Hi @smccammon -
Welcome to the forums!
When an ESC beeps like that, it is “un-initialized” ! So you’re already achieving your goals - if you want to do so more quietly, you would need to adjust the ESC firmware to not beep…