Jump to content
The simFlight Network Forums

Support for more than 4 engines


kaha

Recommended Posts

Is there a possibility to bind a hardware axis to throttle, prop and mixture of engine numbers greater than 4?

I only succeeded to bind the throttle axis using Avars (A:GENERAL ENG THROTTLE LEVER POSITION:nr)

Maybe this is a sim restriction?

 

Karl

Link to comment
Share on other sites

3 hours ago, kaha said:

Is there a possibility to bind a hardware axis to throttle, prop and mixture of engine numbers greater than 4?

MSFS only provides events/controls for 4 engines, and FSUIPC only has in-built support for up to 4 engines, and the offsets only hold the simvars (A-type variables) for 4 engines.

3 hours ago, kaha said:

I only succeeded to bind the throttle axis using Avars (A:GENERAL ENG THROTTLE LEVER POSITION:nr)

How are you doing this - using offsets? The GENERAL ENG THROTTLE LEVER POSITION simvar is currently held in offset
    0x38A8 - engine/index 4
    0x3968 - engine/index 3
    0x3A28 - engine/index 2
    0x3AE8 - engine/index 1
with mixture and prop lever positions held in adjacent offsets (see the offset status document).

You can add this simvar with indices 5 & 6 (for engines 5 and 6) to offsets designated as 'free for general use' using the facilities provided - see the section Adding Simulator variables (simvars) to FSUIPC offsets in the Advanced User guide for details. However, the SDK documentation does say (see https://docs.flightsimulator.com/html/Programming_Tools/SimVars/Aircraft_SimVars/Aircraft_Engine_Variables.htm#note😞

Quote

NOTE: Many of the SimVars listed above require an engine index. This is a value between 1 and 4 that signals which of the engines on the aircraft is being targeted to get or set the value for the SimVar.

so maybe this isn't possible... You can try this, and you will see an error in the log if the simvar with indices 5 and 6 are not available, although I suspect that this is a documentation error.

Alternatively, you could define your own preset to update these simvars, and then assign your axis to the preset.
For example, to define your own preset to control all 6 engines on one axis, add the following line to your myevents.txt file (create this file in your FSUIPC7 installation folder if it doesn't exist):
     

Six Engine Throttle#$Param 16383 + 32767.0 / (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) $Param 16383 + 32767.0 / (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100) $Param 16383 + 32767.0 / (>A:GENERAL ENG THROTTLE LEVER POSITION:3, percent over 100) $Param 16383 + 32767.0 / (>A:GENERAL ENG THROTTLE LEVER POSITION:4, percent over 100) $Param 16383 + 32767.0 / (>A:GENERAL ENG THROTTLE LEVER POSITION:5, percent over 100) $Param 16383 + 32767.0 / (>A:GENERAL ENG THROTTLE LEVER POSITION:6, percent over 100)

(assuming axis value goes from -16383 to +16282)

Then, in the axis assignment panel, move your axis lever and check Select for Preset and Send to FS as normal axis, and then select the preset Six Engine Throttle from the drop-down.

However, I have just tried this and it doesn't seem to work...it functions correctly if you reduce the code to control one throttle, but not when trying to control two or more... not sure why this is at the moment. I will look into this further and get back to you.

John

 

 



     

Link to comment
Share on other sites

Thank you.

 

I control throttles individually in a lua script using execCalcCode. This works from engine 1 to engine 6.

        calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:1, Percent)"
        ipc.execCalcCode(calc_code)

 

There are also variables for mixture and pitch: A:GENERAL ENG THROTTLE LEVER POSITION:1 and A:GENERAL ENG PROPELLER LEVER POSITION:1, but they only work for engines 1 to 4.

Just wanted to be sure that those variables cannot be accessed somehow.

Karl

 

Link to comment
Share on other sites

4 minutes ago, kaha said:

I control throttles individually in a lua script using execCalcCode. This works from engine 1 to engine 6.

        calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:1, Percent)"
        ipc.execCalcCode(calc_code)

Ok, that makes sense, and is basically what the preset does. I don't understand why you cannot control multiple throttles in the same calculator code string though.

7 minutes ago, kaha said:

