Thranda HDC-2 Beaver Instruments for Xplane
Thranda HDC-2 Beaver Instruments for Xplane
There a number of panel instruments for the DHC-2 Beaver that have Lua scripts for Xplane. I am flying the Thranda DHC-2 but the Lua scripts are referencing datarefs for another aircraft manufacture not Thranda. I can see the datarefs that Thranda is using as the dataref tool displays data for the dataref in green when the engine is running. I have tried to insert these datarefs into the Lua file for the instrument but the instrument does not respond. In particular there is a oil, fuel pressure and oil temperature instrument. Only the fuel pressure seems to respond. Also the carberator heat and cylinder heat temp gauges do not respond. Does anyone have guidance on how to get the Thranda datarefs to work with these SI instruments. I have very limited experience with writing Lua script. Thanks. Bill
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Thranda HDC-2 Beaver Instruments for Xplane
Hi @wrschultz, the default Sim Innovations DHC-2 Beaver instruments are related to Soul Made Simulations (SMS) in X-Plane from here https://forums.x-plane.org/index.php?/f ... mulations/
currently watching for datarefs related to Thranda DHC-2 Beaver
I will post next here
The expected working instrument is this one :
currently watching for datarefs related to Thranda DHC-2 Beaver
I will post next here
The expected working instrument is this one :
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Thranda HDC-2 Beaver Instruments for Xplane
Seems to work properly :
Code: Select all
---------------------------------------------
-- Sim Innovations - All rights reserved --
-- DHC-2 Beaver Oil and fuel pressure --
---------------------------------------------
-- enjxp_SimPassion 10/17/2022 Added Thranda handling
-- Add images --
img_add_fullscreen("oil_fuel_background.png")
img_needle_oil_p = img_add("needle_small.png", 248, 291, 70, 322)
img_needle_fuel_p = img_add("needle_small.png", 352, 291, 70, 322)
img_needle_oil_t = img_add("needle_big.png", 275, 33, 120, 600)
rotate(img_needle_oil_t, -90)
rotate(img_needle_oil_p, -18)
rotate(img_needle_fuel_p, 180)
-- Functions --
function new_data_xpl(oil_temp, oil_pres, fuel_pres)
oil_temp = var_cap(oil_temp, 0, 100)
rotate(img_needle_oil_t, (1.8 * oil_temp) -90)
oil_pres = var_cap(oil_pres, 0, 100)
rotate(img_needle_oil_p, (180 / 200 * oil_pres) -180)
fuel_pres = var_cap(fuel_pres, 0, 25)
rotate(img_needle_fuel_p, 180 - (180 / 25 * fuel_pres) )
end
function new_data_Thranda(oil_t, oil_p, fuel_pres)
oil_temp = oil_t[1]
oil_pres = oil_p[1]
oil_temp = var_cap(oil_temp, 0, 100)
rotate(img_needle_oil_t, (1.8 * oil_temp) -90)
oil_pres = var_cap(oil_pres, 0, 100)
rotate(img_needle_oil_p, (180 / 200 * oil_pres) -180)
fuel_pres = var_cap(fuel_pres, 0, 25)
rotate(img_needle_fuel_p, 180 - (180 / 25 * fuel_pres) )
end
function new_data_fsx(oil_temp, oil_pres, fuel_pres)
new_data_xpl(oil_temp, oil_pres, fuel_pres)
end
-- Subscribe to data --
xpl_dataref_subscribe("sms/custom/cdrAnimOilTemp", "FLOAT",
"sms/custom/cdrAnimOilPress", "FLOAT",
"sms/custom/cdrAnimFuelPress", "FLOAT", new_data_xpl)
xpl_dataref_subscribe("thranda/electrical/OilT", "FLOAT[4]",
"thranda/electrical/OilP", "FLOAT[4]",
"thranda/fuel/FuelPress", "FLOAT", new_data_Thranda)
fsx_variable_subscribe("GENERAL ENG OIL TEMPERATURE:1", "Celsius",
"ENG OIL PRESSURE:1", "PSI",
"ENG FUEL PRESSURE", "PSI", new_data_fsx)
fs2020_variable_subscribe("GENERAL ENG OIL TEMPERATURE:1", "Celsius",
"ENG OIL PRESSURE:1", "PSI",
"GENERAL ENG FUEL PRESSURE", "PSI", new_data_fsx)
Re: Thranda HDC-2 Beaver Instruments for Xplane
This is the instrument in question. I think you are saying that the instrument is working with the special SMS datarefs for the SMS DHC-2 Beaver. I can see that Thranda has its own datarefs for this instrument. The Thranda DHC-2 instrument did not work with the SMS datarefs for me. Bill
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Thranda HDC-2 Beaver Instruments for Xplane
Watch carefully the script where I've added the Thranda datarefs as stated previously !!! (read comment in script : -- enjxp_SimPassion 10/17/2022 Added Thranda handling)wrschultz wrote: ↑Mon Oct 17, 2022 12:23 am This is the instrument in question. I think you are saying that the instrument is working with the special SMS datarefs for the SMS DHC-2 Beaver. I can see that Thranda has its own datarefs for this instrument. The Thranda DHC-2 instrument did not work with the SMS datarefs for me. Bill
Re: Thranda HDC-2 Beaver Instruments for Xplane
I was able to follow your logic with the "Float[n] and Thranda dataref and the fuel, oil pressure and oil temp gauge works. I then extended the method to setup the carb heat and the cylinder head temp gauges and they now work. I am only missing the fuel quantity gauge that has the front, center and rear gauge. I have found a dataref with a Float[4]. Need to investigate this one further. For some reason the gauge will not display on my panel even though it is there in the SI panel setup program. I know about the layers and how an instrument can be hidden behind another. I do not think this is the issue. Will work on this further. Appreciate your help on this. Bill
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Thranda HDC-2 Beaver Instruments for Xplane
Hi Billwrschultz wrote: ↑Tue Oct 18, 2022 1:09 am I was able to follow your logic with the "Float[n] and Thranda dataref and the fuel, oil pressure and oil temp gauge works. I then extended the method to setup the carb heat and the cylinder head temp gauges and they now work. I am only missing the fuel quantity gauge that has the front, center and rear gauge. I have found a dataref with a Float[4]. Need to investigate this one further. For some reason the gauge will not display on my panel even though it is there in the SI panel setup program. I know about the layers and how an instrument can be hidden behind another. I do not think this is the issue. Will work on this further. Appreciate your help on this. Bill
could you please post a screenshot of your panel setup expanded from Air Manager [Home] tab, also showing the Layout part on the right, together with every single instrument name added in the left pane ?
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Thranda HDC-2 Beaver Instruments for Xplane
When we create a panel and add instruments, they are automatically superimposed at first, so we have to move the last added so we discover the previous in the list and so on until the first added
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Thranda HDC-2 Beaver Instruments for Xplane
Hi Bill @wrschultz,
It was a bit tricky, but now a fully working fuel quantity gauges. It gone by simplifying the original function
It was a bit tricky, but now a fully working fuel quantity gauges. It gone by simplifying the original function
Code: Select all
---------------------------------------------
-- Sim Innovations - All rights reserved --
-- DHC-2 Beaver Fuel quantity --
---------------------------------------------
-- enjxp_SimPassion 10/19/2022 Added Thranda handling and made simplification adding interpolate usage, with needle properly calibrated
local gbl_target_front = 0
local gbl_target_mid = 0
local gbl_target_rear = 0
local gbl_currnt_front = 0
local gbl_currnt_mid = 0
local gbl_currnt_rear = 0
local gbl_factor = 0.01
local gal_imperial_rat = 1.2009499255049
local frontmid_int = { { 0 , 36 },
{ 4, 48 },
{ 8, 95 },
{ 12, 125 },
{ 16, 185 },
{ 20, 259 },
{ 24, 291 },
{ 35, 325 } }
local rear_int = { { 0 , 36 },
{ 4, 78 },
{ 8, 121 },
{ 12, 196 },
{ 16, 273 },
{ 25, 325 } }
-- Add images --
img_add_fullscreen("background_fuel.png")
img_needle_rear = img_add("needle.png", 312, 64, 46, 224)
img_needle_front = img_add("needle.png", 177, 306, 46, 224)
img_needle_middle = img_add("needle.png", 447, 306, 46, 224)
-- Functions --
function new_data_xpl(front, mid, rear, bus_volt)
-- Front: 28.98 - Middle: 28.98 - Rear: 21.0
if bus_volt[1] >= 10 then
gbl_target_front = interpolate_linear(frontmid_int, front, true)
gbl_target_mid = interpolate_linear(frontmid_int, mid, true)
gbl_target_rear = interpolate_linear(rear_int, rear, true)
else
gbl_target_front = 0
gbl_target_mid = 0
gbl_target_rear = 0
end
end
function new_data_Thranda(tanks, bus_volt)
-- front = tanks[1]
-- mid = tanks[2]
-- rear = tanks[3]
front = tanks[1] / 2.2 / gal_imperial_rat
mid = tanks[2] / 2.2 / gal_imperial_rat
rear = tanks[3] / 2.2 / gal_imperial_rat
-- Front: 35.0 - Middle: 35.0 - Rear: 25.0
if bus_volt[1] >= 10 then
gbl_target_front = interpolate_linear(frontmid_int, front, true)
gbl_target_mid = interpolate_linear(frontmid_int, mid, true)
gbl_target_rear = interpolate_linear(rear_int, rear, true)
else
gbl_target_front = 0
gbl_target_mid = 0
gbl_target_rear = 0
end
end
function new_data_fsx(front, mid, rear, bus_volt)
new_data_xpl(front, mid, rear, {bus_volt})
end
function timer_callback()
-- Rotate the needles
rotate(img_needle_front, gbl_currnt_front)
rotate(img_needle_middle, gbl_currnt_mid)
rotate(img_needle_rear, gbl_currnt_rear)
-- Calculations
gbl_currnt_front = gbl_currnt_front + ((gbl_target_front - gbl_currnt_front) * gbl_factor)
gbl_currnt_mid = gbl_currnt_mid + ((gbl_target_mid - gbl_currnt_mid) * gbl_factor)
gbl_currnt_rear = gbl_currnt_rear + ((gbl_target_rear - gbl_currnt_rear) * gbl_factor)
end
-- Subscribe to data --
xpl_dataref_subscribe("sms/custom/cdrAnimFuelFront", "FLOAT",
"sms/custom/cdrAnimFuelMid", "FLOAT",
"sms/custom/cdrAnimFuelAft", "FLOAT",
"sim/cockpit2/electrical/bus_volts", "FLOAT[6]", new_data_xpl)
xpl_dataref_subscribe("thranda/electrical/Fuel", "FLOAT[4]",
"sim/cockpit2/electrical/bus_volts", "FLOAT[6]", new_data_Thranda)
fsx_variable_subscribe("FUEL LEFT QUANTITY", "Gallons",
"FUEL RIGHT QUANTITY", "Gallons",
"FUEL TANK CENTER QUANTITY", "Gallons",
"ELECTRICAL MAIN BUS VOLTAGE", "Volts", new_data_fsx)
fs2020_variable_subscribe("FUEL LEFT QUANTITY", "Gallons",
"FUEL RIGHT QUANTITY", "Gallons",
"FUEL TANK CENTER QUANTITY", "Gallons",
"ELECTRICAL MAIN BUS VOLTAGE", "Volts", new_data_fsx)
-- TIMER --
timer_start(0, 10, timer_callback)
-
- Posts: 5339
- Joined: Thu Jul 27, 2017 12:22 am
Re: Thranda HDC-2 Beaver Instruments for Xplane
Just a point : when trying to modify an original script, try to run the edited instrument at first in [Create/Edit] tab, so we can see in the [Console] tab if there's not any error that prevent the instrument from running. If we try to show the instruments in a panel from the [Home] tab, we don't see any error and one or many instruments may very well not being displayed