Wiring a real C172 Ignition Switch
Wiring a real C172 Ignition Switch
Hello all,
I recently managed to get my hands on a (reasonably affordable as they go) old ignition switch from a real C152 that I'm hoping to integrate into my 172 panel build via a Mega unit. I was looking to get some feedback as to the proper way to wire this guy up based on the wiring diagram I found from Aircraft Spruce. For the starter engagement I was planning to run a wire from the 5v rail to the "BAT" terminal and then have that go back from the "S" to an analog pin on the Mega to trigger the "Engage Starter" command in the sim. I was then going to follow the diagram and just hook Terminal 5 to my common ground wire and each mag terminal to its own analog pin. Seems pretty straight forward though I'm curious how I could implement/program the command for "Both" based on this diagram, as in a normal install situation the "BO" and "LR" terminals are not used.
Figured I would throw the question out here to get you thoughts.
Thanks!
I recently managed to get my hands on a (reasonably affordable as they go) old ignition switch from a real C152 that I'm hoping to integrate into my 172 panel build via a Mega unit. I was looking to get some feedback as to the proper way to wire this guy up based on the wiring diagram I found from Aircraft Spruce. For the starter engagement I was planning to run a wire from the 5v rail to the "BAT" terminal and then have that go back from the "S" to an analog pin on the Mega to trigger the "Engage Starter" command in the sim. I was then going to follow the diagram and just hook Terminal 5 to my common ground wire and each mag terminal to its own analog pin. Seems pretty straight forward though I'm curious how I could implement/program the command for "Both" based on this diagram, as in a normal install situation the "BO" and "LR" terminals are not used.
Figured I would throw the question out here to get you thoughts.
Thanks!
Re: Wiring a real C172 Ignition Switch
For starters I don’t think you need bother using analog inputs when these are simple switch signals. You also don’t need 5v for the starter as you can also use GND for this. The both can be handled in code or by diode ORing the L and R. You will also need to account for the fact that the opposite mag is grounded. So when The key is L the R terminal is grounded and vice versa. It will be in both when neither is grounded.
Hope this helps.
Tony
Hope this helps.
Tony
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: Wiring a real C172 Ignition Switch
I've made a script for one of these before, I'll look it up. I used digital_input, together with a pull up resistor. As you rotate the switch, it goes through various combinations. According to those different combinations of all digital inputs, you can determine the position of the switch.
Re: Wiring a real C172 Ignition Switch
Thank you gents! I was starting to think along the same lines before I went to bed yesterday, Tony. Glad I was on the right trail.
Ralph, that also makes sense. I have a few resistors left on hand from a previous project that may work. Any particular value I should be using?
Ralph, that also makes sense. I have a few resistors left on hand from a previous project that may work. Any particular value I should be using?
Re: Wiring a real C172 Ignition Switch
You'll need just one. I'm not sure what I used, but I think that something above 1K will work.
One of the terminals should be ground, I'm not sure which one that was. If you measure with a multimeter and turn the switch, you'll see that all pins connect to one pin. That one pin should be the ground pin.
One of the terminals should be ground, I'm not sure which one that was. If you measure with a multimeter and turn the switch, you'll see that all pins connect to one pin. That one pin should be the ground pin.
Re: Wiring a real C172 Ignition Switch
Hi everyone,
My apologies for digging up this old post but I'm back to working on my panel after upgrading to AM4. I've got everything else working but I'm still having a bit of trouble with this particular switch. I was wondering if anyone had any input on how I should wire it up using the C172 Magneto Switch hardware template in AM4. I guess another question I could ask is, will this switch work with this code or will I need to write up something custom? I have ditched the idea of analog inputs and will just be using digital instead. Thanks for any insight you may be able to provide.
My apologies for digging up this old post but I'm back to working on my panel after upgrading to AM4. I've got everything else working but I'm still having a bit of trouble with this particular switch. I was wondering if anyone had any input on how I should wire it up using the C172 Magneto Switch hardware template in AM4. I guess another question I could ask is, will this switch work with this code or will I need to write up something custom? I have ditched the idea of analog inputs and will just be using digital instead. Thanks for any insight you may be able to provide.
Code: Select all
hw_switch_add("Magneto switch", 5, function(position, direction)
if position == 0 then
xpl_command("sim/magnetos/magnetos_off_1")
elseif position == 1 then
xpl_command("sim/magnetos/magnetos_right_1")
elseif position == 2 then
xpl_command("sim/magnetos/magnetos_left_1")
elseif position == 3 then
xpl_command("sim/starters/engage_starter_1", 0)
xpl_command("sim/magnetos/magnetos_both_1")
elseif position == 4 then
xpl_command("sim/starters/engage_starter_1", 1)
end
end)
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Wiring a real C172 Ignition Switch
Hi,
You can try something like this...
It is far better to use tables than if statements. Not always possible i know.
Keith
You can try something like this...
It is far better to use tables than if statements. Not always possible i know.
Code: Select all
---create a table with the commands in their corresponding to the switch position'
transponder_switch_table = {"sim/transponder/transponder_off","sim/transponder/transponder_standby","sim/transponder/transponder_test","sim/transponder/transponder_on","sim/transponder/transponder_alt"}
---Add a counter for the switch/dial position. Note I have used dial in this example. No specific reason. The same logic applies to rotary switches and button matrix.
dial_pos=1
---Switch function
function dial_callback(dir)
dial_pos=var_cap(dial_pos+dir,1,5)
xpl_command(transponder_switch_table[dial_pos])
rotate(temp_dial,70+(dial_pos*55))
end
---Add the rotary switch
dial_add(nil,590,40,80,80,dial_callback)
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
Re: Wiring a real C172 Ignition Switch
You'll have to start with the hardware side first. Make sure you can read all different positions with an digital_input_add, then you can start to build the X-Plane code.
Re: Wiring a real C172 Ignition Switch
That standard ignition switch code will not work with a real aircraft ignition switch for the reasons I stated towards the beginning of this thread. You can get it to work but as Ralph said you need to get your head round how the real switch functions. You should be able to make it work with just 3 I/O lines (one each for the left and right mag and one for the starter).
It should work out as follows. (Note during start one of the mags will be grounded, usually the left. You don’t need to worry about this)
Off - left & right contacts grounded.
Right - left contact grounded, right contact open.
Left - left contact open, right contact grounded.
Both - left & right contacts open.
Start - start contact made. (You can use ground in lieu of the intended real world start power)
It should work out as follows. (Note during start one of the mags will be grounded, usually the left. You don’t need to worry about this)
Off - left & right contacts grounded.
Right - left contact grounded, right contact open.
Left - left contact open, right contact grounded.
Both - left & right contacts open.
Start - start contact made. (You can use ground in lieu of the intended real world start power)
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Re: Wiring a real C172 Ignition Switch
AgreedSling wrote: ↑Fri Jun 11, 2021 5:28 am That standard ignition switch code will not work with a real aircraft ignition switch for the reasons I stated towards the beginning of this thread. You can get it to work but as Ralph said you need to get your head round how the real switch functions. You should be able to make it work with just 3 I/O lines (one each for the left and right mag and one for the starter).
It should work out as follows. (Note during start one of the mags will be grounded, usually the left. You don’t need to worry about this)
Off - left & right contacts grounded.
Right - left contact grounded, right contact open.
Left - left contact open, right contact grounded.
Both - left & right contacts open.
Start - start contact made. (You can use ground in lieu of the intended real world start power)
The logic truth table for the main two I/O would be - (for 3 x Hw input add) - and presuming Hw input add has internal weak pullups enabled
The three inputs can be scanned for the following combos
0 0 Off - left & right contacts grounded.
0 1 Right - left contact grounded, right contact open.
1 0 Left - left contact open, right contact grounded.
1 1 Both - left & right contacts open.
3rd I/0
1 Normal state - non start.
0 Start - start contact made. (You can use ground in lieu of the intended real world start power)
Note below though - it may be advantageous - and indeed appropriate - to use a pullup resistor on the 'batt' input to 5V for correct function as the
operation of the starter solenoid involves connecting Bat to Solenoid (starter)
I think the pull up to 5V on Bat would be a better and maybe necessary option ? - (and the gnd on switch to logic low (gnd).
IN this case also, then a pull down resistor on the start output would also appear to be needed also for normal operation as it would normally be O/C but then connected to BATT when engaged.
The resistors can be around 1K
Hence the logic would be -
3rd I/0
0 Normal state - non start.
1 Start - start contact made. (You can use ground in lieu of the intended real world start power)
It would be still very wise to check all positions with a multimeter to determine the actual needs from the switch itself.
However, I may well be overthinking this.
Joe
Joe. CISSP, MSc.