How to control servo motor using SRV_Channels?

Hi,

We have developed and tested tilt quad copter, two dimensional vectored thrust machines from ArduCopter.
It works well.
Servo motors are used to tilt rotors or deflection nozzle.



In those source code, first, we add the code as
add_motor_raw(AP_MOTORS_MOT_5, 0.0f, 0.0f, 0.0f, 5);
add_motor_raw(AP_MOTORS_MOT_6, 0.0f, 0.0f, 0.0f, 6);
for servo motor which are connected to Pixhawk.

Then, set output PWM value as
// elevator and rudder
motor_out[LeftPlate] = LeftTrim+_thrust_rpyt_out[7];
motor_out[RightPlate] = RightTrim+_thrust_rpyt_out[7];

After, they are output as
// send output to each motor
for (i=0; i<AP_MOTORS_MAX_NUM_MOTORS; i++) {
if (motor_enabled[i]) {
rc_write(i, motor_out[i]);
}
}
https://github.com/ZetaMiw/ardupilot/blob/Copter-3.6/libraries/AP_Motors/AP_MotorsMatrix.cpp

This way succeeded to output pwm signals.
But in this way, we must build every time when we want to set new trim pwm values.
So, we want to use SRV_Channels.

We tried as:
// right servo defaults to servo output 5
SRV_Channels::set_aux_channel_default(SRV_Channel::k_tiltMotorRight, CH_5);
// left servo defaults to servo output 6
SRV_Channels::set_aux_channel_default(SRV_Channel::k_tiltMotorLeft, CH_6);

SRV_Channels::set_output_pwm_trimmed(SRV_Channel::k_tiltMotorLeft,_thrust_rpyt_out[7]);
SRV_Channels::set_output_pwm_trimmed(SRV_Channel::k_tiltMotorRight,_thrust_rpyt_out[7]);

SRV_Channels::calc_pwm();
SRV_Channels::output_ch_all();

We used Mission Planner : Servo output to check/set servo function.
But, 5ch and 6ch always output 1100usec.
I think that it lacks to activate servo motors.

Please give me some help.

I think for tilting motors you cant use MotorsMatrix anyway, it assumes all the coefficients are constant. Probibly a good place to start would be to have a look at the tricotper, single copter and tailsitter motors files.

SRV_Channels::enable_aux_servos() after SRV_Channels::set_aux_channel_default(SRV_Channel::k_tiltMotorLeft, CH_6);

I am trying to do the same - I have not tested yet

Hi,

Is there any progress to this problem?
I encountered a similar problem with @miw01. The CH_1 always output 2000 us, and other channels always 0. (Even I assigned CH_3 or other channels for output)

I have tested the method using hal.rcout in examples/RCOutput, and I got the desired result. So I think it is not a hardware or routing problem.

Several attempts:

  • I test the solution from @iamczar, but it seems not work.
  • I also tried to add SRV_Channels::push(); after SRV_Channels::output_ch_all();, however, the console down after I added this line.

I’m wondering if the SRV_Channel can be run individually. Or I need to enable the motor in other ways.

Here is my code