There are also variables for mixture and pitch: A:GENERAL ENG THROTTLE LEVER POSITION:1 and A:GENERAL ENG PROPELLER LEVER POSITION:1, but they only work for engines 1 to 4.

Then this should be raised with Asobo. However, the documentation does say only for engines 1-4, so you are lucky that the throttle works for indices 5 & 6. Probably worth asking in the Asobo SDK forums though - or I can do this if you like.

8 minutes ago, kaha said:

Just wanted to be sure that those variables cannot be accessed somehow.

If they don't change via calc code, then I suspect not. You could try adding them to an FSUIPC offset, but I suspect this would only work for the throttle simvar with indices 5 & 6, and you will get an error (something like 'index out of bounds') with the prop and mixture ones.

John

Link to comment
Share on other sites

1 minute ago, John Dowson said:

Ok, that makes sense, and is basically what the preset does. I don't understand why you cannot control multiple throttles in the same calculator code string though.

I have 2 throttle levers and what I'm actually doing is controlling the left 3 and the right 3 seperately, or (by a switch) all 6 using the left throttle.


 

event.offset (0x25F0, "SW", "throttle1")    
event.offset (0x25F2, "SW", "throttle2")    


function throttle1(offset, value)    
    if user_aircraft_type:find(special_aircraft_names["BAE146"], 1, true) then
        ipc.control(67103, value)
        ipc.control(67110, value)
        if logic.And(ipc.buttons("C"), 8388608) == 8388608 then    
            ipc.control(67117, value)
            ipc.control(67124, value)
        end
    elseif user_aircraft_type:find(special_aircraft_names["LATECOERE"], 1, true) then
        value = ((value + 16384) / 32767.0) * 100.0
        value = value > 99.0 and 100 or value < 1.0 and 0 or value
        calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:1, Percent) " ..
                    value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:2, Percent) " ..
                    value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:3, Percent) " 
        ipc.execCalcCode(calc_code)
        if logic.And(ipc.buttons("C"), 8388608) == 8388608 then    
            calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:4, Percent) " ..
                        value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:5, Percent) " ..
                        value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:6, Percent) " 
            ipc.execCalcCode(calc_code)
        end
    else
        ipc.control(67103, value)
        if logic.And(ipc.buttons("C"), 8388608) == 8388608 then    
            ipc.control(67110, value)
        end
    end
end

function throttle2(offset, value)    
    if user_aircraft_type:find(special_aircraft_names["BAE146"], 1, true) then
        if logic.And(ipc.buttons("C"), 8388608) ~= 8388608 then    
            ipc.control(67117, value)
            ipc.control(67124, value)
        end
    elseif user_aircraft_type:find(special_aircraft_names["LATECOERE"], 1, true) then
        value = ((value + 16384) / 32767.0) * 100.0
        value = value > 99.0 and 100 or value < 1.0 and 0 or value
        if logic.And(ipc.buttons("C"), 8388608) ~= 8388608 then    
            calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:4, Percent) " ..
                        value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:5, Percent) " ..
                        value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:6, Percent) " 
            ipc.execCalcCode(calc_code)
        end
    else
        if logic.And(ipc.buttons("C"), 8388608) ~= 8388608 then    
            ipc.control(67110, value)
        end
    end
end

 


Karl

  • Like 1
Link to comment
Share on other sites

On 6/21/2023 at 5:20 PM, kaha said:
            calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:4, Percent) " ..
                        value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:5, Percent) " ..
                        value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:6, Percent) " 

Does this work? I have found that sending a value to multiple lvars in his manner doesn't work. You have to use registers, i.e.

Quote

calc_code = value .. " s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:4, Percent) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:5, Percent) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:6, Percent) " 

Also, better to use 'Percent over 100', so
     value = (value + 16384) / 32767.0
     ...
     calc_code = value .. " s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:4, Percent over 100) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:5, Percent over 100) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:6, Percent over 100) " 

On 6/21/2023 at 5:20 PM, kaha said:
        value = value > 99.0 and 100 or value < 1.0 and 0 or value

That syntax is new to me....looks strange, does it work?

Link to comment
Share on other sites

Hello John,

