How to modify the firmware for a quadrotor to account for bidirectional motors?

I am trying to modify the Px4 firmware for a quadrotor that has bidirectional motors, to enable inverted flight (so that the quadrotor can fly upside down). The basic principle is that since the motors can operate in both directions, the scaling for the output PWM has changed. Normally, 1000 is the minimum PWM corresponding to no power, 2000 is the maximum PWM corresponding to full power. With the bidirectional motors, 1000 corresponds to full power in the reverse direction, and thus the middle value, 1500 results in no power. I have configured the ESC’s for the bidirectional capability using BLHeli, and now I’m trying to understand how to account for this in the firmware. I have been trying to understand the file mixer_multirotor.cpp, to see if I can modify the mapping of the outputs to the range [-1,1], and have not had much success. I’ve also looked through mc_att_control_main.cpp, pwm.cpp, pwm_limit.c and motor_ramp.cpp. It’s a bit confusing and I don’t fully understand the process to get from the controller to the commands actually sent to the actuators. If someone can clarify any of this or point me in the right direction it would be much appreciated.

1 Like