Issue with Controlling Throttle Servo Through Lua Script on CUAV X7 Pro Plus with ArduPlane 4.6 Dev

Hello,

I am experiencing an issue with controlling a throttle servo via a Lua script on my CUAV X7 Pro Plus running ArduPlane 4.6 Dev firmware. I have set up channel 6 to manage both the minimum throttle position and arm/disarm functionalities. My SERVO2_FUNCTION in Mission Planner is set to 70 (Throttle), and I expected that changes made through the Lua script would allow me to adjust the throttle servo’s minimum position based on the switch’s position on my transmitter.

Problem: The script loads without any errors, but the servo does not respond to commands that should increase the minimum position of the throttle by 10%. Here are the key elements of my script:

lua

local switch_channel = 6
local throttle_servo = 2
local normal_min_pwm = 988
local increased_min_pwm = normal_min_pwm + (2011 - normal_min_pwm) * 0.1

function update_throttle_position()
    local pwm_value = rc:get_pwm(switch_channel)
    if pwm_value > 1500 then
        SRV_Channels:set_output_pwm(throttle_servo, increased_min_pwm)
    else
        SRV_Channels:set_output_pwm(throttle_servo, normal_min_pwm)
    end
    return update_throttle_position, 0.1
end

return update_throttle_position()

Questions:

  1. Is there anything in my approach or configuration that could be preventing the script from functioning correctly?
  2. What additional checks or settings would you recommend for troubleshooting and resolving this issue?
  3. Could using one channel for both throttle control and arm/disarm impact the script’s performance?

I would appreciate any help or guidance for further investigation!