Carlos Garcia 1,603 Posted July 23, 2011 Report Share Posted July 23, 2011 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 Ftdr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total")g_total_weight = xp.getFloat(dr_sim_total_weight) * 2.20462262if (g_total_weight > 880000) then -- > 400.000 kgscruisealt = 27000elseif (g_total_weight < 879000 and g_total_weight > 837000) then -- entre 380.000 y 400.000 kgscruisealt = 29000elseif (g_total_weight < 836999 and g_total_weight > 794000) then -- entre 360.000 y 380.000 kgscruisealt = 31000 elseif (g_total_weight < 793999 and g_total_weight > 750000) then -- entre 340.000 y 360.000 kgscruisealt = 33000elseif (g_total_weight < 749999 and g_total_weight > 705000) then -- entre 320.000 y 340.000 kgscruisealt = 35000elseif (g_total_weight < 704999 and g_total_weight > 661000) then -- entre 300.000 y 320.000 kgscruisealt = 35000elseif (g_total_weight < 660999 and g_total_weight > 617000) then -- entre 280.000 y 300.000 kgscruisealt = 37000elseif (g_total_weight < 616999 and g_total_weight > 573000 ) then -- entre 260.000 y 280.000 kgs cruisealt = 39000elseif (g_total_weight < 572999 and g_total_weight > 529000 ) then -- entre 240.000 y 260.000 kgscruisealt = 41000elseif (g_total_weight < 528999 and g_total_weight > 485000 ) then -- entre 220.000 y 240.000 kgscruisealt = 43000elseif (g_total_weight < 484999 ) then -- entre 220.000 y 240.000 kgscruisealt = 43000end---- hasta qui-- Control del piloto automaticoAUTOPILOT = 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 automaticoaltitude_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)endThanks Carlos Quote Link to post Share on other sites
Cameron 3,143 Posted July 23, 2011 Report Share Posted July 23, 2011 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. Quote Link to post Share on other sites
Carlos Garcia 1,603 Posted July 23, 2011 Author Report Share Posted July 23, 2011 Mr Ben Dont get mad at me I just want to answer Mr Cameron post... SorryThanks 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 Quote Link to post Share on other sites
Cameron 3,143 Posted July 23, 2011 Report Share Posted July 23, 2011 Hi, Carlos,Thanks for sharing!I wasn't trying to say your content is bad at all. I was just genuinely curious as to what you were doing with Gizmo.I'm glad you're having fun with it. I think a lot of us do. Quote Link to post Share on other sites
Carlos Garcia 1,603 Posted July 24, 2011 Author Report Share Posted July 24, 2011 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 Ftdr_sim_total_weight = xp.getDataref("sim/flightmodel/weight/m_total")g_total_weight = xp.getFloat(dr_sim_total_weight) * 2.20462262if (g_total_weight > 880000) then -- 400.000 kgscruisealt = 27000optimal_speed = 346elseif (g_total_weight < 879000 and g_total_weight > 837000) then -- entre 380.000 y 400.000 kgscruisealt = 29000optimal_speed = 345elseif (g_total_weight < 836999 and g_total_weight > 794000) then -- entre 360.000 y 380.000 kgscruisealt = 31000 optimal_speed = 321elseif (g_total_weight < 793999 and g_total_weight > 750000) then -- entre 340.000 y 360.000 kgscruisealt = 33000optimal_speed = 308elseif (g_total_weight < 749999 and g_total_weight > 705000) then -- entre 320.000 y 340.000 kgscruisealt = 35000optimal_speed = 294elseif (g_total_weight < 704999 and g_total_weight > 661000) then -- entre 300.000 y 320.000 kgscruisealt = 35000optimal_speed = 294elseif (g_total_weight < 660999 and g_total_weight > 617000) then -- entre 280.000 y 300.000 kgscruisealt = 37000optimal_speed = 281elseif (g_total_weight < 616999 and g_total_weight > 573000 ) then -- entre 260.000 y 280.000 kgs cruisealt = 39000optimal_speed = 269elseif (g_total_weight < 572999 and g_total_weight > 529000 ) then -- entre 240.000 y 260.000 kgscruisealt = 41000optimal_speed = 256elseif (g_total_weight < 528999 and g_total_weight > 485000 ) then -- entre 220.000 y 240.000 kgscruisealt = 43000optimal_speed = 245elseif (g_total_weight < 484999 ) then -- entre 220.000 y 240.000 kgscruisealt = 43000optimal_speed = 244end---- hasta qui-- Control del piloto automaticoAUTOPILOT = 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 automaticoaltitude_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=capturedon_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_speedif (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 Quote Link to post Share on other sites
x-alberto 1 Posted July 24, 2011 Report Share Posted July 24, 2011 Amazing,I'll give it a try when I am done with my main project!Good job. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.