Doing 

		calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:1, Percent) " ..
					value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:2, Percent) " ..
					value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:3, Percent) " 
		ipc.execCalcCode(calc_code)

is the same as this, I think. At least it works perfectly:

		calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:1, Percent)"
		ipc.execCalcCode(calc_code)
		
		calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:2, Percent)"
		ipc.execCalcCode(calc_code)
		
		calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:3, Percent)" 
		ipc.execCalcCode(calc_code)

But maybe I'm missing something concerning "ipc.execCalcCode()?

 

 

This:

value = value > 99.0 and 100 or value < 1.0 and 0 or value

can be done due to the fact that true and false work differently in lua than in any other language. It makes sure that any value greater than 99.0 becomes 100.0 and any value smaller than 1.0 becomes 0.0

The construct

x > y and a or b

would in C/C++ read:

x > y ? a : b;

 

Link to comment
Share on other sites

2 hours ago, kaha said:

At least it works perfectly:

Ok, but I am surprised at this as it doesn't work here...I can only get it to work using registers.

2 hours ago, kaha said:

The construct

x > y and a or b

would in C/C++ read:

x > y ? a : b;

Ok, interesting - I didn't know that syntax in lua....!

John

Link to comment
Share on other sites

This:

value = 34	

calc_code = value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:1, Percent) " ..
			value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:2, Percent) " ..
			value .. " (>A:GENERAL ENG THROTTLE LEVER POSITION:3, Percent) " 

ipc.execCalcCode(calc_code)

results in the following string being executed:

"34 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, Percent) 34 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, Percent) 34 (>A:GENERAL ENG THROTTLE LEVER POSITION:3, Percent) "

This should be perfectly valid RPN code, isn't it?

 

What do you mean when you say "using registers"

Link to comment
Share on other sites

23 minutes ago, kaha said:

This should be perfectly valid RPN code, isn't it?

it is valid RPN code, but it doesn't do what you expect when I tried it - there is a discussion about this on the MobiFlight discord channel: https://discord.com/channels/608690978081210392/1028408626643214336/threads/1121089790553632850

If it works as expected for you, then thats fine. Just didn't work for me. i was testing using presets, not lua, but they both use the same mechanism to execute the calculator code, so not sure why it works for you but not for me.

28 minutes ago, kaha said:

What do you mean when you say "using registers"

Look a the the code i provided:

On 6/26/2023 at 1:05 PM, John Dowson said:

calc_code = value .. " s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:4, Percent) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:5, Percent) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:6, Percent) " 

The value provided is stored in register 0 (s0), and then the register is used to provide the value for the subsequent simvars (l0). I am no expert in using registers in calc code - this was provided by the MF team in that thread I referenced. I started that thread as the calc code in the style you are using wasn't working for me and I couldn't understand why.

 

Link to comment
Share on other sites

Ok, I see.

I am not familiar with this calc code language. I just thought, by looking at code in some .xml files, that this could work.

But it'S strange, why does it work here and not for you? What was your code?

Link to comment
Share on other sites

14 minutes ago, kaha said:

But it'S strange, why does it work here and not for you?

I have no idea....

14 minutes ago, kaha said:

What was your code?

I was testing with presets. Simplest example, to just set lever to 50% on a button press, this works:

Test Two Engine Throttle 50#0.5 s0 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) l0 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)

but this doesn't:

Test Two Engine Throttle 50#0.5 (>A:GENERAL ENG THROTTLE LEVER POSITION:1, percent over 100) 0.5 (>A:GENERAL ENG THROTTLE LEVER POSITION:2, percent over 100)

For further information, see that discord thread.
 

No idea why...

 

Link to comment
Share on other sites

23 minutes ago, kaha said:

Are you using this in a permanent lua script or in a button assignment? Maybe it's a timing matter? Life time of variables in Lua?

I only set up some tests with presets for this (not lua - but the underlying mechanism that executes the calc code is the same) both using buttons and axis assignments. As I said, it didn't work for me when sent using the same value to set multiple simvars, only when using registers. I don't know or understand why. Something else may be going on - I also had an issue with two presets that looked/are exactly the same, but one works and the other not, so it could be related to this.

I don't have time to look into this further at the moment. I may revisit this at some other point. Just use whatever works for you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.