C-172 Fuel Shutoff Valve

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

Message
Author
Voyager
Posts: 33
Joined: Mon Apr 17, 2023 1:00 am

Re: C-172 Fuel Shutoff Valve

#11 Post by Voyager »

SimPassion:
I copied your entire script to a new hardware function. I set the the Button: OFF in Hardware Property to the pin on my Arduino Mega 2560. I then added the hardware function to my panel and ran it.
I did not get any response from my Fuel Shutoff Valve on either MSFS2020 or XP-12.
As the hardware function had no response, I deleted it.
Thank you for your help, but I do not know enough LUA programming to troubleshoot this code.

Ralph:
There is no Fuel Shutoff or Fuel Cutoff hardware function.
The instrument: "Cessna 172SP - Fuel selector valve" includes the Fuel Shutoff Valve that works on X-Plane 12 and MSFS2020. I guess it was included in the Cessna 172SP panel that I bought.

The fuel shutoff valve is useful because when a C-172 is loaded at a parking area in MSFS2020, the engine is off and the fuel shutoff valve is also off. The fuel valve must be pushed in to open the valve and start the engine.

Please send me an email at rasander1@gmail.com when the new hardware function is available.

Thanks,

Rich

SimPassion
Posts: 4988
Joined: Thu Jul 27, 2017 12:22 am

Re: C-172 Fuel Shutoff Valve

#12 Post by SimPassion »

Voyager wrote: Tue Sep 26, 2023 7:50 pm SimPassion:
I copied your entire script to a new hardware function. I set the the Button: OFF in Hardware Property to the pin on my Arduino Mega 2560. I then added the hardware function to my panel and ran it.
I did not get any response from my Fuel Shutoff Valve on either MSFS2020 or XP-12.
As the hardware function had no response, I deleted it.
Thank you for your help, but I do not know enough LUA programming to troubleshoot this code.

Rich
You didn't performed what's requested, which is only and at first to check the instrument as it is, after importing it in your own Air Manager.
The Hardware part isn't meant to be imported like this, without modification in your own instrument : no one ever mentioned to perform this way, including me.

I think the best way would be to post either your whole instrument exported in a SIFF file, far better way in any case !!!
Otherwise post your own script between code tags with clicking on the dedicated button while writing your post
In either case we will be able to help you going ahead

image.png
Last edited by SimPassion on Mon Oct 02, 2023 9:32 am, edited 1 time in total.

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

Re: C-172 Fuel Shutoff Valve

#13 Post by Ralph »

This is a dificult one, or actually impossible to make as one instrument, without the fuel selector.
What happens in X-Plane is that the fuel selector handle sets the fuel tank selector position at a certain value, but so does the fuel shut off valve.

So having two individual instruments for these will cause a conflict. Your handle would say for example that it wants the left position (1), and the shut off valve says it wants the off position (4).

Long story short, I'll be incorporating this into one hardware script.

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

Re: C-172 Fuel Shutoff Valve

#14 Post by Ralph »

I've uploaded a hardware function that does both the selector switch and the cut-off.
This is only for the Cessna 172. Almost every aircraft will needs its own hardware function. A Cirrus works different, the Baron 58 has cross-feed, etc...

Voyager
Posts: 33
Joined: Mon Apr 17, 2023 1:00 am

Re: C-172 Fuel Shutoff Valve

#15 Post by Voyager »

Thanks so much. I did notice that operating the fuel shutoff valve changes the fuel selector datarefs. I’ll try it later today.

Voyager
Posts: 33
Joined: Mon Apr 17, 2023 1:00 am

Re: C-172 Fuel Shutoff Valve

#16 Post by Voyager »

I wired the fuel shutoff valve to pass power when the switch is pushed in (on).

I tried the fuel shutoff valve in MSFS 2020 and X-Plane 11 and 12.

MSFS2020
Fuel Shutoff Valve Hardware: operates the fuel shutoff valve but the action is reversed. It opens when it should close and closes when it should open. It also sets the fuel selector to the left tank.
C-172SP Fuel Selector Instrument in Air Manager: Fuel Shutoff Valve works as intended.

X-Plane 11 and 12
Fuel Shutoff Valve Hardware: does not operate the fuel shutoff valve. Upon operating the fuel shutoff valve hardware the fuel selector moves to the left fuel tank and stays there.
Datarefs move reversed but do not change the fuel valve
————————————————————————————----Datarefs ---
""………………………………………………………………..Valve In Valve Out
sim/cockpit2/fuel/fuel_tank_selector…………. 0…………. 1
sim/cockpit2/fuel/fuel_tank_selector_left=….0…………. 1
sim/cockpit2/fuel/fuel_tank_selector_right=.0…………….1

