Jump to content

Recommended Posts

Some Large Aircraft with a lot of weight have a OPTIMAL altitude, N1 and Speed based on the Actual Weight of the plane.

When the 744 make a large trip they Do Step Climbs. My idea is use Gizmo to make a Step Climb for a very long trip about 14 to 15 Hours. with a 744

So I try to make this Script, but Can manage the autopilot Functions the right way ( my mistake).

Maybe some one can hel with the right way to control the Plane Autopilot...

In the code I calculate the actual plane weight, then based in the IF statement, the Script give the Optimal Cruise Altitude. Then when the plane is Above 2.000 Ft the Gizmo Auto pilot script take control, using FLY LEVEL CHANGE and taking care of the Engine N1, that have to be 93 % all the way to the Cruise Altitude.

The plane Go Up to the optimal altitude, but when the plane Weight Change do to the Fuel BURN the plane dont go UP to the new optimal Altitude... (GIZMO Update the new optimal altitude in the AUTOPILOT cockpit) but cant manage that autoplitot activate the FLY LEVEL CHANGE for the second time..... HERE IS WHERE I NEED SOME ADVICE...


function main()
get_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ft
dr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total")
g_total_weight =  xp.getFloat(dr_sim_total_weight)  * 2.20462262
if (g_total_weight > 880000) then -- > 400.000 kgs
cruisealt = 27000
elseif (g_total_weight < 879000 and g_total_weight > 837000) then -- entre 380.000 y 400.000 kgs
cruisealt = 29000
elseif (g_total_weight < 836999 and g_total_weight > 794000) then -- entre 360.000 y 380.000 kgs
cruisealt = 31000
elseif (g_total_weight < 793999 and g_total_weight > 750000) then -- entre 340.000 y 360.000 kgs
cruisealt = 33000
elseif (g_total_weight < 749999 and g_total_weight > 705000) then -- entre 320.000 y 340.000 kgs
cruisealt = 35000
elseif (g_total_weight < 704999 and g_total_weight > 661000) then -- entre 300.000 y 320.000 kgs
cruisealt = 35000
elseif (g_total_weight < 660999 and g_total_weight > 617000) then -- entre 280.000 y 300.000 kgs
cruisealt = 37000
elseif (g_total_weight < 616999 and g_total_weight > 573000 ) then -- entre 260.000 y 280.000 kgs
cruisealt = 39000
elseif (g_total_weight < 572999 and g_total_weight > 529000 ) then -- entre 240.000 y 260.000 kgs
cruisealt = 41000
elseif (g_total_weight < 528999 and g_total_weight > 485000 ) then -- entre 220.000 y 240.000 kgs
cruisealt = 43000
elseif (g_total_weight < 484999 ) then -- entre 220.000 y 240.000 kgs
cruisealt = 43000
end
---- hasta qui

-- Control del piloto automatico
AUTOPILOT = xp.getDataref("sim/cockpit/autopilot/autopilot_mode")
ALTG= xp.getDataref("sim/flightmodel/position/y_agl")
get_ALTG=xp.getFloat(ALTG)
get_ALTG_ft = get_ALTG*3.28 -- Meters to Ft
-- parametros del piloto automatico
altitude_a = xp.getDataref("sim/cockpit/autopilot/altitude")
get_altitude_a = xp.getFloatV(altitude_a)
airspeed_a = xp.getDataref("sim/cockpit/autopilot/airspeed")
get_airspeed_a  = xp.getFloatV(airspeed_a )
N1 = xp.getDataref("sim/cockpit2/engine/indicators/N1_percent")
get_N1 = xp.getFloatV(N1,1,4)
thro=xp.getDataref("sim/flightmodel/engine/ENGN_thro")
get_thro=xp.getFloatV(thro,1,4) --caution here you need to give your engine count : 4 engines -> xp.getFloatV(thro,1,4)


SpeedFL = xp.getDataref("sim/cockpit2/autopilot/speed_status")
get_SpeedFL = xp.getInt(SpeedFL) -- Autopilot Speed-hold (via pitch) status. 0=off,1=armed,2=captured


-- PROBANDO
if (get_ALTG_ft > 2000) then
xp.setFloat(altitude_a,cruisealt)

if(get_SpeedFL <2) then
xp.commandOnceByName("sim/autopilot/level_change")
end
 
    gain = 0.0001
    target_N1 = 93
    delta_N1 = (get_N1 - target_N1)
    thro1 = xp.getFloatV(thro,1,1)
    thro2 = xp.getFloatV(thro,2,1)
    thro3 = xp.getFloatV(thro,3,1)
    thro4 = xp.getFloatV(thro,4,1)
    custom_throttle1 = (thro1 - (delta_N1 * gain))
if (custom_throttle1 > 1) then
custom_throttle1=1
end
custom_throttle2 = (thro2 - (delta_N1 * gain))
    if (custom_throttle2 > 1) then
custom_throttle2=1
end
custom_throttle3 = (thro3 - (delta_N1 * gain))
    if (custom_throttle3 > 1 )then
