I am working on a project which involves reading a 0-5V voltage measure (related to custom-made encoders made of slide potentiometers) to ADC on STM32F103. However, I have only one pin with ADC available. Anyway - i have 3 measurements which I would like to multiplex - and there comes the problem. The measures do not need to bo switched with high frequency, they will be switched only when needed to be read.

I was thinking about using NPN transistors, although I am not sure if I have used them correctly. Anyway - is it a good idea? Are there any other possibilities?


LTSpice uC NPN switching sim

  • \$\begingroup\$ What is the resistance values for the slide pots and are you allowed to rewire them into a new design if asked to do that? \$\endgroup\$ – jonk Oct 25 '17 at 8:06
  • \$\begingroup\$ 100k. The project is still being designed, so yes. \$\endgroup\$ – user166843 Oct 25 '17 at 8:14
  • \$\begingroup\$ You seem to have digital outputs available. I assume these can also be used as digital inputs, if you wanted to do that. So this means there are lots of ways to go here. You could even free up the ADC input itself for a different use, if you wanted, and just use digital I/O for this (and a capacitor.) Or you can use I/Os to enable one, or another, of the the sliders as a current source to an opamp, whose output then goes to the ADC. Disabling other sliders is nothing more than setting the driving I/O pin to "0" (or "1" depending on the arrangements.) The active slider gets the other I/O state. \$\endgroup\$ – jonk Oct 25 '17 at 8:27
  • \$\begingroup\$ For example, see: reibot.org/2011/05/23/… \$\endgroup\$ – jonk Oct 25 '17 at 8:30
  • \$\begingroup\$ Or use the digital I/O pin as indicated in the link I gave. But it requires a timer process you may want to avoid in your software. So perhaps the opamp method is better here. Up to you. \$\endgroup\$ – jonk Oct 25 '17 at 8:33

I would suggest that the use of the transistors injects unnecessary offsets and errors into your analogue signal measurements. Instead use a very simple chip such as the common 74HC4066. This has analogue switches that will suit your 0V to 5V signal range and each switch can be controlled from a port pin just like you are trying to control the transistors.

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.