Electronic – Solution for accepting 3-24v as digital high for microcontroller

designdigital-logicmicrocontrollersensorsignal

I'm after any suggestions for converting a digital input in the range of 3-24vdc to a 3.3v signal for a microcontroller.

I need to handle a total of 32 inputs (each of which could vary anywhere between those voltages), so density is more important than cost.

Someone suggested a non-inverting hex buffer like TI's CD4050 (http://www.ti.com/lit/ds/symlink/cd4050b.pdf) might be the solution, but I'm not entirely sure if it will handle multiple different input voltages.

Thanks in advance for your suggestions.

EDIT: The inputs will be connected to either:

  1. Various mechanical switches which may pull the line to GND or to a voltage anywhere in the given range of 3-24v

or

  1. Sensors of various types with digital outputs. Those outputs could be low (gnd) or high with voltages that could be anywhere in the given 3-24v range, depending on the type, make and model of the sensor.

Any of the inputs could be connected to any type of switch or sensor within the limits specified above.

EDIT 2: Multiplexers and the like are unfortunately not possible as timings are VERY tight and interrupts of varying priority are to be used extensively which requires direct connections to the microcontroller pins.

Best Answer

You could use dual pre-biased transistors (16 required). If the MCU has suitable internal pullups you would not require any other parts. R1/R2 of 22K/22K or 47K/47K could be suitable. The input voltage rating is -10V to +40V for those values.

enter image description here

They're about 2mm x 2mm, so they don't use up much board space.