Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Probably best to append a note about this request to the same thread in the sub-forum

I've had a quick look at the script. There is actually an error, of no real consequence, but which I think need correcting first:

In two places (lines 11 and 36) this appears:

 	 setfi(ipc.readSW(0x332E))[/CODE]

This is calling function "setfi" which is defined as:

[CODE]function setfi(off, val)[/CODE]

so the parameter, the value read from offset 332E is being supplied to that function as "offset" (!), whilst the value itself is not supplied at all and remains undefined.

The reason it is inconsequential is that neither "offset" nor "Val" are even actually referenced in the function "setfi"! Instead, it actually reads offset 332E again, in line 18.

There is another error which may have consequences but probably normally doesn't. The variable "timefi2 is referenced before being defined for the first time, which can cause a Lua error.

So the corrected script should be:

[CODE]-- v.2 ATR Idle Gate
timefi = 0

function onground(off,val)
if ipc.readUW(0x0366)==1 then
ipc.writeLvar("L:ATRIdleGate", 0)
ipc.writeUB(0x310A,0)
ipc.writeSW(0x088C, ipc.readSW(0x332E))
ipc.writeSW(0x0924, ipc.readSW(0x332E))
else
ipc.writeLvar("L:ATRIdleGate", 1)
setfi()
end
end

function setfi()
if ipc.readUW(0x0366)==0 then
if ipc.readLvar("L:ATRPLLeft_notch") == 0 then
if ipc.readSW(0x332E) <= 3600 then
if ipc.readUB(0x310A)==0 or ipc.elapsedtime()-timefi>4000 then
ipc.writeUB(0x310A, 8)
ipc.writeSW(0x088C, 3600)
ipc.writeSW(0x0924, 3600)
timefi = ipc.elapsedtime()
--ipc.log("TimeSet"..timefi) ----------------------------------------------------------------------------------
end
elseif ipc.readUB(0x310A)==8 then
ipc.writeUB(0x310A, 0)
end
else ipc.writeUB(0x310A, 0)
end
end
end

function checktime(time)
if ipc.readUW(0x0366)==0 and ipc.readSW(0x332E) <= 3600 then
setfi()
--ipc.log("TimeKick") ----------------------------------------------------------------------------------------------------------------------------------------------------
end
end

event.offset(0x0366,"UW","onground")
event.timer(5000,"checktime")
event.offset(0x332E, "SW", "setfi")[/CODE]

Now on to your question.

Offset 332E actually provides the calibrated input value for the generic all-engine throttle. You need this to reference Throttle 1 offset 3330 and throttle 2 offset 3332. Also note in the script references to

088C == actual throttle 1 control

0924 == actual throttle 2 control

310A == throttle disconnect control: value 8 = generic throttle. There are different values for thr1, thr2 and both.

So it gets a little bit more complicated. You need to process throttle 1 input on 3330 and output on 088C with bit 6 (value 64) in 310A, and also, simultaneously, throttle 2 input on 3332 and output on 0924 with bit 7(value 128) in 310A. I could sort this out for you except that I don't understand what the ATR Idle Gate is nor how two throttles would affect what appears to be only one "gate" or whatever. i.e. the functions of [b]L:ATRIdleGate[/b] and [b]L:ATRPLLeft_notch[/b]. How would the operation of the throttles separately affect these when they only appear to be single? Should there be a [b]L:ATRPLRight_notch[/b]? And is there only one [b]L:ATRIdleGate[/b]?

If the answer to this is "it doesn't matter" then the following modified code might work:

[CODE]-- v.2 ATR Idle Gate modified tentatively by Pete for twin throttle inputs ... ?
timefi1 = 0
timefi2 = 0

function onground(off,val)
if ipc.readUW(0x0366)==1 then
ipc.writeLvar("L:ATRIdleGate", 0)
ipc.clearbitsUB(0x310A,192)
ipc.writeSW(0x088C, ipc.readSW(0x3330))
ipc.writeSW(0x0924, ipc.readSW(0x3332))
else
ipc.writeLvar("L:ATRIdleGate", 1)
setfi()
end
end

function setfi()
if ipc.readUW(0x0366)==0 then
if ipc.readLvar("L:ATRPLLeft_notch") == 0 then
inhibits = ipc.readUB(0x310A)
if ipc.readSW(0x3330) <= 3600 then
if logic.And(inhibits,64) == 0 or ipc.elapsedtime()-timefi1>4000 then
ipc.setbitsUB(0x310A, 64)
ipc.writeSW(0x088C, 3600)
timefi1 = ipc.elapsedtime()
end
else ipc.clearbitsUB(0x310A, 64)
end
if ipc.readSW(0x3332) <= 3600 then
if logic.And(inhibits,128) == 0 or ipc.elapsedtime()-timefi2>4000 then
ipc.setbitsUB(0x310A, 128)
ipc.writeSW(0x0924, 3600)
timefi2 = ipc.elapsedtime()
end
else ipc.clearbitsUB(0x310A, 128)
end
else ipc.clearbitsUB(0x310A, 192)
end
end
end

