I´m using a PC with Windows 10 and X-Plane11 on it.
My problem is, that my hardware witch is connected to a Arduino Mega 2560, runs not smooth when I move both throttle handles. One of them (the right one) stutters or stucks at a position.
When I build a test bench with a breadboard, pot and wires it's the same. The DataRefTool in x-Plane11 shows also a stutter of the right throttle value.
The same when I move both Prop handles and both Mix handles. When I move just one throttle and one Prop handle, the are moving really smooth.
My LUA code is:
Code: Select all
----------------------------------------------------------------------
-- This is the script for the Throttle Quadrant with the Throttle ----
-- Prop, Mixture, Rudder Trim, Flap Handle, Flap Pos. Indicator LED --
-- It works on Channel D only ----------------------------------------
----------------------------------------------------------------------
--------------------------------------------------------------------
-- Rudder Trim
--------------------------------------------------------------------
function adc_rudder_trim(value)
print("The Ruddel Trim is now by " ..value)
-- X-Plane expects a value between -1 and 1,
xpl_dataref_write("sim/cockpit2/controls/rudder_trim", "FLOAT", (2 * value)-1)
end
-- Create a ADC input
hw_adc_input_add("ARDUINO_MEGA2560_D_A0", adc_rudder_trim)
--------------------------------------------------------------------
-- Throttle 1 LH
--------------------------------------------------------------------
-- For X-Plane we need to override the joystick input first
-- xpl_dataref_write("sim/operation/override/override_throttles", "INT", 1)
function adc_input_throttle_left(value)
print("The Throttle Nr.1 LH is now by " ..value)
-- percent = var_round(value, 3)
-- print("Input is at " .. percent .. "%")
-- val = var_cap((value - 0.033236) * (1/(0.951124-0.033236)))
-- X-Plane expects a value between 0 and 1, no conversion necessary
xpl_dataref_write("sim/flightmodel/engine/ENGN_thro", "FLOAT[8]", {((value - 0.033236) * (1/(0.951124-0.033236)))}, 0)
end
-- Create a ADC input
hw_adc_input_add("ARDUINO_MEGA2560_D_A1", adc_input_throttle_left)
--------------------------------------------------------------------
-- Throttle 2 RH
--------------------------------------------------------------------
-- For X-Plane we need to override the joystick input first
-- xpl_dataref_write("sim/operation/override/override_throttles", "INT", 2)
function adc_input_throttle_right(value)
print("The Throttle Nr.2 RH is now by " ..value)
-- X-Plane expects a value between 0 and 1, no conversion necessary
xpl_dataref_write("sim/flightmodel/engine/ENGN_thro", "FLOAT[8]", {((value - 0.038123) * (1/(0.946237-0.038123)))}, 1)
end
-- Create a ADC input
hw_adc_input_add("ARDUINO_MEGA2560_D_A2", adc_input_throttle_right)
--------------------------------------------------------------------
-- Propeller Pitch LH
--------------------------------------------------------------------
-- For X-Plane we need to override the joystick input first
-- xpl_dataref_write("sim/operation/override/override_prop_pitch", "INT", 1)
function adc_input_prop(value)
print("The Prop Pitch LH is in the Position" ..value)
--
xpl_dataref_write("sim/flightmodel/engine/ENGN_prop", "FLOAT[8]", {67.2 + (292 - 67.2) * value}, 0)
end
-- Create a ADC input
hw_adc_input_add("ARDUINO_MEGA2560_D_A3", adc_input_prop)
--------------------------------------------------------------------
-- Propeller Pitch RH
--------------------------------------------------------------------
-- For X-Plane we need to override the joystick input first
-- xpl_dataref_write("sim/operation/override/override_prop_pitch", "INT", 2)
function adc_input_prop(value)
print("The Prop Pitch RH is in the Position" ..value)
xpl_dataref_write("sim/flightmodel/engine/ENGN_prop", "FLOAT[8]", {71.2 + (291 - 71.2) * value}, 1)
end
-- Create a ADC input
hw_adc_input_add("ARDUINO_MEGA2560_D_A4", adc_input_prop)
--------------------------------------------------------------------
-- Mixture LH
--------------------------------------------------------------------
-- For X-Plane we need to override the joystick input first
-- xpl_dataref_write("sim/operation/override/override_mixture", "INT", 1)
-- Callback function which is called when the ADC input state changes
-- 0.0 : GND (lowest voltage)
-- 1.0 : VCC (highest voltage)
function adc_input_mixt(value)
print("The Mixture LH is now by " ..value)
-- X-Plane expects a value between 0 and 1, no conversion necessary
xpl_dataref_write("sim/flightmodel/engine/ENGN_mixt", "FLOAT[8]", {((value - 0.01173) * (1/(0.980382-0.01173)))}, 0)
end
-- Create a ADC input
hw_adc_input_add("ARDUINO_MEGA2560_D_A5", adc_input_mixt)
--------------------------------------------------------------------
-- Mixture RH
--------------------------------------------------------------------
-- For X-Plane we need to override the joystick input first
-- xpl_dataref_write("sim/operation/override/override_mixture", "INT", 2)
-- Callback function which is called when the ADC input state changes
-- 0.0 : GND (lowest voltage)
-- 1.0 : VCC (highest voltage)
function adc_input_mixt(value)
print("The Mixture RH is now by " ..value)
-- X-Plane expects a value between 0 and 1, no conversion necessary
xpl_dataref_write("sim/flightmodel/engine/ENGN_mixt", "FLOAT[8]", {((value - 0.077224) * (1/(0.993157-0.077224)))}, 1)
end
-- Create a ADC input
hw_adc_input_add("ARDUINO_MEGA2560_D_A6", adc_input_mixt)
For the video with the Multi Throttle Problem. Please click here:
https://vimeo.com/529725750
https://vimeo.com/529725730
For the video of the Multi Prop Problem. Please click here:
https://vimeo.com/529725771
For the video with the Single Throttle movement. And the video with the single Throttle and single Prop movement. Please click here:
https://vimeo.com/529725771
https://vimeo.com/529725799
Hope that with the videos works and someone has an idea. My brain is lost .