Arduino Portenta H7 Servo

Hello guys,

I recently bought a Protenta h7 to use it as a brain in my "self-driving" quadcopter. I had tried something similar with a Mega board, but was lacking processing power.

The problem is that I can't use the Servo.h library, because it is not yet supported for that board. (I need the Servo library to send the desired pulse to ESCs.)

ESCs get a standard 50Hz PWM pulse.

#include <Servo.h>
Servo servo;     // create servo object

void setup() {
    // Attach the ESC on my pin
    servo.attach(A0,1000,2000); // (pin, min pulse width, max pulse width in microseconds) 
}
void loop() {
  
    servo.write(1200);    // Send PWM to ESC
}

The above code would set the motor to 20% speed.

Anything to suggest?
If not, any idea whether and when they add it to supported boards?

Thanks!

Hi SpaseRe! Thanks for pointing this out. It's definitely something we want to support asap. Let me investigate the timeframe for this. I'll keep you posted.

Hi SpaseRe!

I had a look at the Servo library and it seems that there was a small bug that prevented the library from compiling for Portenta. I've submitted a fix which we'll merge once reviewed. You can check the PR here:

sbhklr:
Hi SpaseRe!

I had a look at the Servo library and it seems that there was a small bug that prevented the library from compiling for Portenta. I've submitted a fix which we'll merge once reviewed. You can check the PR here:
Add missing include by sebromero · Pull Request #60 · arduino-libraries/Servo · GitHub

Any word on if this fix is working. I have Servo.h version 1.1.6 and I am still getting compile errors. Even if I use the Servo.h file found at

The necessary change is in src/mbed/Servo.cpp:

You only need to add an #include directive for mbed.h.

Have you done that @jerteach? If so, please post the full error output. If you haven't done it, and want more detailed instructions, I'm happy to provide them.

Pert, that was the issue. Until the library is updated you only have to change that one line of code. Strangely hard on windows because the directory was locked. Had to load notepad in administrator mode. The file was at

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp

and I just needed to add this line after the other #includes in the file:

#include <mbed.h>

I have listed my running Servo code on my Portenta Github site at my-examples-for-the-arduino-portentaH7/my11-servo.ino at master · hpssjellis/my-examples-for-the-arduino-portentaH7 · GitHub