Is it possible to simplify slider switch wiring (Double knife four throw) - Page 1
Forum section: electronics / projects

author: Georgy.Moshkin
author_rank: Frequent Contributor
timestamp: November 29, 2024, 12:51:19 pm
content: Assume I want a device to be turned on and configured using a single slider switch with settings for OFF/Low/Medium/High. Many devices, such as air humidifiers and some older massagers, use such switches. I have used a "double knife, four throw" configuration switch, model K3-2410D-F1 (datasheet). I tried to find a way to use a simpler switch, but I am almost certain that it is impossible. The attached image shows the switch connection schematic. The left row of pins is used for configuring the speed, while the right row of pins has three pins shorted together to function as a simple on/off switch. Is there any way to use "single knife" switch?

author: inse
author_rank: Super Contributor
timestamp: November 29, 2024, 03:33:01 pm
content: I don’t think it’s possible the way the “logic“ is working now.If you could “OR“ the speed select signals with diodes to generate an on signal, it would be possible to use a single pole switch.

author: schmitt trigger
author_rank: Super Contributor
timestamp: November 29, 2024, 04:15:30 pm
content: Minor correction, it is not a knife switch but a slide switch.If your circuit is DC, then a simple diode O’ring configuration would work. If it is AC, then it is also feasible but the solution would be far more complicated.

author: inse
author_rank: Super Contributor
timestamp: November 29, 2024, 07:57:10 pm
content: Not quite, one side is switching to GND, the other side supply voltage

author: Georgy.Moshkin
author_rank: Frequent Contributor
timestamp: November 30, 2024, 08:06:45 am
content: Thanks! I've tried the diode idea and changed GPIO outputs to positive ones but then realized that there is a huge voltage drop for a battery-powered device. I tried different ideas with resistive voltage dividers and N-channel MOSFET, and seems to find one possible solution.I am using AO3400A with a Li-ion battery (3v to 4.7v).With a resistor-only approach gate voltage becomes too close to a gate threshold voltage.I added three diodes. Almost like it except the fact that now I have to use 3 GPIO inputs instead of 2 GPIOs.Previously, I've used 2-bit state (00, 10, 11, 01) to encode 4 positions of slide switch.But now I need three. 1 MOhm resistors just to show where GPIOs will be connected.Does this circuit look good?https://tinyurl.com/294amtnb

author: inse
author_rank: Super Contributor
timestamp: November 30, 2024, 08:31:02 am
content: Looks good, only need to select a MOSFET with low gate voltage.Keep in mind that the gate threshold parameter is usually given for uA drain current, so you need to look at the curves.Why did you go for 1M series resistor to the GPIO?I would go for something lower and add a pull-down to each input, unless the GPIO can be configured for WPD.

author: Georgy.Moshkin
author_rank: Frequent Contributor
timestamp: November 30, 2024, 09:07:12 am
content: You are right! 1M is a bogus value. Here is an updated version. P-channel version has less resistors.I think that 2 GPIOs are enough to read 3 states:For N-channel:Two GPIOs with MCU internal pull-downs.In position 1 switch pulls-up GPIO1In position 2 switch pulls-up GPIO2In position 3 wire is not used, position 3 detected if GPIO1 and GPIO2 are still pulled down by MCU internal pull-downs.For P-channel:Two GPIOs with MCU internal pull-upsIn position 1 switch pulls-down GPIO1In position 2 switch pulls-down GPIO2In position 3 wire is not used, position 3 detected if GPIO1 and GPIO2 are in high position (MCU internal pull-ups)N-channel version:https://tinyurl.com/26mm7v8cP-channel version:https://tinyurl.com/22heebd5Quote from: inse on November 30, 2024, 08:31:02 amhmm, this is indeed very important.I have only looked into these curves:These curves are for pretty high current, so gate voltages >2v will safely open both transistors.Transistor datasheets:https://www.aosmd.com/res/data_sheets/AO3400A.pdfhttps://www.aosmd.com/pdfs/datasheet/AO3401A.pdf

author: Georgy.Moshkin
author_rank: Frequent Contributor
timestamp: December 23, 2024, 03:58:01 am
content: I think I've messed up with this one.See that LOAD on the schematic? It's STM32 with bunch of other ICs like opamps, LDOs, step-ups.The problem is that during the "off" state current somehow finds the way through STM32 GPIO outputs (ESD diodes, etc.) to the gate of N-Channel MOSFET. And it occurs only when battery is closer to discharged state, doesn't make sense to me why there is no leak when battery is fully charged though. It should be noted that the prototype PCB has an additional resistor to ground on the GATE pin (tried 1k, 10k, 100k), but it seems that the gate voltage remains the same() - leak looks like a voltage source. Currently, in "off" state, I can measure some voltage around 1.2v on 3.3v lines. Device looks disconnected and LEDs are not blinking.So, the only way is to switch to P-Channel high-side switch configuration?I thought about adding diodes on GPIO lines, or maybe there is another solution.

author: fourfathom
author_rank: Super Contributor
timestamp: December 23, 2024, 04:46:30 am
content: Add a high-value pulldown resistor (to ground) at the MOSFET gate. Otherwise the gate capacitance will stay charged when all switches are open, and the MOSFET won't turn off for a long time (if ever).

author: inse
author_rank: Super Contributor
timestamp: December 23, 2024, 05:16:24 am
content: Oops, forgot about the gate discharge resistor..Make the 1k gate resistor 100Ohms and place 10k from gate to source.Another issue you identified yourselves is the GND level issue as in off state the GND of the circuit will be above source potential of the MOSFET thus creating a path via the input protection diodes to charge the gate.If you don’t mind a couple of uA quiescent current, place >100k in series with your GPIOs, so you will have a divider for the stray gate voltage in off state.This will not allow the MOSFET to turn on and won’t affect the level detection in on state as the GPIOs are high impedance inputs.Switching to PMOS would only create a mirror of the probem.

author: Georgy.Moshkin
author_rank: Frequent Contributor
timestamp: December 25, 2024, 01:29:31 pm
content: Thanks, that worked! N-Channel MOSFET is currently fully off: I measure 0v on both gate and source. Source is connected directly to the external ground, and the gate is pulled down by a ~10kOhm resistor to the same external ground. This was thanks to the 100kOhm resistor you've suggested in series with MCU's GPIO inputs.In OFF state there is a 2.5 voltage drop across 100kOhm resistor in series with GPIO.According to the formula I=2.5/100000 = 25 , I guess it's the only way with my current design.I have 0.67v across decoupling capacitors of MCU in off state.I haven't measured all voltage drops, but 0.67+2.5 is around 3.17.Battery voltage is 3.82v, so there is 0.68v is dropped somewhere.

author: inse
author_rank: Super Contributor
timestamp: December 25, 2024, 01:59:18 pm
content: In fact you have 3x25uA as there are three 100k resistors…You could go higher, but I would stay below 1Mohm if quiescent current is an issue.Just check at the uC pins whether there is a drop in the signal.Also depends on input config like comparator or GPIO and WPU enabled