# Motor Mixers Block

Hey,
i’m trying to understand the ardupilot Code.
Where can i find the ‘Motor Mixers’ Block in the Code?
So where is the Motor Control done, for receveiving the percentage motor throttle from a pilot stick input ?

Thanks

Depending on your particular frame type, it’s one of the files in here.

hi James_pattison,

i already looked into AP_Motors, but can’t find where the mixing is done.
I’m using a quadrocopter with x-configuration.

The output mixing is basically driven by the configurations defined in motorsmatrix.

Perhaps if you could explain what you are trying to do it would be easier to steer in the right direction.

Also, some light reading here may lead you to what you’re looking for.

http://ardupilot.org/dev/docs/apmcopter-programming-attitude-control-2.html

Exactly that’s what i’m trying to do. I already built up a Simulink model from the control Loop, like it’s done in the ardupilot code. Now i want to generate the ‘Motors Block’ (last element in the pic), which get’s the pwm output from the control loop.

Thanks maybe i found what i’m searching for in AP_MotorsMatrix.cpp:

// calculate roll and pitch for each motor
// calculate the amount of yaw input that each motor can accept
for (i=0; i<AP_MOTORS_MAX_NUM_MOTORS; i++) {
if (motor_enabled[i]) {
_thrust_rpyt_out[i] = roll_thrust * _roll_factor[i] + pitch_thrust * _pitch_factor[i];
if (!is_zero(_yaw_factor[i])){
if (yaw_thrust * _yaw_factor[i] > 0.0f) {
unused_range = fabsf((1.0f - (throttle_thrust_best_rpy + _thrust_rpyt_out[i]))/_yaw_factor[i]);
if (yaw_allowed > unused_range) {
yaw_allowed = unused_range;
}
} else {
unused_range = fabsf((throttle_thrust_best_rpy + _thrust_rpyt_out[i])/_yaw_factor[i]);
if (yaw_allowed > unused_range) {
yaw_allowed = unused_range;
}
}
}
}
}

I’m trying to built a Simulink Model from the ardupilot Code in the Stabilize Mode, for calculating the PID’s without the AUTOTUNE function.

3 Likes

Nice, it’ll be interesting to see a Simulink model of the code. I haven’t played in simulink since college.