Page 1 of 1

flipping the motor direction in the firmware.

Posted: Thu Mar 11, 2021 4:54 am
by cafeciaojoe
Hi,

I am looking to reverse the direction of the motors such that the motors can be mounted upside down, but the chassis remains the same.

From this old post viewtopic.php?p=16079#p16079 Tobias flipped the signs in the powerDistribution function definition.
tobias wrote: Fri Feb 01, 2019 11:07 am I gave it a quick shot and it this worked.

Then since it is now up-side-down I flipped M1.M4 and M2,M3 in power distribution

Code: Select all

void powerDistribution(const control_t *control)
{
...    
    motorPower.m4 = limitThrust(control->thrust - r + p + control->yaw);
    motorPower.m3 = limitThrust(control->thrust - r - p - control->yaw);
    motorPower.m2 =  limitThrust(control->thrust + r - p + control->yaw);
    motorPower.m1 =  limitThrust(control->thrust + r + p - control->yaw);
...
I also tried

Code: Select all

    
    motorPower.m4 = limitThrust(-control->thrust - r + p + control->yaw);
    motorPower.m3 = limitThrust(-control->thrust - r - p - control->yaw);
    motorPower.m2 =  limitThrust(-control->thrust + r - p + control->yaw);
    motorPower.m1 =  limitThrust(-control->thrust + r + p - control->yaw);    
This did not work, probably because the problem in this post was also flipping the whole chassis.

NOTE: I can use stock firmware and just reverse polarity of the motors, flip them upside down, then keeping the props facing the same direction. But i would prefer to do it in the firmware than always be flipping the polarity of the plugs.

Re: flipping the motor direction in the firmware.

Posted: Thu Mar 11, 2021 7:13 am
by kristoffer
What about swapping the propellers?

Re: flipping the motor direction in the firmware.

Posted: Thu Mar 11, 2021 7:32 am
by cafeciaojoe
that does get the drone off the ground, but the yaw is uncontrollable. it spins really fast then crashes.

Re: flipping the motor direction in the firmware.

Posted: Thu Mar 11, 2021 9:23 am
by wydmynd
I think you need to flip something in the IMU too

Re: flipping the motor direction in the firmware.

Posted: Thu Mar 11, 2021 9:34 am
by kristoffer
I did a quick test and it actually works pretty well :-)
I flipped the motor mounts up-side down (and flipped the propellers to keep the convex side up) and swapped the A and B propellers.

Since the motors are spinning in the other direction you have to change the sign of the yaw in the power distribution

motorPower.m1 = limitThrust(control->thrust - r + p - control->yaw);
motorPower.m2 = limitThrust(control->thrust - r - p + control->yaw);
motorPower.m3 = limitThrust(control->thrust + r - p - control->yaw);
motorPower.m4 = limitThrust(control->thrust + r + p + control->yaw);

If you put the battery under the CF you move the center of mass down to a better position which makes the platform more stable

This was fun!

Re: flipping the motor direction in the firmware.

Posted: Fri Apr 16, 2021 4:48 am
by cafeciaojoe
:oops:

Well yes that makes a lot of sense Thanks for that!