Powering and function selection with SP5T switch - Page 1
Forum section: electronics / projects

author: okw
author_rank: Frequent Contributor
timestamp: December 06, 2023, 10:05:25 pm
content: Hello.I have a SP5T rotary switch, and I want it to work as a both a power switch and a position switch.Position 1 is off, position 2, 3, 4, 5 will power the MCU (and everything else) + MCU will read which position the switch is in.If I had a separate power switch, I could simply use a resistor ladder and read the analog value.Am I looking at a rather complex network of separate transistors on each position?Also, between switching position, the MCU should stay powered. Could be quite a bounce, since the switch is quite tight. Some big caps maybe?

author: Benta
author_rank: Super Contributor
timestamp: December 06, 2023, 10:26:29 pm
content: Wire-OR 2,3,4,5 using Schottky rectifiers to power the MCU. A cap is a good idea.Then the MCU can read the switch as desired.Yes, your MCU supply voltage will be a bit lower. Dunno if that's an issue.

author: moffy
author_rank: Super Contributor
timestamp: December 06, 2023, 10:28:51 pm
content: You could use 4 diodes, one each from 2-5, all joined together at their K end to provide a drive signal to a semiconductor switch connected to power and the MCU. Depending on current load for the MCU circuit, if you can tolerate a 0.7V drop then silicon diodes could power the MCU, or 0.4V then schottky diodes would work.

author: themadhippy
author_rank: Super Contributor
timestamp: December 06, 2023, 11:12:53 pm
content: Id just buy a 2 pole 6 way switch and shift the washer to make it 2 pole 5 way

author: okw
author_rank: Frequent Contributor
timestamp: December 08, 2023, 11:48:27 pm
content: Quote from: Benta on December 06, 2023, 10:26:29 pmYou mean something like what I have in the image? I also added a resistor ladder, to only use one ADC input. I'm not sure if this will eat some battery(?).The 0.4V Schottky drop will will for sure eat some battery capacity, but not sure if it will be a practical issue.

author: Benta
author_rank: Super Contributor
timestamp: December 09, 2023, 12:39:17 am
content: For the diodes: exactly what I meant.I don't understand your resistor network.

author: okw
author_rank: Frequent Contributor
timestamp: December 09, 2023, 12:53:40 am
content: When the switch is in any of the ON-positions (2,3,4,5) it creates different voltages depending on where 4.2V is injected. If I tap into POS2 (schematic shows POS1 but the difference between a few of the voltages was too small and more difficult to distinguish for the ADC):Switch 1: (off)Switch 2: 3.8V on POS2Switch 3: 4.2V on POS2Switch 4: 1.7V on POS2Switch 5: 0.9V on POS2I then bring POS2 out to a voltage divider to get max 3.3V (actually 3.158V) when POS2 is 4.2V.Then TO_MCU_ADC is read by the MCU ADC to distinguish which position the switch is in.The above readings will drop with decreasing battery voltage and current draw. So I'm worried when values drop, it will be interpreted wrong in my code.

author: Benta
author_rank: Super Contributor
timestamp: December 09, 2023, 01:18:44 am
content: Yeah, but why so complicated? This is much simpler (change resistor values to fit):

author: okw
author_rank: Frequent Contributor
timestamp: December 09, 2023, 01:42:38 am
content: LOL - embarrassed. Yes, why complicated things.I thought about resistor ladder for multiple push buttons, but they are usually designed to short to ground.As my switch provides power, much simpler to read.Thanks

author: ArdWar
author_rank: Frequent Contributor
timestamp: December 09, 2023, 01:46:54 am
content: Not complicated actually, maybe even better if you want to reduce BOM complexity. Just remove R21 and R24, and set all resistor to the same value. Your output voltage then will be 1/2, 1/3, 1/4, 1/5 Vin. You don't need to be linear here, just distinct.Or maybe set R22 to twice the other value so your output will be 2/3, 2/4, 2/5, 2/6. Slightly wider separation.