custom_throttle3=1
end
custom_throttle4 = (thro4 - (delta_N1 * gain))
if (custom_throttle4 > 1 )then
custom_throttle4=1
end
xp.setFloatV(thro, 1, custom_throttle1, custom_throttle2, custom_throttle3, custom_throttle4)

end



Thanks

Carlos

Link to post
Share on other sites

Hi, Carlos,

Sorry to take this slightly off topic...

I notice you tend to do more challenging things and move on to the next. Are you doing this for fun, or is there more to it? It's nice to hear why and how people are using Gizmo.

Link to post
Share on other sites

Mr Ben Dont get mad at me I just want to answer Mr Cameron post... Sorry

Thanks for Answer Cameron (One of the best GIZMO guru) ...

Difficult to answer ... Its for Fun, learning, personal challenge (some one says that I dont going to make anything thats works OK in gizmo) so thats give me the force to learn more about it... maybe its just a personal Challenge than other thing...

Well Im not working in any official plane, or any plane project ... so its just for me... or anyone that think that my bad scripts count for something ....

I like to learn and develop. Sometimes I feel like a plane in the cold and dark side... but sometimes theres some NICE people (arnaud, x-alberto and Pete)  that help me with my scripts .... Maybe some other developper can make this GIZMO forum more ACTIVE... and maybe more users like me buy GIZMO and make their own projects.... GIZMO is a POWERFULL Tools.

This GIZMO step climb, is becouse I have UFMC, this  wonderful tool, and manage Step Climb, but you have to change in the Altitude dial (autopilot) the next  optimal Altitude based on weight, is not automatic, (UFMC calulates the next waypoint altitude but dont make the plane go to that altitude)  Well I think that UFMC try to do the things like in real life.... But I cant stay in front of my plane (PC) for a large 14 Hours trip, so I ahve to make this GIZMO Script to manage the plane Altitude....

My next step is to make some auto flare Script but first i have to learn and read too much information...

Sorry if my post or behavior (conduct) is Bad in any point ? 

Carlos Garcia

Link to post
Share on other sites

Ok now is working...  ;)

I link (couple) the Auto cruise script to the NO SMOKING Button, If I turn ON the No Smoking Sign the Auto cruise Script ACTIVATES... I dont know any other way to activate and de activate a script using other way ... This one works good for me...

I make a relative long trip form SCEL to KJFK (9 hours 15 minutes) ... With 94380 Lbs payload and 250.250 lbs fuel. about 760.808 total plane weight. Based on this info the initial plane cruise altitude was 33.000 ft. I make the manual climb until The plane was at 33.000 ft. then ACTIVATES de auto cruise Script (using the NO SMOKE Button) and left the script manage the plane altitude based on the weight... the script change the plane altitude all the way and .... After 8:30 Minutes the plane was at 41.000 ft and 256 knots like mach 0.7?? to 0.8?? something dont remember right now... Then I turn Off the Script (using the NO SMOKE Button) and Start the descent to KJFK... about 100 something nm away from the Airport.

The script works very good, theres some minor FALSE trigger in the Selected altitude but was Ok...

This way the plane have a Fuel economy, about 7.292 lbs of fuel compared using UFMC and 35.570 lbs of fuel if i only use the X plane FMS ( here we can make some kind a step climb using VNAV) ... ( i have records of all this data, about 10 trips SCEL and KJFK)... Using this Script if the first trip ... so I have to test a little more and see if the data is consistent ...

IDEA : Maybe this Script can Help, plane FLY pilot tester, to make long trips un-attended, so test the plane Engine, Fuel consumption (fuel used in the trip, take a look in my other post when i calculate the total fuel Burn in a trip)  and plane performace is in the real world range...  The plane data (Weight, altitude, Speed) are based in a real world plane performance charts..... Yes there are many others variables, like weather, winds and many many more but is Out of the scope of this script ...


function main()
get_altA_ft = acf.getAltMsl() * 3.28 -- Aircraft altitude above mean-sea-level in meters. Then meter to Ft
dr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total")
g_total_weight =  xp.getFloat(dr_sim_total_weight)  * 2.20462262
if (g_total_weight > 880000) then -- 400.000 kgs
cruisealt = 27000
optimal_speed = 346
elseif (g_total_weight < 879000 and g_total_weight > 837000) then -- entre 380.000 y 400.000 kgs
cruisealt = 29000
optimal_speed = 345
elseif (g_total_weight < 836999 and g_total_weight > 794000) then -- entre 360.000 y 380.000 kgs
cruisealt = 31000
optimal_speed = 321
elseif (g_total_weight < 793999 and g_total_weight > 750000) then -- entre 340.000 y 360.000 kgs
cruisealt = 33000
optimal_speed = 308
elseif (g_total_weight < 749999 and g_total_weight > 705000) then -- entre 320.000 y 340.000 kgs
cruisealt = 35000
optimal_speed = 294
elseif (g_total_weight < 704999 and g_total_weight > 661000) then -- entre 300.000 y 320.000 kgs
cruisealt = 35000
optimal_speed = 294
elseif (g_total_weight < 660999 and g_total_weight > 617000) then -- entre 280.000 y 300.000 kgs
cruisealt = 37000
optimal_speed = 281
elseif (g_total_weight < 616999 and g_total_weight > 573000 ) then -- entre 260.000 y 280.000 kgs
cruisealt = 39000
optimal_speed = 269
elseif (g_total_weight < 572999 and g_total_weight > 529000 ) then -- entre 240.000 y 260.000 kgs
cruisealt = 41000
optimal_speed = 256
elseif (g_total_weight < 528999 and g_total_weight > 485000 ) then -- entre 220.000 y 240.000 kgs
cruisealt = 43000
optimal_speed = 245
elseif (g_total_weight < 484999 ) then -- entre 220.000 y 240.000 kgs
cruisealt = 43000
optimal_speed = 244
end
---- hasta qui

