Toggle switch / Relay - Page 1
Forum section: electronics / beginners

author: cothien
author_rank: Newbie
timestamp: November 11, 2015, 01:43:43 am
content: I have been trying to learn electronics and gave myself a project to focus on. Just doing some toggle switches for a flight sim controls.I got a basic control circuit with a on/on toggle switch that when flipped up will press the key and turn a light on and flipped down will press the key again and turn the light off.I ran into a issue where I need it when flipped up it presses one key and then when down it presses a different key. I thought maybe doubling the circuit and using a on/on DPDT toggle this would work, but all it would do is set both relays off and press both buttons at once. After thinking about it, wasn't sure why I thought that would work.I am kind of at a loss at what I would need to do what I am looking for. Thought making a switch pressing one button in the up position and press another button in the down position would be a bit simple.This is the diagram of my circuit. Using a header connection for the switch since I couldn't find a matching switch one.

author: cothien
author_rank: Newbie
timestamp: November 12, 2015, 05:35:05 am
content: I ended up solving the toggle switch. While working on other parts I somehow moved a wire on the breadboard and never noticed. Found in a couple of minutes today.Even though I learned how to get the relays to alternate with the switch. I am still clueless on how to get it so that when its in the up position it will do connect for letter A and down position it will connect for letter B. Since it is a on on switch it gives both A and B.I have thought about different types of relays, but looking at them I feel like I will run into the same issue. Kind of wondering if there needs to be something in between the switch and relays to direct what gets the signal, but not sure.

author: Ian.M
author_rank: Super Contributor
timestamp: November 12, 2015, 09:42:54 am
content: There are actually hundreds of better ways of doing this, ranging from using 555 timer chips in their monostable configuration to generate the timed pulses to drive the relays, all the way through via optocouplers to eliminate the relays, and something like an Arduino or other MCU controlling them, up to a fancier MCU running as a USB HID keyboard device, directly reading the toggle switches.However if you are determined to persevere with an electro-mechanical solution, the key to making it work with two relays, is to put their coils in series with the fixed contacts of the switch and the capacitor on the moving contact. This does mean that you no longer have a good switched voltage to feed the LED. It now has to be powered from the voltage across the capacitor, drawing its current through the upper relay coil so the resistor must be an order of magnitude greater than the coil resistance so it doesn't interfere with the relay's operation. You'll therefore probably want to use a high efficiency 'superbright' LED.

author: cothien
author_rank: Newbie
timestamp: November 12, 2015, 06:49:34 pm
content: Thank you for the information. Will try to put it together tonight.I understand that there are better ways to do this, but currently I am very limited on parts. Figure it's worth at least learning what I can with the parts I have.

author: Ian.M
author_rank: Super Contributor
timestamp: November 12, 2015, 07:04:05 pm
content: N.B. As drawn, the circuit doesn't have any provision for damping the current in the relay coil at the moment the switch opens. This is OK because, apart from the LED current, there should be no current through the coils at the moment the switch is operated. However, if in the throes of your gaming passion, you are prone to frobulate the switches, it would be well worth adding anti-parallel diodes to both coils to clamp the back EMF.