EEVblog Electronics Community Forum
Electronics => Projects, Designs, and Technical Stuff => Topic started by: okw on December 06, 2023, 10:05:25 pm
-
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?
-
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.
-
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.
-
Id just buy a 2 pole 6 way switch and shift the washer to make it 2 pole 5 way
-
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.
You 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.
-
For the diodes: exactly what I meant.
I don't understand your resistor network.
-
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 POS2
Switch 3: 4.2V on POS2
Switch 4: 1.7V on POS2
Switch 5: 0.9V on POS2
I 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.
-
Yeah, but why so complicated? This is much simpler (change resistor values to fit):
-
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
-
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.