Jump to content
The simFlight Network Forums

program to randomly change EGT values of both engines


Recommended Posts

Posted

Hello,

the homecockpit software always shows exactly the same egt values on both engines without variation, which is highly unrealistic.

I want to write a program, that randomly makes small changes to the offset value for EGT engine 1 and EGT engine 2. 

EGT 1 : 0x08BE

EGT2: 0x0956

-- ////////////////////////////////////////////


math.randomseed(os.time())


function generateRandomValue()
    return math.random(-9, 9)
end


function updateRandomValue()
    while true do
        local randomValue = generateRandomValue()
        local sleepTime = math.random(3, 😎
        os.execute("sleep " .. sleepTime) 
    end
end


local thread = love.thread.newThread(updateRandomValue)
thread:start()

 

It gives out random values between -9 and 9 in a variable time between 3-8 sec. 

What do I have to add to change the values of the offsets 0x08BE and 0x0956 ?

Kind regards

 

 

Posted

First, using a prop. aircraft, you should use offsets 0x3B70 and 0x3AB0, as the comments in the FSUIPC offset document states:

Quote
Engine 1 EGT, 16384 = 860 C. [Note that for Props this value is not actually correct. You will get the correct value from 3B70. The value here has been derived by FSUIPC to be compatible with FS2004, FS2002 et cetera]
1 hour ago, Egyptair said:

What do I have to add to change the values of the offsets 0x08BE and 0x0956 ?

Those offsets are two-byte ints - I am not sure if they are signed or not (i.e. can they be negative?). If signed, you would use the function ipc.writeSW(offset, value), and if unsigned, you would use ipc.writeUW(offset, value). I suspect they are signed, so try that first. Note that a value of 16384 - 860 C, so you would need to scale your values of -9 to + 9 to the range temperatures that you want (e.g. -16384 to + 16384).

If using offsets  0x3B70 and 0x3AB0, these hold 64bit/8-byte floating point numbers, so you would use ipc.writeDBL(offset, value). These offsets are in degrees Rankine, so you should also convert your -9 to +9 value to the variation range toy want to see in these units.

John

 

 

 

Posted
46 minutes ago, John Dowson said:

First, using a prop. aircraft, you should use offsets 0x3B70 and 0x3AB0, as the comments in the FSUIPC offset document states:

Those offsets are two-byte ints - I am not sure if they are signed or not (i.e. can they be negative?). If signed, you would use the function ipc.writeSW(offset, value), and if unsigned, you would use ipc.writeUW(offset, value). I suspect they are signed, so try that first. Note that a value of 16384 - 860 C, so you would need to scale your values of -9 to + 9 to the range temperatures that you want (e.g. -16384 to + 16384).

If using offsets  0x3B70 and 0x3AB0, these hold 64bit/8-byte floating point numbers, so you would use ipc.writeDBL(offset, value). These offsets are in degrees Rankine, so you should also convert your -9 to +9 value to the variation range toy want to see in these units.

John

 

 

 

Hello again John,

thank you, I will try this and come back to you.

BTW, your lua script works perfectly, no more engine shut downs during flight. 

Kind regards

 

Ahmed

Posted
5 minutes ago, Egyptair said:

thank you, I will try this and come back to you.

Ok. Looking at the script you posted (always better to attach than paste!), why are you doing this:

3 hours ago, Egyptair said:

local thread = love.thread.newThread(updateRandomValue)
thread:start()

?

You should use the event.timer function.. Using that, you shouldn't need to sleep, but if you do want to add a random delay, use ipc.sleep and not os.execute.

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.