Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hello everyone,

I am using the follwing script for some while to save L:Vars into FSUIPC offsets to use them in hardware gauges of Flight Illusion and Open Cockpits. It works but smooth needle movements are not possible. Additionally, the offsets are set to zero frequently which results in jittering of the needles as they try to return to zero for a micro second.

I tried different variable formats but nothing did help, so I assume something is wrong within the script:

function datasend(time)

l = ipc.readLvar("NEEDLE_VERTICAL_SPEED_RIGHT") ipc.writeUW(0x66B1,l)

n = ipc.readLvar("NEEDLE_FUEL_QUANTITY_LEFT") ipc.writeUW(0x66C0,n)

m = ipc.readLvar("NEEDLE_FUEL_QUANTITY_RIGHT") ipc.writeUW(0x66C1,m)

-- ipc.sleep(10)

end

event.timer(100, "datasend")

ipc.writeSTR(0x3380, "Data Module initiated")

ipc.writeSW(0x32FA, 3)

Ipc.sleep has been commented out to ensure that this is not the cause for the "zero effect".

There is a video on youtube (Home Cockpit Servo Driven Instrument Panel) that shows great needle movements but I failed in contacting the author of the video for help on my setup.

I am looking forward for any help! Thank you and greetings,

Marcel

Posted

Hi,

You could use the great new event.Lvar function, which Pete implemented with the last release. This event function checks in a given interval every change of a Lvar variable. Check the latest documentation.

Your code could look like this:


-- define Lvar to offset mapping functions
function setVerticalSpeedRight (lvarname,value)
ipc.writeUW(0x66B1,value)
end

function setFuelQuantityLeft (lvarname,value)
ipc.writeUW(0x66C0,value)
end

function setFuelQuantityRight (lvarname,value)
ipc.writeUW(0x66C1,value)
end

-- initialize offsets
setVerticalSpeedRight ("NEEDLE_VERTICAL_SPEED_RIGHT",ipc.readLvar("NEEDLE_VERTICAL_SPEED_RIGHT"))
setFuelQuantityLeft ("NEEDLE_FUEL_QUANTITY_LEFT",ipc.readLvar("NEEDLE_FUEL_QUANTITY_LEFT"))
setFuelQuantityRight ("NEEDLE_FUEL_QUANTITY_RIGHT",ipc.readLvar("NEEDLE_FUEL_QUANTITY_RIGHT"))

-- register Lvars to check (100 msec is the minimum interval)
event.Lvar("NEEDLE_VERTICAL_SPEED_RIGHT",100,"setVerticalSpeedRight")
event.Lvar("NEEDLE_FUEL_QUANTITY_LEFT",100,"setFuelQuantityLeft")
event.Lvar("NEEDLE_FUEL_QUANTITY_RIGHT",100,"setFuelQuantityRight")
[/CODE]

Very easy to implement now Lvar changes with this new function.

Rgds

Reinhard

Posted

l = ipc.readLvar("NEEDLE_VERTICAL_SPEED_RIGHT") ipc.writeUW(0x66B1,l)

n = ipc.readLvar("NEEDLE_FUEL_QUANTITY_LEFT") ipc.writeUW(0x66C0,n)

m = ipc.readLvar("NEEDLE_FUEL_QUANTITY_RIGHT") ipc.writeUW(0x66C1,m)

What is wrong with the normal offsets for these valees?

Regards

Pete

Posted

Your code could look like this:

Hello Reinhard,

Thank you very much! I implemented that code and at the moment it only saves new values if I do reload the lua script. Do you have an idea what I may have done wrong? I will install the new FSUIPC again, perhabs something went wrong here.

Are you from Austria? :)

Greetings,

Marcel

Posted

What is wrong with the normal offsets for these valees?

Regards

Pete

Hello Pete,

Those three are just part of a longer list of variables. And for example, the fuel quantity displays depend on a circtuit breaker and the indication will swap and jitter depending on engine vibrations and aircraft movements. So on most needles I don't use FSX default offsets but my own system simulation. :)

Greetings,

Marcel

Posted
Thank you very much! I implemented that code and at the moment it only saves new values if I do reload the lua script. Do you have an idea what I may have done wrong? I will install the new FSUIPC again, perhabs something went wrong here.

You must have the latest version of FSUIPC installed (from the download section in this forum) as Pete implemented this function end of July.

Are you from Austria? :)

Yes - as you easily can guess from my account ;-)

Rgds

Reinhard

Posted

Thank you very much! I implemented that code and at the moment it only saves new values if I do reload the lua script. Do you have an idea what I may have done wrong? I will install the new FSUIPC again, perhabs something went wrong here.

Certainly sounds like you are using a version of FSUIPC which preceded the event.lvar function addition. Check the FSUIPC log -- it will log the error in the function is not there.

Pete

Posted

Thanks for the hint, will look for it later when the computer is at the aircraft again. I checked the version number to be 4.84 in FSX, that is the case...

But the event.lvar function was not added until update 4.841! The current interim update is 4.844. See the Download Links subforum.

Pete

Posted

Now I got it. :) Thank you so much Pete and Reinhard! Gauges seem to run more smoothly and those "zero stutters" are away. Only some needles behave odd but I will have to check them today.

Double check your use of the free user offsets. I just noticed you have both of these:

  ipc.writeUW(0x66C0,value)
ipc.writeUW(0x66C1,value)
[/CODE]

[font=arial,helvetica,sans-serif]The writeUW writes an unsigned WORD (2 bytes), so the write to 66C0 overwrites the low byte of the Word at 66C1. You either need to change to "writeUB" to write only one byte (8 bits) -- which is okay if the range of the value doesn't exceed 0-255 -- or choose offsets at least 2 bytes apart.[/font]

Regards

Pete

Posted

Hi,

For the fuel quantity gauges you should think about the interval, how often you are checking the Lvars. I don't believe, that the value will change within 100 msec so dramatically. So I would suggest to select for the slow moving gauges a longer interval to reduce load of the system.

Rgds

Reinhard

Posted

Thanks Pete for your hint - that solved some issues. :-) I don't have much knowledge on the offsets, datatypes etc. Do you mean 66C0 and 66C2 with two bytes apart or 66C3?

On most needles I would have a bad feeling to have only 255 steps...

Reinhard, the fuel quantity needles are those with the highest update rate because of the shaking of the needles. Will reduce the interval for the voltmeter etc. :)

Posted

Thanks Pete for your hint - that solved some issues. :smile: I don't have much knowledge on the offsets, datatypes etc. Do you mean 66C0 and 66C2 with two bytes apart or 66C3?

66C0 and 66C2 are 2 bytes apart (66C2 - 66C0 = 2, simple arithmetic).

66C1 and 66C3 are also of course 2 bytes apart. But why start at an odd number like 66C1?

On most needles I would have a bad feeling to have only 255 steps...

It's not what you want, it's what FS provides. Many needles used in FS default gauges only have a max of 255 steps. Some less.

Pete

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.