Muas Posted November 2, 2009 Report Posted November 2, 2009 Hi everyone. The FSUIPC Sync Pos feature does well with throttle, pitch and mixture lever line up. However, I tried a LUA approach to compensate thrust assimetry, and it works very well too. Here's the code for twin engined aircraft - it easily can be adapted to four engined aircraft, and also for pitch and mixture. ------------------------------------------------------- -- FSX Lua plug-in for thrust assimetry compensation -- ------------------------------------------------------- -- [[Thrust assimetry compensation for twin engine aircraft. In this method, assimetric thrust is compensated by adding half of the detected assimetry to each engine throttle.]] -- MaxAssimetry = 1024 -- maximum thrust assimetry allowed while 1 do ipc.sleep(500) -- do nothing for half a second Throttle1Now = ipc.readSW(0x088C) Throttle2Now = ipc.readSW(0x0924) if math.abs(Throttle1Now - Throttle2Now) < MaxAssimetry then -- there's an assimetric thrust, let's compensate MidValue = (Throttle1Now + Throttle2Now)/2 ipc.writeSW(0x088C, MidValue) ipc.writeSW(0x0924, MidValue) -- done! end end -- by Muas, November 2009 The maximum assimetry value can be preset to taste. Both throttle levers work well on their own; it's when they are pushed together that this plugin will get them lined up. Compensated thrust is then set to the mid value between Throttle 1 and Throttle 2, unlike Sync Pos which line them up according to Throttle 1 value. Save this file and name it Sync 2 Throttle.lua. Put it in the Modules folder, run FSX and assign a keybord key to run this file on the FSUIPC interface. Also assing a key to kill it. Then test it, and set the maximum allowed thrust values to taste. Tests on the default FSX Boeing 737-800 showed excellent results. Hope it might be usefull.
Pete Dowson Posted November 2, 2009 Report Posted November 2, 2009 Hope it might be usefull. Thanks! That's neat. Can I add this to the Lua examples package? You'd get the credit -- if you can put your name in some comments at the beginning, perhpas? Regards Pete
Muas Posted November 2, 2009 Author Report Posted November 2, 2009 Can I add this to the Lua examples package? Sure you can. I added the author credits.
Pete Dowson Posted November 2, 2009 Report Posted November 2, 2009 Can I add this to the Lua examples package? Sure you can. I added the author credits. Thanks! Pete
kizzle Posted November 7, 2009 Report Posted November 7, 2009 Hi, Can you post the info for the 4 engine controls? Can i use this with my PFC throttle quad? If so do i have to config it through Fsuipc to have this function work Regards
Muas Posted November 7, 2009 Author Report Posted November 7, 2009 Can you post the info for the 4 engine controls?Can i use this with my PFC throttle quad? If so do i have to config it through Fsuipc to have this function work Try this: ------------------------------------------------------- -- FSX Lua plug-in for thrust assimetry compensation -- ------------------------------------------------------- -- [[Thrust assimetry compensation for 4 engine aircraft. In this method, assimetric thrust is compensated first on the outbord engines, then the inbord ones, and then the Left/Right couples.]] -- OuterMaxAssimetry = 1000 -- maximum outbord thrust assimetry allowed InnerMaxAssimetry = 1000 -- maximum inbord thrust assimetry allowed LeftMaxAssimetry = 1000 -- maximum left thrust assimetry allowed RightMaxAssimetry = 1000 -- maximum right thrust assimetry allowed while 1 do ipc.sleep(500) -- do nothing for half a second Throttle1Now = ipc.readSW(0x088C) Throttle4Now = ipc.readSW(0x0A54) if (Throttle1Now > 0) and (Throttle4Now > 0) then -- delete this line if reverse throttle compensation is required if math.abs(Throttle1Now - Throttle4Now) < OuterMaxAssimetry then -- there's an outbord assimetric thrust, let's compensate OuterMidValue = (Throttle1Now + Throttle4Now)/2 ipc.writeSW(0x088C, OuterMidValue) ipc.writeSW(0x0A54, OuterMidValue) -- done! end end -- delete this line if reverse throttle compensation is required Throttle2Now = ipc.readSW(0x0924) Throttle3Now = ipc.readSW(0x09BC) if (Throttle2Now > 0) and (Throttle3Now > 0) then -- delete this line if reverse throttle compensation is required if math.abs(Throttle2Now - Throttle3Now) < InnerMaxAssimetry then -- there's an inbord assimetric thrust, let's compensate InnerMidValue = (Throttle2Now + Throttle3Now)/2 ipc.writeSW(0x0924, InnerMidValue) ipc.writeSW(0x09BC, InnerMidValue) -- done! end end -- delete this line if reverse throttle compensation is required Throttle1Now = ipc.readSW(0x088C) Throttle2Now = ipc.readSW(0x0924) if (Throttle1Now > 0) and (Throttle2Now > 0) then -- delete this line if reverse throttle compensation is required if math.abs(Throttle1Now - Throttle2Now) < LeftMaxAssimetry then -- there's assimetric thrust on left engines, let's compensate LeftMidValue = (Throttle1Now + Throttle2Now)/2 ipc.writeSW(0x088C, LeftMidValue) ipc.writeSW(0x0924, LeftMidValue) -- done! end end -- delete this line if reverse throttle compensation is required Throttle4Now = ipc.readSW(0x0A54) Throttle3Now = ipc.readSW(0x09BC) if (Throttle4Now > 0) and (Throttle3Now > 0) then -- delete this line if reverse throttle compensation is required if math.abs(Throttle4Now - Throttle3Now) < RightMaxAssimetry then -- there's assimetric thrust on right engines, let's compensate RightMidValue = (Throttle4Now + Throttle3Now)/2 ipc.writeSW(0x0A54, RightMidValue) ipc.writeSW(0x09BC, RightMidValue) -- done! end end -- delete this line if reverse throttle compensation is required end -- by Muas, November 2009 Save this file and name it Sync 4 Throttle.lua. Put it in the Modules folder, run FSX and assign a keybord key to run this file on the FSUIPC interface. Also assing a key to kill it. Then test it, and set the maximum allowed thrust values to taste. Tests on the default FSX Boeing 747-400 showed excellent results. Please report back how it went.
Pete Dowson Posted November 9, 2009 Report Posted November 9, 2009 Can i use this with my PFC throttle quad? If so do i have to config it through Fsuipc to have this function work It doesn't matter how the throttle values get into FS, as the Lua program is working with FS's internal values, not your joystick or quadrant inputs. Regards Pete
Muas Posted November 22, 2009 Author Report Posted November 22, 2009 Hi Pete. I edited the 4 engine throttle syncro code, as it was not working as I expected. Here's another working example for 2 engine throttle, prop pitch and mixture axxis sync. -------------------------------------------------------------------------- -- FSX Lua plug-in for thrust, pitch and mixture assimetry compensation -- -------------------------------------------------------------------------- -- [[Thrust, prop pitch and mixture assimetry compensation for twin engine aircraft. In this method, compensation is achieved by adding half of the detected assimetry to each engine throttle, pitch or mixture values.]] -- MaxThrottleAssimetry = 1000 -- maximum thrust assimetry allowed MaxPitchAssimetry = 1500 -- maximum prop pitch assimetry allowed MaxMixtureAssimetry = 1000 -- maximum mixture assimetry allowed while 1 do ipc.sleep(500) -- do nothing for half a second -- Throttle compensation Throttle1Now = ipc.readSW(0x088C) Throttle2Now = ipc.readSW(0x0924) if (Throttle1Now > 0) and (Throttle2Now > 0) then -- delete this line if reverse throttle compensation is required if math.abs(Throttle1Now - Throttle2Now) < MaxThrottleAssimetry then -- there's an assimetric thrust, let's compensate MidThrottleValue = (Throttle1Now + Throttle2Now)/2 ipc.writeSW(0x088C, MidThrottleValue) ipc.writeSW(0x0924, MidThrottleValue) -- done! end end -- delete this line if reverse throttle compensation is required -- Prop pitch compensation Pitch1Now = ipc.readSW(0x088E) Pitch2Now = ipc.readSW(0x0926) if (Pitch1Now > 0) and (Pitch2Now > 0) then -- delete this line if reverse pitch compensation is required if math.abs(Pitch1Now - Pitch2Now) < MaxPitchAssimetry then -- there's an assimetric pitch, let's compensate MidPitchValue = (Pitch1Now + Pitch2Now)/2 ipc.writeSW(0x088E, MidPitchValue) ipc.writeSW(0x0926, MidPitchValue) -- done! end end -- delete this line if reverse pitch compensation is required -- Mixture compensation Mixture1Now = ipc.readSW(0x0890) Mixture2Now = ipc.readSW(0x0928) if math.abs(Mixture1Now - Mixture2Now) < MaxMixtureAssimetry then -- there's an assimetric mixture, let's compensate MidMixtureValue = (Mixture1Now + Mixture2Now)/2 ipc.writeSW(0x0890, MidMixtureValue) ipc.writeSW(0x0928, MidMixtureValue) -- done! end end -- by Muas, November 2009 Save this file and name it Sync Axis.lua. It's worth assigning a keybord key to run this file on the FSUIPC interface, and another key kill it. Set the maximum allowed thrust values to taste. Tests on the FSX default Beechcraft Baron 58 showed excellent results.
Pete Dowson Posted November 22, 2009 Report Posted November 22, 2009 I edited the 4 engine throttle syncro code, as it was not working as I expected. Here's another working example for 2 engine throttle, prop pitch and mixture axxis sync. Thanks! I will be putting your excellent examples into the Lua package soon, when I do the next user updates. Best Regards Pete
jimthomasjohnston Posted November 22, 2009 Report Posted November 22, 2009 Should the same code work in FS9? I can not get the twin engine code to work at all. Jim
Pete Dowson Posted November 22, 2009 Report Posted November 22, 2009 Should the same code work in FS9? I can not get the twin engine code to work at all. The offsets are the same. It should work okay, but you may need a tighter loop -- FS9 might be overriding the values more often. Try lowering the Sleep value in the line: ipc.sleep(500) You should be okay with values as low as 20 or 50. Experiment. Pete
jimthomasjohnston Posted November 22, 2009 Report Posted November 22, 2009 Pete, Just found the following line repeated several times in my FSUIPC log file: 52760 *** LUA Error: ...les (x86)\Microsoft Games\Flight Simulator 9\MODULES\Sync 2 Throttle.lua:1: unexpected symbol near 'ï' Still can not get the plug-in to work. What does this error mean? Jim
hodge001 Posted November 22, 2009 Report Posted November 22, 2009 Hi Maus As I have only just acquired a set up that includes a four lever throttle, I have been using both your lua files in FSX, and I just wanted to say thank you for all the effort that you have put into this, and for sharing it with us. Jim Hodkinson (no longer flying in circles)
Pete Dowson Posted November 22, 2009 Report Posted November 22, 2009 52760 *** LUA Error: ...les (x86)\Microsoft Games\Flight Simulator 9\MODULES\Sync 2 Throttle.lua:1: unexpected symbol near 'ï' Still can not get the plug-in to work. What does this error mean? It means the Lua program has not compiled due to an error. If it doesn't compile it doesn't run. The Lua program concerned is Sync 2 Throttle.lua and the line is the first line, number 1 (the "1" after :). The error is "unexpected symbol near 'ï'". It sounds like you have either corrupted the file, or not selected it all and saved it as a whole, or have added your own non-lua characters to it. Regards Pete
Muas Posted November 24, 2009 Author Report Posted November 24, 2009 As I have only just acquired a set up that includes a four lever throttle, I have been using both your lua files in FSX, and I just wanted to say thank you for all the effort that you have put into this, and for sharing it with us. I made another update for the Sync 4 Throttle.lua file with the option to not syncronize the reversers. In my 4 lever (Saitek) setup, the reversers are activated as key strokes at the end of the lever travel - the Saitek has buttons especially for that, so I set them to decrease throttle value when pressed (by repeting default F2 keystrokes) and cut it when released (default F3) - it works very good this way, but I found that when syncronized, the reverse levers tend to move slower than usual, so I de-sycronized the reversers by default in the code. But there are people out there that uses half of the throttle lever travel to activate the reversers, so they might want to keep the throttles syncronized in negative values (reversed). If this is the case, one only needs to delete some marked lines in the code, and the 4 throttles will work syncronized during reverse operation too - as I said, on the above lua files Sync 4 Throttle.lua and Sync Axis.lua, the reverse sync option is disabled by default.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now