Old style Cessna 172 oil pressure won´t run

Questions about deployment and use of Air Manager Instruments

Moderators: russ, Ralph

Message
Author
acornejo
Posts: 5
Joined: Thu Dec 03, 2020 2:05 am

Old style Cessna 172 oil pressure won´t run

#1 Post by acornejo »

Screen Shot 12-02-20 at 11.55 PM.PNG
Hi...I´m new with Air Manager on X-Plane 11...After lots of videos, tutorials and searches I have my old cessna 172 panel almost ready. Most is working, but Oil Pressure gauge is not running. I downloaded the C152 oil temperature/pressure from this comunity. Temperature is fine but pressure is killing me. I`ve tried to edit the script taken other instruments info...But nothing work for me. Please someone help me...Pleasseeee!!
Attachments
Screen Shot 12-02-20 at 11.24 PM.PNG

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Old style Cessna 172 oil pressure won´t run

#2 Post by Sling »

Perhaps if you post the instrument we would be able so see where the issue is.

User avatar
Ralph
Posts: 7916
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Old style Cessna 172 oil pressure won´t run

#3 Post by Ralph »

Would indeed be good to see your script. It might also be a custom dataref for this aircraft.

acornejo
Posts: 5
Joined: Thu Dec 03, 2020 2:05 am

Re: Old style Cessna 172 oil pressure won´t run

#4 Post by acornejo »

This´s the original script:

Code: Select all

-- Made for the Just Flight C172 -> Fuel Quantity Left and Right
-- Author: getselim-stack
-- Modified script from Alejandro Cornejo (Cessna 172 N - Fuel Quantity Left and Right)
-- which is modified from macnfly 

-- Global variables --
local gbl_target_oil_temp  = 0
local gbl_cur_oil_temp     = 0
local gbl_max_oil_temp     = 245
local gbl_target_oil_press = 0
local gbl_cur_oil_press    = 0
local gbl_max_oil_press    = 115
local gbl_factor           = 0.09

-- Load images
img_add_fullscreen("1_backgroundoil.png")

img_temp_needle = img_add("2_needle.png",9,46,280,280)
img_press_needle = img_add("2_needle.png",298,46,280,280)

img_add_fullscreen("3_scratches.png")
img_add_fullscreen("4_bezel.png")

function p3d_oil_vars(oil_temp, oil_press, bus_volts)

    if bus_volts >= 12 then
        gbl_target_oil_temp = var_cap(oil_temp, 0, gbl_max_oil_temp)
        gbl_target_oil_press = var_cap(oil_press, 0, gbl_max_oil_press)
        
    else
        gbl_target_oil_temp = 0
        gbl_target_oil_press = 0
    end

end

-- Slowly move needle to current temp and press --
function timer_callback()	
	
    -- Rotate needle image
    -- Temp needle range -37 to +76 (calibrated for JF C152)
    rotate(img_temp_needle, (gbl_cur_oil_temp/gbl_max_oil_temp)*76-37)
    -- Press needle range -37 to +93 (calibrated for JF C152)
    rotate(img_press_needle, (gbl_cur_oil_press/gbl_max_oil_press)*93-37)

    -- Calculate the current fuel position
    gbl_cur_oil_temp = gbl_cur_oil_temp + ((gbl_target_oil_temp - gbl_cur_oil_temp) * gbl_factor)
    gbl_cur_oil_press = gbl_cur_oil_press + ((gbl_target_oil_press - gbl_cur_oil_press) * gbl_factor)

end

-- Subscribe to databus --
fsx_variable_subscribe("ENG OIL TEMPERATURE:1", "Farenheit", 
                       "ENG OIL PRESSURE:1", "PSI",
                       "ELECTRICAL MAIN BUS VOLTAGE", "Volts", p3d_oil_vars)
xpl_dataref_subscribe("sim/flightmodel/engine/ENGN_oil_temp_c", "FLOAT[8]",
                      "sim/flightmodel/engine/ENGN_oil_press", "FLOAT[8]", 
                      "sim/cockpit2/electrical/bus_volts", "FLOAT[6]", function(temp, press, volts)
    p3d_oil_vars(temp[1], press[1], volts[1])
end)

-- Timers --
tmr_update = timer_start(0, 20, timer_callback)

[\code]



Thank you
Last edited by acornejo on Thu Dec 03, 2020 12:52 pm, edited 2 times in total.

User avatar
Keith Baxter
Posts: 4684
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Old style Cessna 172 oil pressure won´t run

#5 Post by Keith Baxter »

Hi,

Please edit your post and post the code in the code box . Click on the </> button.

It make it easier to read.

Thank you.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

acornejo
Posts: 5
Joined: Thu Dec 03, 2020 2:05 am

Re: Old style Cessna 172 oil pressure won´t run

#6 Post by acornejo »

And this one...One of my attempts to fix it complementing with other working scripts:

Code: Select all


-- Made for the XPLANE C172 -> Fuel Quantity Left and Right
-- Author: getselim-stack
-- Modified script from Alejandro Cornejo (Cessna 172 N - Fuel Quantity Left and Right)
-- which is modified from macnfly 

-- Global variables --
local gbl_target_oil_temp  = 0
local gbl_cur_oil_temp     = 0
local gbl_max_oil_temp     = 245
local gbl_target_oil_press = 0
local gbl_cur_oil_press    = 0
local gbl_max_oil_press    = 115
local gbl_factor           = 0.02

-- Load images
img_add_fullscreen("1_backgroundoil.png")

img_temp_needle = img_add("2_needle.png",9,46,280,280)
img_press_needle = img_add("2_needle.png",298,46,280,280)

-- img_add_fullscreen("3_scratches.png")
-- img_add_fullscreen("4_bezel.png")

function new_oil(bus_volts, opress_xpl, otemp_xpl, otemp_afl, opress_afl)

    opress = fif(opress_afl > 0, opress_afl, opress_xpl[1])
    otemp = fif(otemp_afl > 0, otemp_afl, otemp_xpl[1])
    
    opress = var_cap(opress, 0, 115)
    otemp = var_cap(otemp, 75, 250)

    if bus_volts[1] >= 10 then
        target_oilt = otemp
        target_oilp = opress
    else
        target_oilt = 75
        target_oilp = 0
    end
    
end

function p3d_oil_vars(oil_temp, oil_press, bus_volts)

    if bus_volts >= 12 then
        gbl_target_oil_temp = var_cap(oil_temp, 0, gbl_max_oil_temp)
        gbl_target_oil_press = var_cap(oil_press, 0, gbl_max_oil_press)
        
    else
        gbl_target_oil_temp = 0
        gbl_target_oil_press = 0
    end

end

-- Slowly move needle to current temp and press --
function timer_callback()	
	
    -- Rotate needle image
    -- Temp needle range -37 to +76 (calibrated for JF C152)
    rotate(img_temp_needle, (gbl_cur_oil_temp/gbl_max_oil_temp)*76-37)
    -- Press needle range -37 to +93 (calibrated for JF C152)
    rotate(img_press_needle, (gbl_cur_oil_press/gbl_max_oil_press)*93-37)

    -- Calculate the current fuel position
    gbl_cur_oil_temp = gbl_cur_oil_temp + ((gbl_target_oil_temp - gbl_cur_oil_temp) * gbl_factor)
    gbl_cur_oil_press = gbl_cur_oil_press + ((gbl_target_oil_press - gbl_cur_oil_press) * gbl_factor)

end

-- Subscribe to databus --
fsx_variable_subscribe("ENG OIL TEMPERATURE:1", "Farenheit", 
                       "ENG OIL PRESSURE:1", "PSI",
                       "ELECTRICAL MAIN BUS VOLTAGE", "Volts", p3d_oil_vars)
xpl_dataref_subscribe("sim/flightmodel/engine/ENGN_oil_temp_c", "FLOAT[8]",
                      "sim/flightmodel/engine/ENGN_oil_press", "FLOAT[8]", 
                      "sim/cockpit2/electrical/bus_volts", "FLOAT[6]",


function(temp, press, volts)
    p3d_oil_vars(temp[1], press[1], volts[1])
end)

-- Timers --
tmr_update = timer_start(0, 20, timer_callback)

[\code]

User avatar
Keith Baxter
Posts: 4684
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Old style Cessna 172 oil pressure won´t run

#7 Post by Keith Baxter »

Hi,

Thank you for editing you post.
I will look into it and revert.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Ralph
Posts: 7916
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Old style Cessna 172 oil pressure won´t run

#8 Post by Ralph »

There's a lot of things that aren't correct in this script :)

- The X-Plane subscribe has no callback.
- The original callback function has bus volts first, then oil pressure and temperature for X-Plane and then for Airfoil Labs. You have Engine oil temperature first, then pressure and then bus volts.
- On line 80 there's a function which doesn't do anything.

User avatar
Keith Baxter
Posts: 4684
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Old style Cessna 172 oil pressure won´t run

#9 Post by Keith Baxter »

Hi

Ok looks like the origional instrument uses a different dataref.

DatarefTool is the best tool to check what datarefs an airframe is using.

However locate first dataref in your code and replace with the second one.

You will have to fix the other issues Ralph mentioned.

But to get just the oil pressure working make a clone of that instrument and change the datarefs.

Code: Select all

"sim/flightmodel/engine/ENGN_oil_press", "FLOAT[8]",

"sim/flightmodel/engine/ENGN_oil_press_psi", "FLOAT[8]",
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

acornejo
Posts: 5
Joined: Thu Dec 03, 2020 2:05 am

Re: Old style Cessna 172 oil pressure won´t run

#10 Post by acornejo »

Ralph wrote: Thu Dec 03, 2020 1:12 pm There's a lot of things that aren't correct in this script :)

- The X-Plane subscribe has no callback.
- The original callback function has bus volts first, then oil pressure and temperature for X-Plane and then for Airfoil Labs. You have Engine oil temperature first, then pressure and then bus volts.
- On line 80 there's a function which doesn't do anything.

Is it so clear that is my first time trying to do something with scripts???...hahaha...You say I`m wrong with this and that...And the "subscribe" and "callback" ¿what is that?...hahaha...Sorry for take your time with small basic things...But you know that every project takes an important effort for each of one that have yhe passion of flight and try to drive the simulation to another level...

Thank you so much for that.

Post Reply