# How can a GPIO logic to high amp/voltage logic adapter be built using multiple voltages? (5v, 12v, 24v)

I'm working on a project that requires making a fairly universal board (to work on different model machines). I need to hook up many pre existing motors and switches/sensors to the board that all work off of different voltages and have their own unique pin/plug configuration. I figured using fpga would allow programming of the correct configuration, but I need the 3.3v fpga pins to accept input/output from 5vdc, 12vdc, and 24vdc selectively. Is there any simple solution out there? They all need pwm capability, and the ability to drive small motors/devices.

I have thought of using load switches for the outputs, which seems correct. As for inputs, I was thinking isolators, but they don't allow such a wide range of input voltages if I am correct. The only other thing I can think of is voltage regulators in series or parallel to convert the voltage to 3.3v logic. However this may pose a problem where pins can not be ground (as in 0v) for high current as well as serve as a logic input. Any help or ideas would be appreciated.

• Be clear... are you wishing to convert 5V logic level signals to 3V3 logic levels or the other way around. – Andy aka Dec 19 '15 at 22:13
• @Andyaka 3.3v logic I/O, to I/O of 5, 12, and 24v. – mr danker Dec 19 '15 at 22:18
• What speed requirements? – Andy aka Dec 19 '15 at 22:25
• @Andyaka As far as I know, just PWM for driving stepper motors. Somewhat high amps for small motors to produce a small bit of torque temporarily (1 or 2 amps). It's for vending machine control. – mr danker Dec 20 '15 at 16:06

For your wide range inputs you could consider a solution that I have used a number of times. Bring your inputs in through a circuit like this:

As shown the input threshold for high/low is set at 2.5V by use of the TLV431. The input signal coming through the 2.2K series resistors are clamped to the 5V supply to keep them in safe input range of the AM26LV32. Outputs swing from rail to rail of 0 to 3.3V for input to the FPGA.

For wide range inputs, I managed to build one recently that worked from 5v to 30v or so with an optoisolator, zener diode, and a pair of resistors. Basically, design the circuit such that the LED current at the input is in range for the entire voltage range that you are interested in. It is also possible to stick a bridge rectifier in there to make the circuit insensitive to polarity, at the cost of around 1.2 volts or so of extra drop. The resistor and diode are selected to produce the minimum turn-on current for the optoisolator at around 5V, ramping up to the maximum LED current when the zener starts to conduct.

simulate this circuit – Schematic created using CircuitLab

• That would be great! – mr danker Dec 19 '15 at 22:17
• I've used opto couplers for inputs in the past but instead of zeners or resistors I used a constant current diode to limit the opto coupler LED current to 3.5mA. The problem I've had is that often the opto couplers are two slow for some applications where for example a shaft encoder is presenting inputs at frequencies up into the MHz. If you truly need ground isolation then the opto isolators are the way to go but they give little benefit in cases where GNDs are all tied together. So look at my answer for another solution where GNDs are common. – Michael Karas Dec 19 '15 at 22:51
• CRDs also work, but I found that they can be quite a bit more expensive than a couple of resistors and a Zener diode. They also sometimes have a rather large voltage drop which could cause issues at the low end if the range. – alex.forencich Dec 20 '15 at 0:12
• @MichaelKaras -- great minds must think alike ;) (I wrote up a nigh-universal input circuit in my lab notebook during college that's basically the same as yours with a bridge rectifier on the frontend to render it polarity-insensitive, and using a depletion MOS for the current source instead of a CRD.) – ThreePhaseEel Dec 20 '15 at 1:31
• @ThreePhaseEel - The CRD's do have issues with the voltage drop which means that a General Purpose Input going to an opto coupler does not work well for a 3.3V input and does work for 5V OK under most conditions. By the way CRD's are built with an N-channel JFET with the gate tied to the source circuit after a series source resistor. – Michael Karas Dec 20 '15 at 3:20