Toggle Switch Off Position
- BradyBrother100
- Posts: 54
- Joined: Tue Oct 13, 2020 4:21 pm
- Location: United States MDT
Toggle Switch Off Position
Hi! Before buying a On/Off/On switch, I want to know if Air Manager can detect if the switch is Off. Can it or can it only detect if the switch is completing the circuit?
Thanks!
Brady
Thanks!
Brady
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Toggle Switch Off Position
Hi Brady,
The short answer YES.
This will help you with all types of hardware. Note the different switch types. Whilst there is not a o/f/o switch diagram the principle is the same as two single switches.
http://siminnovations.com/wiki/index.ph ... n_examples
Keith
The short answer YES.
This will help you with all types of hardware. Note the different switch types. Whilst there is not a o/f/o switch diagram the principle is the same as two single switches.
http://siminnovations.com/wiki/index.ph ... n_examples
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: Toggle Switch Off Position
Brady,
As a minimum all systems including Air Manager that need to accept an electrical switch input need to be able to determine the difference between at least 2 states. This doesn’t necessarily mean you need a wire from 2 positions of that switch because you can represent the 2 states with a single wired connection to the micro and some form of switch common.
I can see why you may ask about a 3 position with centre off switch but It’s quite easy to implement. You have a few options depending on the type of switch and how you need it to work.
Add 2 AM buttons if the switch is a momentary action type. Each I/O line would connect to one of the switched terminals and the Arduino gnd to the switch common.
Add 2 AM switches and connect the same as for the buttons and just use the individual switch callbacks to action whatever you is want.
Lastly and probably the most conventional method would be to add a single 3 way switch in AM. This again only requires 2 Arduino I/O pins. The callback in this instance will return a position. You just use the returned position to determine what action to take.
As a minimum all systems including Air Manager that need to accept an electrical switch input need to be able to determine the difference between at least 2 states. This doesn’t necessarily mean you need a wire from 2 positions of that switch because you can represent the 2 states with a single wired connection to the micro and some form of switch common.
I can see why you may ask about a 3 position with centre off switch but It’s quite easy to implement. You have a few options depending on the type of switch and how you need it to work.
Add 2 AM buttons if the switch is a momentary action type. Each I/O line would connect to one of the switched terminals and the Arduino gnd to the switch common.
Add 2 AM switches and connect the same as for the buttons and just use the individual switch callbacks to action whatever you is want.
Lastly and probably the most conventional method would be to add a single 3 way switch in AM. This again only requires 2 Arduino I/O pins. The callback in this instance will return a position. You just use the returned position to determine what action to take.
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
- BradyBrother100
- Posts: 54
- Joined: Tue Oct 13, 2020 4:21 pm
- Location: United States MDT
Re: Toggle Switch Off Position
Ok, so how would I assign each position if there are only three wires going to the Arduino?(That includes the ground connection)
https://www.amazon.com/Twidec-Rocker-To ... ast_sto_dp These are the on/off/on switches I am planning on getting.
https://www.amazon.com/Twidec-Rocker-To ... ast_sto_dp These are the on/off/on switches I am planning on getting.
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Toggle Switch Off Position
Brady,
0= on(1) wire connected to arduino
1= off No wire connected to arduino BUT the arduino pin assigned must not be used for anything.
2= on(2) wire connected to arduino
The switch center wire is your earth.
Keith
0= on(1) wire connected to arduino
1= off No wire connected to arduino BUT the arduino pin assigned must not be used for anything.
2= on(2) wire connected to arduino
The switch center wire is your earth.
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
- BradyBrother100
- Posts: 54
- Joined: Tue Oct 13, 2020 4:21 pm
- Location: United States MDT
Re: Toggle Switch Off Position
Cool! That should work!
Thanks!
Brady
Thanks!
Brady
Re: Toggle Switch Off Position
All,
This is a bit hacky and I would prefer the option in the API to be able to be able to specify a switch position as off rather than having to allocate the I/O pin and just not use it. However you can re-use the un-connected pin if you don't like the idea of wasting a pin every time you want an off position.
Note you can specify an off for a simple 2-way switch by only setting the number of positions to 1 and AM will take care of the rest but we should really have something in the API for using an off (no connection) with a switch of any number of positions.
perhaps @Corjan , @Ralph can add to the to-do list.
The current hacky way is configured in a similar way to what follows.
hardware set as:-
3-way switch
pin pos 0 : D2
pin pos 1 : D3
pin pos 2 : D4 (leave un-connected)
button : D4
This is a bit hacky and I would prefer the option in the API to be able to be able to specify a switch position as off rather than having to allocate the I/O pin and just not use it. However you can re-use the un-connected pin if you don't like the idea of wasting a pin every time you want an off position.
Note you can specify an off for a simple 2-way switch by only setting the number of positions to 1 and AM will take care of the rest but we should really have something in the API for using an off (no connection) with a switch of any number of positions.
perhaps @Corjan , @Ralph can add to the to-do list.
The current hacky way is configured in a similar way to what follows.
hardware set as:-
3-way switch
pin pos 0 : D2
pin pos 1 : D3
pin pos 2 : D4 (leave un-connected)
button : D4
Code: Select all
function sw_callback(pos)
print(pos)
end
hw_switch_add("test sw", 3, sw_callback)
function but_callback()
print("button")
end
hw_button_add("test_but", but_callback)
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
- BradyBrother100
- Posts: 54
- Joined: Tue Oct 13, 2020 4:21 pm
- Location: United States MDT
Re: Toggle Switch Off Position
Hi! Yah, that would be nice if AM could detect if there was no signal coming from a switch. https://www.cockpitsimparts.co.uk/switc ... n-mon.html This is the switch I am probably going to get. I'll try your code once I get it.
Thanks!
Brady
Thanks!
Brady
Re: Toggle Switch Off Position
Not a case of AM detecting no signal as it can do this already in the same way as any micro controller can. What we need is a means to tell AM when one of the defined number of switch ways is not needed.
Let us know how you go once your switch turns up.
Let us know how you go once your switch turns up.
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: Toggle Switch Off Position
An alternative way is to do it with digital_input and then combine the two states.