How does motor mixing work?

Post Reply
sirbow2
Posts: 7
Joined: Sun Oct 14, 2012 7:13 am

How does motor mixing work?

Post by sirbow2 »

for fun im working on my own quad X firmware and i need help understanding motor mixing/how to implement it. i have all the other main code sections done:
RX data in
IMU reading
IMU calibration
R/P/Y values calculated
R/P Kalman
PID on R/P/Y
EEPROM storage (stick values, IMU stuff (going to be))

I need to do:
motor mixing
arming
save IMU data to EEPROM?
various code tweaks, mods etc

i got all the stuff except the motor mixing covered for sure. ive looked at the MWC 1.3 code (http://code.google.com/p/multiwii/source/browse/tags/MultiWiiV1_3/MultiWiiV1_3.pde?spec=svn9&r=9) since i thought it would be the simplest, but im still a bit confused.

i found this:

Code: Select all

#ifdef QUADX
    motor[FRONT_L] = 1500 + rcCommand[THROTTLE] + axisPID[ROLL] - axisPID[PITCH] - axisPID[YAW];
    motor[FRONT_R] = 1500 + rcCommand[THROTTLE] - axisPID[ROLL] - axisPID[PITCH] + axisPID[YAW];
    motor[REAR_L]  = 1500 + rcCommand[THROTTLE] + axisPID[ROLL] + axisPID[PITCH] + axisPID[YAW];
    motor[REAR_R]  = 1500 + rcCommand[THROTTLE] - axisPID[ROLL] + axisPID[PITCH] - axisPID[YAW];
    #endif

which seems pretty simple and is the main mixing part. does this mean i can do as it says but with my throttle + pid values? but it seems this RCcommand function is changing the values, why? to implement rate/expo?


also, ive attached the code so far for reference if anyone is interested.
Attachments
QuadXTest.zip
(6.48 KiB) Downloaded 183 times

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: How does motor mixing work?

Post by Hamburger »

yes, mixing does combine interpreted inputs (rx and sensors) into motor/servo outputs depending on geometric layout of your copter.
rcCommand[THROTTLE] is not a function but an array, I think. You are right it is derived from rx throttle input and computed wrt. expo.

User avatar
Gartenflieger
Posts: 65
Joined: Sat Oct 01, 2011 10:07 pm
Location: Dortmund, Germany

Re: How does motor mixing work?

Post by Gartenflieger »

I would think in 1.3 there was no expo on throttle.
I think you are correct in saying it is an array. The array holds the R/C stick positions.

P.S: By the way, I think it is a great idea to have a simplistic version as a starting point for those interested in programming.

sirbow2
Posts: 7
Joined: Sun Oct 14, 2012 7:13 am

Re: How does motor mixing work?

Post by sirbow2 »

i thought i would auto subscribe to any post/topic i made so i didnt see you guys ( where is that button/option, anyways?). and i jsut found rev1.0 here: http://code.google.com/p/multiwii/sourc ... svn18&r=18 this still worked in teh beginning, right? ( not missing any core functions).

oh btw, rev 1.0 does have some sort of expo/rate. see line 511

im thinking that the rcCommand whole purpose is for adding in mixing because the motor values start out with "1500 + " and rcCommand goes from -500 to 500... for a very first simulated test, this isnt important, so i think something like this will work:
motor[FRONT_L] = thrVal + axisPID[ROLL] - axisPID[PITCH] - axisPID[YAW];
motor[FRONT_R] = thrVal - axisPID[ROLL] - axisPID[PITCH] + axisPID[YAW];
motor[REAR_L] = thrVal + axisPID[ROLL] + axisPID[PITCH] + axisPID[YAW];
motor[REAR_R] = thrVal - axisPID[ROLL] + axisPID[PITCH] - axisPID[YAW];

sirbow2
Posts: 7
Joined: Sun Oct 14, 2012 7:13 am

Re: How does motor mixing work?

Post by sirbow2 »

im confused as i forgot about adding in YPR channels into the PID/motor mixing. any advice on how to do this? i figured it'd be easiest to just modify the PID values after they're calculated with their respective channels.

also, what does "windUp" do in PID calculations?

Post Reply