Only 2 PWMout channels

I successfully tried the Servo example from your github repository (with my brushless motors, but I guess this should not matter?).

But there seem to be only 2 channels for PWM, but my quad obviosuly has 4 motors (Ardupilot can control all 4 motors).
I get the error Can't init channel 2 (from PWM.cpp:18).

Checking the filesystem it shows only 2 pwm channels:

ls /sys/class/pwm/pwmchip0
device  export  npwm  power  pwm0  pwm1  subsystem  uevent  unexport
ls /sys/class/pwm/

How do I control channel 3 and 4?

Hi @mirkow ,

All 14 Navio2’s servo rail pins can be used to output the PWM signal.

If you want to control PWM pins you can access them using GPIO. We have an example of use in our documentation.

You can also check Navio2’s examples. There is also information in the description regarding the means of accessing pins using Python and C++. They might be of help to you.

May I ask, were you making your own autopilot or creating control scripts when you’ve faced this issue?

OK, thanks, I will try.

But why does the PWM class only support channel 0 and 1?

To your question: Both. I am currently testing all the inputs and outputs to ultimately make my own autopilot.

Today all pwm (0-13) channels exist in /sys/class/pwm/pwmchip0 and I can use them. What does this depend on?

Hey @mirkow,

Normally, all the pins should be present in the pwmchip0 directory. It’s rather hard to say what caused them to vanish on your previous boot without knowing your full setup. However, if they do appear there now, everything should work just fine.

If the issue will show up once again and you won’t be able to operate PWMs, please, let us know.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.