Analog Switch - state when starting up? - Page 1
Forum section: electronics / beginners

author: Saimoun
author_rank: Frequent Contributor
timestamp: December 21, 2020, 10:33:41 am
content: HiMost analog switch's datasheet say the control pin should not be floating.Which makes me wonder:1) what state is the switch in while Vcc is < min value and right after it has reached the minimum value?2) is it then "good enough" to connect it directly to a MCU GPIO, thinking that the GPIO will take a few ms to be high or low (default is typically floating)? Or would a pull-up resistor (say 10k and Vcc=3.3V) working with an open-drain GPIO be a better idea?I am thinking generally - but we can take this SPDT switch as example:https://www.diodes.com/assets/Datasheets/74LVC1G3157.pdfThank you

author: S. Petrukhin
author_rank: Super Contributor
timestamp: December 21, 2020, 11:09:43 am
content: The switch is a strict hardware logic, often with a high input impedance and in a floating state can catch anything.With a Vcc threshold, no one will give you a guarantee of its state, unless there are special measures in this switch to guarantee the state.I never leave important MCU outputs directly connected to actuators unless those devices have a guaranteed floating input state.But i also like the pull-down resistor floating inputs so that the output state of 1 MCU can turn on and in the absence of a signal from the MPU, they were guaranteed to be turned off.Do not forget that in addition to a small delay configuring pins in the MCU at startup, all its pins will be floating inputs and during the firmware download. If you update the firmware in a working device, you may get an undesirable result with the spontaneous activation of the managed devices.

author: fcb
author_rank: Super Contributor
timestamp: December 21, 2020, 11:16:57 am
content: Pg. 4 of the datasheet. IINis max +/-10uA at any Vcc, so you can probably assume the switching input will drift to one rail or another if unconnected.Depending on the consequences of having the switch in an unknown state, I wouldn't bother with pull-ups open-drains etc.. unless you need them for level-translation, and unless you need to switch super-fast 10K is 0.33mA - and as Dave says "you can fly-to-the-moon on that".

author: Ian.M
author_rank: Super Contributor
timestamp: December 21, 2020, 11:49:22 am
content: If you *DO* need to avoid it floating, 100K would be plenty to hold its state (below 85 deg C) while the MCU I/O is tristate. In fact you could probably go as high as 400K (+/-1uA switch input leakage & +/-1uA MCU input leakage) and still meet its VILthreshold for Vcc>3V. 100K would be 33uA when the MCU output is in the opposite state, which is negligible except in low power battery powered applications.

author: Saimoun
author_rank: Frequent Contributor
timestamp: December 21, 2020, 03:28:03 pm
content: Thank you all for your repliesNobody directly answered my second question - but as I understood either solution is fine? if not please tell meQuote from: S. Petrukhin on December 21, 2020, 11:09:43 amUnderstood - but the analog switches (at least the ones that say do not leave the select pin floating) do have a floating input state, so I can connect directly a GPIO pin to the "switch" pin of an analog switch, right?

author: SmokedComponent
author_rank: Regular Contributor
timestamp: December 21, 2020, 04:59:36 pm
content: Looks like a standard high impedance logic input. Connect select input directly to MCU output but also pull it up via 100K (or down, depends on which state do you want before the MCU and program start).

author: rstofer
author_rank: Super Contributor
timestamp: December 21, 2020, 06:07:27 pm
content: Some (most, all) CMOS reacts badly to floating inputs. I'm not keen on pull-down (old TTL user) so I would always pull up. The pin needs to be at one level or another at all times.What is the state of the pin during device programming? Could the pin be floating for a relatively long time?To get a clean startup, given a pull-up resistor, set the output pin to logic '1' before enabling it as an output.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: December 21, 2020, 06:35:22 pm
content: Quote from: simonlasnier on December 21, 2020, 03:28:03 pmYou can connect any analog switch directly to the GPIO that matches the control voltage. You can even use an analog switch to switching GPIOs.If this analog switch switches something inside your circuit, for example, selects which signal is fed to the ADC, then you do not care what it chooses at startup until the processor sets the necessary state.But, if the analog switch controls some external device, for example, turns on the rotation of the drum of the washing machine, then you should not neglect the spontaneous switching on and you need to use a resistor to ensure the default state at the input of this switch.

author: S. Petrukhin
author_rank: Super Contributor
timestamp: December 21, 2020, 06:41:19 pm
content: Quote from: rstofer on December 21, 2020, 06:07:27 pmBy the way, I was also used for a long time that the floating TTL input is 1. But in industrial automation, the absence of voltage is 0, which in principle is more logical and now I'm used to pulling to Gnd.

author: Saimoun
author_rank: Frequent Contributor
timestamp: December 21, 2020, 11:32:03 pm
content: Thank you everybody it is a lot clearer now