Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make servoMixer work for types other than CUSTOM_PLANE #289

Merged
merged 3 commits into from
Jul 15, 2015

Conversation

lazd
Copy link
Contributor

@lazd lazd commented Jul 15, 2015

Motivation

I wanted to use the servo mixer to assign a certain switch to control a servo on a certain ESC header on my quadcopter.

This change lets you enable the servo mixer for and create rules to do just that.

Usage: Control servos on a QUADX

# Be a QUADX
mixer QUADX

# Enable servo mixer
feature SERVO_MIXER

# Reset servo mixer
smix reset

# Control servo output 1 with channel 7 (AUX_3)
smix 1 1 7 100 0 0 100 0

# Control servo output 2 with channel 8 (AUX_4)
smix 2 2 8 100 0 0 100 0

The wiring is as follows:

Header 1: Servo 1
Header 2: Servo 2
Header 3: Motor 1
Header 4: Motor 2
Header 5: Motor 3
Header 6: Motor 4

Changes

  • Added SERVO_MIXER feature to enable the servo mixer regardless of craft type
  • Reset servos before applying servo values due to SERVO_TILT feature or GIMBAL type
  • Servo mixer rules can override values set by SERVO_TILT feature and GIMBAL type
  • Only apply rates to servo values affected by servo mixer rules
  • Apply servo values to channels 1 and 2 when SERVO_MIXER feature is enabled
  • Fix bug where input values in servoMixer were reversed due to subtracting the RC value from the RC middle value
  • Center all servos by default
  • Do gimbal AUX forwarding inside of writeServos()

When is servo mixer enabled?

Assuming you've set feature SERVOMIXER, the servo mixer is enabled as follows, based on your type:

Servo mixer is enabled and works as it currently does, but only on the servos that are already used by this multitype

  • MULTITYPE_CUSTOM_PLANE
  • MULTITYPE_FLYING_WING
  • MULTITYPE_AIRPLANE
  • MULTITYPE_BI
  • MULTITYPE_TRI
  • MULTITYPE_DUALCOPTER
  • MULTITYPE_SINGLECOPTER
  • MULTITYPE_GIMBAL

Servo mixer works for servos 1 and 2

  • MULTITYPE_GIMBAL
  • MULTITYPE_QUADP
  • MULTITYPE_QUADX
  • MULTITYPE_GIMBAL
  • MULTITYPE_Y6
  • MULTITYPE_HEX6
  • MULTITYPE_Y4
  • MULTITYPE_HEX6X
  • MULTITYPE_OCTOX8
  • MULTITYPE_OCTOFLATP
  • MULTITYPE_OCTOFLATX
  • MULTITYPE_HELI_120_CCPM
  • MULTITYPE_HELI_90_DEG
  • MULTITYPE_VTAIL4
  • MULTITYPE_HEX6H
  • MULTITYPE_PPM_TO_SERVO
  • MULTITYPE_ATAIL4
  • MULTITYPE_CUSTOM
  • MULTITYPE_CUSTOM_PLANE

* Added SERVO_MIXER feature to enable the servo mixer regardless of craft type
* Reset servos before applying servo values due to SERVO_TILT feature or GIMBAL type
* Servo mixer rules can override values set by SERVO_TILT feature and GIMBAL type
* Only apply rates to servo values affected by servo mixer rules
* Apply servo values to channels 1 and 2 when SERVO_MIXER feature is enabled
* Fix bug where input values in servoMixer were reversed due to subtracting the RC value from the RC middle value
* Center all servos by default
@ghost
Copy link

ghost commented Jul 15, 2015

Can one of the admins verify this patch?

@@ -463,6 +474,13 @@ void writeAllMotors(int16_t mc)
writeMotors();
}

static void resetServos(void) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style

@lazd lazd force-pushed the servomixerfeat branch from 03d54c5 to b026b39 Compare July 15, 2015 17:25
// run the servo mixer if necessary
if (core.useServo == 1) {
servoMixer();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single line if does not need braces

@lazd lazd force-pushed the servomixerfeat branch from b026b39 to 5999692 Compare July 15, 2015 17:30
@@ -588,20 +606,14 @@ void mixTable(void)
}
}

// run the servo mixer if necessary
if (core.useServo == 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just if (core.useServo) is fine, rest of the code does this

@lazd lazd force-pushed the servomixerfeat branch from 5999692 to badb6b0 Compare July 15, 2015 17:34
@lazd lazd force-pushed the servomixerfeat branch from badb6b0 to 4a84151 Compare July 15, 2015 17:36
trollcop added a commit that referenced this pull request Jul 15, 2015
Make servoMixer work for types other than CUSTOM_PLANE
@trollcop trollcop merged commit ba9c0d2 into multiwii:master Jul 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants