3

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.

  • Did you read that datasheet? – Chupacabras May 01 '17 at 05:17
  • Yes. Several times. – Lachlan Fletcher May 01 '17 at 05:35
  • What sort of loading do you need? i.e. are you looking for high impedance? – Jack Creasey May 01 '17 at 05:47
  • 3
    How about a 10:1 voltage divider and a comparator? – uint128_t May 01 '17 at 06:07
  • Yes, a divider. If it is a high-speed signal, the divider bandwidth can be improved by using a capacitive voltage divider as well as a resistive voltage divider. The upper capacitor should just be a few pF. Lower one chosen to produce the right ratio. – user57037 May 01 '17 at 06:15
  • Wouldn't a 10:1 divider and comparator be a little bit of a worry if the input was only 3 volts? – Lachlan Fletcher May 01 '17 at 06:19
  • The comparator threshold would be set at 0.3V. You will have to use a few 1% resistors and go through the corner calculations. But I suspect it is doable. – user57037 May 01 '17 at 06:20
  • Yes, high impedance loading. – Lachlan Fletcher May 01 '17 at 06:21
  • You could use a comparator with no divider, and just clamp the input to protect it. But that could be kind of abusive to the source, depending on what it is. In that case the threshold would be set to 3V. – user57037 May 01 '17 at 06:21
  • It would help to know more about the input voltages and thresholds you want for determining the logic level. Eg is the crossover level(s) always the same? And what are they? – Jodes May 01 '17 at 06:29
  • 1
    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. – user57037 May 01 '17 at 06:39
  • 2
    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. – tomnexus May 01 '17 at 07:03
  • @mkeith Could you explain why that is relevant? – Lachlan Fletcher May 01 '17 at 07:04
  • More information is really required here... what exactly does 3-24V signal mean? – Trevor_G May 01 '17 at 12:57
  • @Trevor could you clarify exactly what more information you require? – Lachlan Fletcher May 01 '17 at 13:13
  • Um.. is that a range... is that a min max? Is that logic levels... you say you have many, are they all the same..... What are the values of logic low Max and logic High Min.... Also what is the source impedance of the signals... – Trevor_G May 01 '17 at 13:15
  • (each of which could vary anywhere between those voltages), ... what exactly do you mean by that... are these actually analog signals? – Trevor_G May 01 '17 at 13:17
  • @Trevor thanks so much for the comments. Please see the edit above. Hopefully that answers your question. Thanks again. – Lachlan Fletcher May 01 '17 at 13:21
  • Option 1 can be handled with most of the answers below however option 2 still needs you to define the sensors low level voltage. You say GND... but that is rarely the case... Some 24V outputs have some fairly high level logic zero voltage ranges and output impedance can be a problem. – Trevor_G May 01 '17 at 13:28
  • Assuming that is... ground at the sensor = ground at the receiver... – Trevor_G May 01 '17 at 13:40
  • @Trevor I can't tell you that because it depends on the exact sensor, and that is not determined beforehand. That's really the point of my question. If all the exact parameters were fixed and known beforehand then I could simply design the circuit to suit. The point of the question is how to design a circuit that will accept a very wide range of possible sensor types. – Lachlan Fletcher May 01 '17 at 13:46
  • @LachlanFletcher that's my point though. It may be **impossible** to devise a simple generic solution that meets all your needs without using a circuit that the micro, or the user, can adapt to adjust it to the connected sensor. – Trevor_G May 01 '17 at 13:56
  • Do you need to measure this voltage or it is just a digital signal? – 0___________ May 01 '17 at 14:45
  • 1
    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. - https://www.google.com/search?q=3V+24V+opto+isolator&tbm=isch – KalleMP May 01 '17 at 15:33
  • If you have a circuit which is not powered, and you drive an input to a high voltage, that will lead to unpredictable behavior of the unpowered circuit. If that is a possible case, then the inputs need to be protected so that they remain high impedance until the local circuit is powered up. – user57037 May 01 '17 at 16:36

4 Answers4

9

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.

abdullah kahraman
  • 5,930
  • 7
  • 59
  • 104
Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842
  • 1
    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. – Lachlan Fletcher May 02 '17 at 13:07
3

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.

Jack Creasey
  • 21,428
  • 2
  • 15
  • 29
  • 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. – Lachlan Fletcher May 01 '17 at 09:11
  • @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. – Jon May 01 '17 at 10:22
  • 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. – Trevor_G May 01 '17 at 13:37
  • 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; http://www.ti.com/product/mux36s16 – Peter Smith May 01 '17 at 14:35
  • @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. – Jack Creasey May 01 '17 at 15:45
  • @JackCreasey Yes I know, but a "generic" variant for a wide range of sensors may be unrealistic. I do prefer this answer for a more controlled sensor set though. – Trevor_G May 01 '17 at 15:47
  • Thanks for the comment Peter. Please see my edit above for details on multiplexers and the like. – Lachlan Fletcher May 02 '17 at 06:03
3

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.

Dave Tweed
  • 168,369
  • 17
  • 228
  • 393
AltAir
  • 739
  • 4
  • 16
  • 1
    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. – Jack Creasey May 01 '17 at 16:31
  • @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. – AltAir May 01 '17 at 19:18
1

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.

dannyf
  • 4,272
  • 1
  • 7
  • 9
  • 1
    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. – Jack Creasey May 01 '17 at 16:57