function checktime(time)
if ipc.readUW(0x0366)==0 and
(ipc.readSW(0x3330) <= 3600 or ipc.readSW(0x3332) <= 3600) then
setfi()
end
end

event.offset(0x0366,"UW","onground")
event.timer(5000,"checktime")
event.offset(0x3330, "SW", "setfi")
event.offset(0x3332, "SW", "setfi")
[/CODE]

Sorry, but i can't test this or say that it works. Maybe the original contributor will see this, in its correct thread, and contribute.

Regards

Pete

Posted

Dear Pete,

Thank you for helping with this.

There is only one Idle Gate: "which prevents reducing power lever angle below flight idle so long as the aircraft is airborne, The gate is removed automatically when the aircraft is landed so that ground idle can be selected. An amber band is indicated when the idle gate is removed. The idle gate cannot be adjusted manually. Click the power levers with the right mouse button to cycle between flight idle and the Take-Off Notch."

There is a Left (Take-Off) Notch for the Left Throttle Axis and a separate Right (Take-Off) Notch for the Right Throttle Axis. The Take-Off Notch position is one of four positions into which each power lever can be inserted (the others being Ground Idle, Fwd Stop and Reverse). From the manual: "TO Notch: Indicates TO power setting. It is computed by the power management system. Click the power levers with the Right Mouse button to move power levers to the TO Notch." (I use FSUIPC mouse macros to achieve this.)

So I think there should be a L:ATRPLRight_notch and that there is only one L:ATRIdleGate.

Thank you again,

Chakko.

Posted

Hi to all,

I am the author of this script. I attach the most recent version of it. You better start working from there.

I cannot readily check Pete's feedback, but the script is working just fine without any abnormalities recorded in FSUIPC.log. So, maybe its suboptimal but works fine.

I am really sorry that I cannot provide any substantial help on the spot, but it has been some time since this was written, and I am far from fluent in programming.

I would need some time in the weekend to "reverse-engineer" my own script and dig into FSUIPC offsets.

I will also check some related detail regarding ATR handling (this is surely somewhere in my notes) and get back soon.

Regards

ATR_Idle_Gate_v_2.txt

Posted

ckovoor,

please try the attached script.

It must be working ok. I took into account all Pete's comments and recommendations (it is practically the same code he proposed in the first place).

After a "quick and dirty" test, please take note of the following:

  1. disable the script, and using FSUIPC on-screen Logging facility, monitor offsets 3330 and 3332 (both type S16). Make sure that when both 'Power Levers' are at 'Flight Idle' mark, the reading is 3200 and the Torque (in aircraft gauge) is appr. 14%. If not, make a note of the reading when your 'Power Levers' are exactly at 'Flight Idle' mark and Torque at 14%. Use this figure to replace "3200" wherever it appears in the script.
  2. While the Flight Idle setting above gives more realistic readings, better spoolup and better flare, there is one caveat. If you do a hi-speed approach (e.g. descending on ILS and decelarating using the "Decelaration Height=IASx10ft" rule) you will probably not decelarate on time. In order to overcome this, you have to assign in your FSUIPC GUI, a "LUA value". To do this:

  • locate a suitable switch in your joystick (best choice would be a spring loaded, toggle switch)
  • Go to "Buttons/Switches", check "Profile Specific", "Select for FS control" and select the switch you decided to use at its up position.
  • At "Control Sent when button pressed", select "LuaValue ATR_Idle_Gate", with "Parameter"=3200 (or whatever the number you came up with in point 1)
  • Repeat above two steps for your switch at down position, with "Parameter"=1

So now, before starting a hi-speed approach descent, just move your switch to the down position (in which you assigned "Parameter"=1).

In this manner, you are using a lower Flight Idle, that will permit deceleration as predicated by the "Decelaration Height=IASx10ft" rule. Still, just before threshold height, Flight Idle will revert to the higher value (without your intervention) and will help in flare.

Simulating turboprops in FSX has known weaknesses, and ATR is no exception. It seems that Flight1 could not find a way to have all things right at the same time. Newer turboprop models probably found better workarounds.

Note: After making sure that the script works for you, if you decide that you don't care about the double "Flight Idle" setting and the complexity, we can easily modify the script.

Please notify on your progress.

ATR_Idle_Gate_v_3.txt

Posted

Hi abax2000 and Pete,

Thank you so much for your time and effort over modifying the script, and for the additional notes. I have just tested the script and so far it seems to be working perfectly. I will get back to you again after more extensive testing.

Thank you again!

Chakko.

Posted

Hi abax2000,

After several flights, your v_3 script is still working perfectly.

I have so far been able to decelerate normally in flight idle, but would prefer to retain the option (that you have provided) of choosing a lower flight idle value for the eventuality you have described. So I would keep the script just as it is.

Maybe you could also post your v_3. script in the User Contributions subforum.

Thank you again for your time and effort!

Regards,

Chakko.

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.