Help with Cessna 402C Fuel Flow Guage

Peer support for Air Manager desktop users

Moderators: russ, Ralph

Post Reply
Message
Author
LZScout
Posts: 32
Joined: Wed Jul 06, 2016 12:06 am

Help with Cessna 402C Fuel Flow Guage

#1 Post by LZScout »

I've downloaded the Cessna 402C Fuel Flow instrument (created by Snake Stack Simulations) and I'm attempting to use it with the Alabeo C-404 Titan. Both aircraft use the Continental TSIO-520 Engine. The instrument does not function at all in my FSX setup. Looking at the LUA Script:

-- C402 Fuel Flow Gauge --
-------------------------------------
-- Load and display images --
-------------------------------------
img_add_fullscreen("C402_fuel_flow_face.png")
img_needle_left = img_add_fullscreen("C402_needle_L.png")
img_needle_right = img_add_fullscreen("C402_needle_R.png")

---------------
-- Functions --
---------------

function new_fuelFlow(efuelFlow)

ff1 = efuelFlow[1]
ff2 = efuelFlow[2]

pph1 = ff1 * 7920
pph2 = ff2 * 7920

pph1 = var_cap(pph1, 0, 511.5)
pph2 = var_cap(pph2, 0, 511.5)

img_rotate(img_needle_left,((220/175.5) * pph1) - 60)

img_rotate(img_needle_right, ((220/175.5) * pph2) - 60)

end

function new_fuelFlow_FSX(FF1, FF2)

new_fuelFlow({FF1, FF2})

end

-------------------
-- Bus subscribe --
-------------------

xpl_dataref_subscribe("sim/cockpit2/engine/indicators/fuel_flow_kg_sec", "FLOAT[8]", new_fuelFlow)
fsx_variable_subscribe("TURB ENG CORRECTED FF:1", "kilogram per second",
"TURB ENG CORRECTED FF:2", "kilogram per second", new_fuelFlow_FSX)


Now I'm the first to admit that I understand very little of this. Looking at the subscribed variables, it seemed strange to me that the FSX variable "TURB ENG CORRECTED FF:1" was chosen. Neither aircraft uses a turbine engine, both use reciprocating engines. I decided to consult the Microsoft FSX variable list located at https://msdn.microsoft.com/en-us/library/cc526981.aspx . The variable this LUA script uses lists "pounds per hour" as the unit, not "kilogram per second". As the instrument reads in LBS/HR, I'm not sure what the intent here is.

In any case, the instrument still doesn't function. Should I change the subscribed variable to "RECIP ENG FUEL FLOW:index"? There is also a "ENG FUEL FLOW PPH:index" variable. Does the present script make sense? I know this is an add-on aircraft and LVARS may be in play, but since I also use the Snake Stack Simulations Cessna 402 Manifold Pressure Gauge (it works great), I think this unlikely.

I also can't tell which "Function" in the LUA script above is the FSX function. Since this is a relatively short LUA script, I was hoping that one of you could take a moment to explain what happens in the two different "Function" areas and where I could find a further explanation/definition of the terms used in the Function area.

Thanks in advance for your help.

Lantz Wagner

User avatar
russ
Posts: 593
Joined: Tue Oct 27, 2015 5:37 pm

Re: Help with Cessna 402C Fuel Flow Guage

#2 Post by russ »

Lantz

First there are three images added using img_add_fullscreen which add the background image and two needles each on a transparent background. Images are always added from the bottom up( back layer first) in the order they appear in the script. Since they are fullscreen there are no x,x location or width, height size required. They stretch to fit the size you have set for the instrument. Normally the image size is the same as the instrument size of the image may be distorted.

Next, this script is written to work both with X-Plane and FSX/P3D. If you look at the bottom of the script there is a Bus Subscrbe section that calls first the xpl_dataref_subscribe and passes the value for fuel flow ( which in this case is an 8 element array of values, the first being for engine 1, the second for engine 2, and the rest just zeros) to the callback function new_fuelFlow. The values are placed into variable efuelFlow. It then sets fuel flow 1 (ff1) to the first element of the array ( think of an array as a list of values) which is efuelFlow[1] . The square bracket signifies it is the element (or item in the list) of that array variable. Then ff2 is set to equal the second element ( engine 2 ) of efuelFlow[2].

The two fuel flow values are each then multiplied by a number to convert kg/ sec to pounds per hour

Then the var_cap function is called to make sure the values are capped between a mm of 0 and a max of 511.5 ( to be sure the needle stays in the range shown on the gauge)

Finally img_rotate is used to rotate each of the needle images a number of degrees that is dependent on the fuel flow variables ff1 and ff2.

Now there is a second bus subscribe to fsx_variable_subscribe which gets the FSX values for the TURB ENG CORRECTED FF:1 and TURB ENG CORRECTED FF:2 and passes them to another callback function new_fuelFlow_FSX . This function just combines the two values into an array ( by putting them into those curly brackets { } and separates them by a comma) and then passes this array as an argument to the previous x-plane callback function new_fuelFlow we discussed earlier. So this function does the work and moves the needles as before but now with the values passed from the FSX callcack.

This works because the values passed are the same variables and with the same units... namely kilograms per second .

As for the units for the FSX variables. There is flexibility and if you request certain other variable units the values are converted by FSX to the values requested. He wanted a consistent value as with X-Plane so he'd not need to add the conversion step to his FSX callback.

As to why that specific variable was used it would be hard to say. Various Developers have their own ways of doing things they don't always follow standard conventions. Sometimes it is necessary to use some strange workaround to get your panel to operate correctly.

The best thing to do is to use the data if you were in the air manager to view the real-time data for different variables to decide which is best to use for your specific application. If the units you receive are not kilograms per second you may have to modify the variable slightly to get things to work correctly but it's just a simple matter of mathematics. Use of the date of your was covered in an article in a recent newsletter from Sim Innovations.( see:
http://us3.campaign-archive1.com/?u=741 ... 0&e=#Lvars )

As you probably can see if you are doing this only for FSX you could just pass the fsx_variable_subscribe results directly to a function that does what the X-Plane function does without the need to convert the values to an array. Likewise, the FSX callback could have been used to do the value capping and image rotation, and an X-Plane callback could just extract the first two array elements and pass them to the FSX callback as the two arguments. Either way works. A final option would be to have each callback do the complete job separately but this leads to more code and is a bit redundant...but still works. There is an article in last March newsletter on cross platform development at: http://us3.campaign-archive1.com/?u=741 ... 93f&e=#lua

Hope this helps some. I know when I started working with the stuff I didn't even understand what a callback function was: that it was the function called whatever data changed in the simulator for a subscription variable.

Good luck
Russ Barlow
Air Manager Evangelist

xp-wym
Posts: 66
Joined: Fri Mar 04, 2016 11:13 am

Re: Help with Cessna 402C Fuel Flow Guage

#3 Post by xp-wym »

Hi,

That gauge was originally only made for x-plane - looks like it has been modified. You will have to find the equivalent dataref/varibles in fsx that govern fuel flow.

You will find that the 404 had GTSIO 520's which were around 400hp on TO; where as the 402's had TSIO 520's which were rated 325hp.

The fuel flow will most likely be off the scale when you set takeoff power. Maybe best to create an entire new gauge.

LZScout
Posts: 32
Joined: Wed Jul 06, 2016 12:06 am

Re: Help with Cessna 402C Fuel Flow Guage

#4 Post by LZScout »

A lot to to think about, a lot to learn. I'll read what you've suggested.

Post Reply