C-172SP Fuel Selector Instrument in Air Manager: Fuel Shutoff Valve works as intended.
Last edited by Voyager on Tue Oct 03, 2023 8:52 pm, edited 1 time in total.

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

Re: C-172 Fuel Shutoff Valve

#17 Post by Ralph »

The fuel shut off in the X-Plane virtual cockpit does not move, but it does work, the engine dies.

Regarding MSFS, that depends on how you're placing/wiring it.
Also regarding X-Plane by the way.

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

Re: C-172 Fuel Shutoff Valve

#18 Post by Ralph »

Also, the fuel cut off switch in the Cessna 172SP panel uses a command, that makes the fuel cut off come out: sim/starters/shut_down
But... there's no command to make it go back in. The position of the switch in our panel is set by the dataref laminar/c172/fuel/fuel_cutoff_selector (which isn't listed in the datareftool by the way), but this dataref cannot be written. So again, no way to make it go back in.
So the only way to do it, is set the dataref sim/cockpit/engine/fuel_tank_selector to 4. This does not make the switch in the virtual cockpit move, but it does cut off the engine.

Image

SimPassion
Posts: 4988
Joined: Thu Jul 27, 2017 12:22 am

Re: C-172 Fuel Shutoff Valve

#19 Post by SimPassion »

This is the "sim/starters/shut_down" command which makes the full shutoff lever moving, its state is read with "laminar/c172/fuel/fuel_cutoff_selector","DOUBLE"

This will do the trick :

Code: Select all

--====================================================================================
--						C172 SHUTOFF VALVE CHECK PURPOSE
--====================================================================================

-- enjxp_SimPassion		1.0.0	10.03.2023

local gbl_so_state = 0

function shutoff()
	xpl_dataref_write("sim/cockpit2/fuel/fuel_tank_selector","INT",0)
	xpl_dataref_write("sim/cockpit/engine/fuel_tank_selector","INT",0)
	xpl_command("sim/fuel/fuel_firewall_valve_lft_closed")
	xpl_command("sim/fuel/fuel_firewall_valve_rgt_closed")
	if gbl_so_state == 0 then
		xpl_command("sim/starters/shut_down")
	end
end

function tank_both()
	xpl_dataref_write("sim/cockpit2/fuel/fuel_tank_selector","INT",4)
	xpl_dataref_write("sim/cockpit/engine/fuel_tank_selector","INT",4)
	xpl_command("sim/fuel/fuel_firewall_valve_lft_open")
	xpl_command("sim/fuel/fuel_firewall_valve_rgt_open")
	if gbl_so_state == 1 then
		xpl_command("sim/starters/shut_down")
	end
end

function tank_left()
	xpl_dataref_write("sim/cockpit2/fuel/fuel_tank_selector","INT",1)
	xpl_dataref_write("sim/cockpit/engine/fuel_tank_selector","INT",1)
	xpl_command("sim/fuel/fuel_firewall_valve_lft_open")
	if gbl_so_state == 1 then
		xpl_command("sim/starters/shut_down")
	end
end

function tank_right()
	xpl_dataref_write("sim/cockpit2/fuel/fuel_tank_selector","INT",3)
	xpl_dataref_write("sim/cockpit/engine/fuel_tank_selector","INT",3)
	xpl_command("sim/fuel/fuel_firewall_valve_rgt_open")
	if gbl_so_state == 1 then
		xpl_command("sim/starters/shut_down")
	end
end

function shutoff_state(so_state)
	gbl_so_state = so_state
end

xpl_dataref_subscribe("laminar/c172/fuel/fuel_cutoff_selector","DOUBLE", shutoff_state)

button_add("bg_l.png","bg_l.png", 10,10,40,40,tank_left)
button_add("bg_b.png","bg_b.png", 60,10,40,40,tank_both)
button_add("bg_r.png","bg_r.png",110,10,40,40,tank_right)
button_add("bg_s.png","bg_s.png", 60,60,40,40,shutoff)



image.png
image.png (3.48 KiB) Viewed 253 times
Last edited by SimPassion on Fri Oct 13, 2023 9:07 am, edited 2 times in total.

User avatar
jph
Posts: 2677
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: C-172 Fuel Shutoff Valve

#20 Post by jph »

@SimPassion
neat :)
Joe. CISSP, MSc.

Post Reply