-- Control del piloto automatico

AUTOPILOT = xp.getDataref("sim/cockpit/autopilot/autopilot_mode")
ALTG= xp.getDataref("sim/flightmodel/position/y_agl")
get_ALTG=xp.getFloat(ALTG)
get_ALTG_ft = get_ALTG*3.28 -- Meters to Ft

-- parametros del piloto automatico
altitude_a = xp.getDataref("sim/cockpit/autopilot/altitude")
get_altitude_a = xp.getFloatV(altitude_a)
airspeed_a = xp.getDataref("sim/cockpit/autopilot/airspeed")
get_airspeed_a  = xp.getFloatV(airspeed_a )
N1 = xp.getDataref("sim/cockpit2/engine/indicators/N1_percent")
get_N1 = xp.getFloatV(N1,1,4)
thro=xp.getDataref("sim/flightmodel/engine/ENGN_thro")
get_thro=xp.getFloatV(thro,1,4) --caution here you need to give your engine count : 4 engines -> xp.getFloatV(thro,1,4)
airspeed_a = xp.getDataref("sim/cockpit/autopilot/airspeed")
get_airspeed_a  = xp.getFloatV(airspeed_a )

SpeedFL = xp.getDataref("sim/cockpit2/autopilot/speed_status")
get_SpeedFL = xp.getInt(SpeedFL) -- Autopilot Speed-hold (via pitch) status. 0=off,1=armed,2=captured

on_cruize =  xp.getDataref("sim/cockpit/switches/no_smoking")
get_on_cruize = xp.getInt(on_cruize) -- voy a utilizrlo para prender Y apagar el Script de fly lever change

-- manage the Speeds and Altitude based on the plane altitude and cruisealt, optimal_speed

if (get_on_cruize > 0) then  -- Well I dont know hot to enable or disable the Autocruice so I attach to a No Smokig Swicth > 1 on 0 Off

if (get_ALTG_ft > 2000) then
xp.setFloat(altitude_a,cruisealt)

if (get_ALTG_ft > 2001 and get_ALTG_ft < 10000 ) then -- Speed Restriction below 10.000 Ft
xp.setFloat(airspeed_a,250)
if(get_SpeedFL <2) then
xp.commandOnceByName("sim/autopilot/level_change")
end
end

if (get_ALTG_ft > 10001 and get_ALTG_ft < 26500 ) then  -- 300 knots best Economical Climb Speed
xp.setFloat(airspeed_a,300)
if(get_SpeedFL <2) then
xp.commandOnceByName("sim/autopilot/level_change")
end
end

if (get_ALTG_ft >  cruisealt - 50 and get_ALTG_ft < cruisealt + 50 ) then -- +50 - 50 A security range for False Triger
xp.setFloat(airspeed_a,optimal_speed)
xp.commandOnceByName("sim/autopilot/autothrottle_on")
xp.commandEndByName("sim/autopilot/level_change") -- Not very sure about this one.. but its working
end

if (get_ALTG_ft < cruisealt-60 ) then -- Minus 60 A security range for False Triger
if(get_SpeedFL <2) then
 xp.commandOnceByName("sim/autopilot/level_change")
end
end

gain = 0.0001
target_N1 = 97 -- I only use this N1, but have to ajust based on plane Altitude in the If statement.
delta_N1 = (get_N1 - target_N1)
       thro1 = xp.getFloatV(thro,1,1)
       thro2 = xp.getFloatV(thro,2,1)
       thro3 = xp.getFloatV(thro,3,1)
       thro4 = xp.getFloatV(thro,4,1)
       custom_throttle1 = (thro1 - (delta_N1 * gain))
if (custom_throttle1 > 1) then
custom_throttle1=1
end
custom_throttle2 = (thro2 - (delta_N1 * gain))
   if (custom_throttle2 > 1) then
custom_throttle2=1
end
custom_throttle3 = (thro3 - (delta_N1 * gain))
   if (custom_throttle3 > 1 )then
custom_throttle3=1
end
custom_throttle4 = (thro4 - (delta_N1 * gain))
if (custom_throttle4 > 1 )then
custom_throttle4=1
end
xp.setFloatV(thro, 1, custom_throttle1, custom_throttle2, custom_throttle3, custom_throttle4)
end
end

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...