3
\$\begingroup\$

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.

\$\endgroup\$
25
  • \$\begingroup\$ Did you read that datasheet? \$\endgroup\$ May 1, 2017 at 5:17
  • 3
    \$\begingroup\$ How about a 10:1 voltage divider and a comparator? \$\endgroup\$
    – uint128_t
    May 1, 2017 at 6:07
  • 1
    \$\begingroup\$ There could be lots of system design issues here. How are the sensors powered? Could they be powered when the micro isn't? Because that will require special treatment if that is the case. Etc. \$\endgroup\$
    – user57037
    May 1, 2017 at 6:39
  • 2
    \$\begingroup\$ How about a large value resistor, and a low-drop diode to the 3.3 v rail. This will read high for any voltage > 2.5 V. Use a much larger pull down resistor so even 3 V input still exceeds the logic threshold. \$\endgroup\$
    – tomnexus
    May 1, 2017 at 7:03
  • 1
    \$\begingroup\$ Such sensors are common on PLCs. Opto-isolated inputs are are the most common robust solution to the task you have described. The 3V input requirement requires careful component selection 5V is more common and much easier to achieve. Follow some of the links on this image search. - google.com/search?q=3V+24V+opto+isolator&tbm=isch \$\endgroup\$
    – KalleMP
    May 1, 2017 at 15:33

4 Answers 4

9
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Thanks for the suggestion @spehro-pefhany. I think this will probably do what I'm after. Components have been ordered and I'll start testing tomorrow. Thanks again. \$\endgroup\$ May 2, 2017 at 13:07
3
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

With pull-up resistor input voltage microcontroller is HIGH. No matter what is voltage on 3-24V input. Except on 3-24V input voltage below the threshold microcontroller input. (including the forward voltage across the diode). In this case, the diode passes current and the input of the microcontroller is LOW.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ The major problem here is that the MCU input will have a Vinput(Low) of < 0.8 V typically, so to pull the input to a guaranteed low you have to have extreme low voltage (even if you use a Schottky diode) of < 0.6 V or less on the sensor side. That will be hard to achieve. \$\endgroup\$ May 1, 2017 at 16:31
  • \$\begingroup\$ @Jack Creasey, you are right. If I understand the question these requirements are met. And Schottky diode version with less demanding than the version of the FET. And diode to protect the microcontroller when it is no supply voltage. \$\endgroup\$
    – AltAir
    May 1, 2017 at 19:18
3
\$\begingroup\$

Since your voltage range is so high I think you could achieve a good result with a single N-Channel FET. There are FET's available that have V(GS) ratings above 24 V ....here's one that has a 40 V rating: 2n7002. You can even get FETs in an array, though it's a bit tougher to find them with high V(GS) ratings.
You could also use the newer FETs such as the NTJD5121NT1G, these have Gate ESD protection diodes built in and you could use this to clamp the input with only a series resistor. You can see from the datasheet that the ESD protection is beginning to conduct at the gate rating of 20 V.

schematic

simulate this circuit – Schematic created using CircuitLab

The V(GS) transfer curve is:

enter image description here

This should provide an input high of about 1.5 to 24 V. Low would need to be below 1 V input.

No matter what you do for 32 inputs you are going to need at least 32 resistors (if you want high impedance inputs) and probably 16-32 SMD packages, so significant board space is going to be required. You could consider an HV5622 and use a serialized reading method as I proposed here. The sense input could be re-arranged to use a single comparator. This reduces PCB complexity, but it's still a layout job with lots of tracks. The nice thing about serial acquisition is of course it/s easy to separate the acquisition board and isolate from the MCU.

\$\endgroup\$
7
  • \$\begingroup\$ Thanks for the excellent detail in your answer Jack. I think this solution would definitely work, however for 32 individual inputs I think the circuit might get a little complicated and take up a bit too much board space. \$\endgroup\$ May 1, 2017 at 9:11
  • \$\begingroup\$ @LachlanFletcher You can also get pre-biased transistors which have the resistors integrated into the package. These come in dual packages so you could get by with 16 of these. Look at something like the NXP PUMH range. \$\endgroup\$
    – Jon
    May 1, 2017 at 10:22
  • \$\begingroup\$ This one will of course may not work if \$V_{OL}\$ max > 1.022V which is not atypical for 24V sensors and definitely will not work if \$V_{OL}\$ max > 2.555 which is also not unheard of. \$\endgroup\$
    – Trevor_G
    May 1, 2017 at 13:37
  • \$\begingroup\$ Add to Jack's answer the possibility of a 36V 16 channel multiplexer and you can simply scan the inputs. That would require the power to be at or above the maximum expected input voltage though; ti.com/product/mux36s16 \$\endgroup\$ May 1, 2017 at 14:35
  • \$\begingroup\$ @Trevor. You can of course select the FETs with any V(GS) threshold you want, I simply selected one of the newer very low threshold devices. \$\endgroup\$ May 1, 2017 at 15:45
1
\$\begingroup\$

the simplest would be to use a large resistor for each of the input. the clamping diode on the input pin + that resistor will do a fine job.

alternatively, use a resistor + a 3.3v zener.

more complex answers also exist.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Certainly this would provide a high into the MCU, but it would be unlikely to provide a guaranteed low (through this high value resistor). Consider an example ... a 3.3 V port input with the internal pullup resistor (47k) on. To pull this input to a valid low (<0.8 V) requires a pulldown of 15k or less (and to 0 V). 15k will result in a current flow into the MCU clamping diode of 1.3 mA when high. I'd consider it bad form to do this (a potential 43 mA in total through the MCU clamps). Perhaps a common TL431 and 32 diodes might be more acceptable. \$\endgroup\$ May 1, 2017 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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