Multi Engine Throttles have not a smooth movement

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

Message
Author
User avatar
Huberflight
Posts: 42
Joined: Sat Mar 31, 2018 2:27 pm

Multi Engine Throttles have not a smooth movement

#1 Post by Huberflight »

Hello Simmers,

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)
I made some videos to explain my Problem. Unfortunately I can't load them up. So I will put the Vimeo links in this post. I hope that is ok.

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 :( .
When it looks not right, go around. It's easier to explain why you done it, than for others to finde out why you don't.

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Multi Engine Throttles have not a smooth movement

#2 Post by Ralph »

An easy debug method would be to flip the ADC inputs around and see if the same thing happens on the left.

User avatar
Huberflight
Posts: 42
Joined: Sat Mar 31, 2018 2:27 pm

Re: Multi Engine Throttles have not a smooth movement

#3 Post by Huberflight »

Hi Ralph,

Thank you for your tip.
When the Tire is on the left Side is flat. Put it on the Right :D .

- I have fliped the ADC Inputs...
- Changed the RPI...
- Changed the Arduino...
- Changed the architeture (Arduino UNO instand of Mega)
- Changed the cables...
- Changed the hole System (PC, RPI, Arduino, USB cable, cables, Power suply, Poti)...

All With the Same result. No change.
When it looks not right, go around. It's easier to explain why you done it, than for others to finde out why you don't.

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Multi Engine Throttles have not a smooth movement

#4 Post by Ralph »

No change meaning?

User avatar
Huberflight
Posts: 42
Joined: Sat Mar 31, 2018 2:27 pm

Re: Multi Engine Throttles have not a smooth movement

#5 Post by Huberflight »

The situation is the Same like before. The Throttles stutter when they are moved together.
Mainly the Right one (Engine 2). But Engine1 sometimes to. The Same with the Prop‘s and Mixture handles.

I also measured the voltage directly at the poti output. At the WOT stop and the Idle stop there was always the Same voltage. But the throttles in x-plane stucks sometimes before this positions.
When it looks not right, go around. It's easier to explain why you done it, than for others to finde out why you don't.

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Multi Engine Throttles have not a smooth movement

#6 Post by Ralph »

It's still not really clear to me. Did you for example try to assign a different axis to the right side, like mixture, to see what happens? Did you try to print the values to see what the ADC values from the Arduino are? Are you 100% sure that the grounding is properly done, so no distortion?

User avatar
Huberflight
Posts: 42
Joined: Sat Mar 31, 2018 2:27 pm

Re: Multi Engine Throttles have not a smooth movement

#7 Post by Huberflight »

Ralph wrote: Mon Mar 29, 2021 6:10 am It's still not really clear to me. Did you for example try to assign a different axis to the right side, like mixture, to see what happens?
Yes, I changed the input of the Throttle LH & RH with an input of the Prop (LH & RH) and the input the Mixture (LH & RH).
The Problem still exist (single handle movement is ok, both movement are stutter and sometimes it's stuck.

Ralph wrote: Mon Mar 29, 2021 6:10 am Did you try to print the values to see what the ADC values from the Arduino are?

Yes, I have the print order implemented in my code. It stutters and stucks to when both handles are used.
The DataRef tool in X-Plane shows also the same.

Ralph wrote: Mon Mar 29, 2021 6:10 am Are you 100% sure that the grounding is properly done, so no distortion?
Yes, because I build a complete new test setup with another breadboard, cables, Arduino Mega, Pot´s, USB cable, RPI with the same result.
the Problem still exist.
IMG_01172 Kopie.jpg
When it looks not right, go around. It's easier to explain why you done it, than for others to finde out why you don't.

User avatar
Ralph
Posts: 7876
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Multi Engine Throttles have not a smooth movement

#8 Post by Ralph »

I suppose you also tried different ADC pins? Other Arduino maybe? Did you flash the Arduino with the latest firmware?

User avatar
Huberflight
Posts: 42
Joined: Sat Mar 31, 2018 2:27 pm

Re: Multi Engine Throttles have not a smooth movement

#9 Post by Huberflight »

Ralph wrote: Mon Mar 29, 2021 6:13 pm I suppose you also tried different ADC pins?
Yes, all of them ;).
Ralph wrote: Mon Mar 29, 2021 6:13 pm Other Arduino maybe?
I tried 2 other Arduino Mega and one Arduino UNO.
Ralph wrote: Mon Mar 29, 2021 6:13 pm Did you flash the Arduino with the latest firmware?
I flash the Arduino‘s with Air Manager 3.7.1.
Is that what you mean?
When it looks not right, go around. It's easier to explain why you done it, than for others to finde out why you don't.

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Multi Engine Throttles have not a smooth movement

#10 Post by jph »

Hi,
Hope @Ralph doesnt mind me saying but imho - This sounds very much like a timing issue and not a hardware issue.
I would suggest that for any kind of multi axis joystick input that a HID game controller is used. Either an Arduino with the 32U4 processor acting as a HID Game Controller with the appropriate arduino library or a Bodner board.
This would then feed directly to X-Plane (or any other sim) via Windows in a native HID format. I don't think that AM is the best option for this kind of use. You are adding unnecessary layers of complexity with Arduino to Rasb Pi to Windows via a non native format that is already fully catered for in Windows.
Joe.
Joe. CISSP, MSc.

Post Reply