Universal Interface

The Universal Interface

It’s time to present a relatively simple yet useful device: the Universal Interface. The need for this little helper arised when building the control for my CNC milling machine. But that’s a major project that I will introduce another time. Today it’s only about this little board.

Universal Interface at work inside the CNC control cabinet

My challenge was that I had to connect to and from a variety of external devices. Such as coolant pumps, pneumatic valves, probes and the like. Input and output signals could be anything from 5V logic, open collector logic, 24V logic to a relay. And they could be active low or active high.

The backside

Some situations also required a bit of logic. Not much but still some. Something like an AND and an OR gate or so. None of those circuits were challenging to design. But there were several of those and I didn’t really want to custom design and build a board for each one. Besides the fact that some in- and outputs were not entirely final yet or could change in the future. In other words, I wanted a single design that is flexible enough to handle all the present and future little challanges.

A total of 4 such interfaces are at work in the CNC control

Now to the design. There are 3 inputs (A, B and C) plus an enable input (EN). Each of these inputs is 24V tolerant and can be equipped with pull-up or pull-down resistors. And each of them can be configured to be either active high or active low. And of course, each of these inputs is nicely debounced by running it trough an RC filter followed by a Schmitt triggered logic gate. The logic state of each input is indicated with an orange LED located next to the input.

The inputs

Next comes the logic part. It uses a 74HC151 8-input logic multiplexer. The three inputs A, B and C select, which of 8 possible inputs is selected. The logic value of these inputs is then determined by 8 resistors as shown below. This allows an arbitrary logic function to be implemented in hardware. Nothing on this board requires software, it’s all hardware.

A hardware-configured logic table

Then comes the output stage. There is only one single logic output but it is provided in multiple varieties:

First, there is a single-pole, double-throw (SPDT) relay that is good up to 250 volts and 10 amps.

Then there is a powerful open collector output that can drain up to 2 amps. Flyback diodes are already included so this output can directly be used to drive another relay, a motor or whatever.

Then there is a standard CMOS 5V logic output. It can source or drain up to something like 25mA, pretty standard really.

And then there is also a 24V logic output which can optionally be equipped with a pulldown resistor or as a push-pull output as you know it from a typical CMOS gate. It can easily sink or source something like 500mA, maybe more. Protection diodes are also provided.

The outputs

And then there is also the enable input. If the enable input is not active, the 5V, 24V and OC output will all enter a high-impedance state. Of course, the relay does not have a high-impedance state and will just remain in its unenergized (i.e. off) position.

The power supply

As this circuit was intended to for use in an industrial environment, its supply voltage is 24V. This could easily be changed to 12V by simply using the 12V version of the relay – nothing else needs to be changed. The 5V voltage for the logic and 5V output is generated by a switching power supply that is good for up to 1 amp output current (far more than ever needed here) and an input voltage up to 30 volts. There is plenty of capacity both at the input (220uF) as well as the output (680uF). And yes, it is also reverse-polarity protected.

Side by side

That’s all I can say about this device. I’m currently using 4 of them in my mill, with different configurations, and they all work reliably.

There is room for more.

As you never know what the future brings, there is room for 3 more of these little helpers in the control cabinet. And if something is to change, I can likely accomodate for that change by simply changing a few resistors.

Where the input signals get treated

As all my stuff (or most of it, anyway), this project is on github:

17 thoughts on “Universal Interface”

    1. Just studied your schematic. So it does not accept 5v to 24v but just 24v on the logic inputs. I think you could find of much better ways to make the inputs accept 24v only and perhaps you should optoisolate them from the rest of the circuit.

  1. Hi Panagiotis

    Yes, they work perfectly with 5V. The reason they accept 24V (and actually even higher voltages) is the clamping diodes of the 74HC14 in connection with the R of the RC filter.

    Like most ICs, the 74HC14 has clamping diodes at its inputs. So any voltage is clamped to supply voltage plus a diode drop. You only need to make sure there is not too much current flowing. With the 51k resistor the 5V supply voltage and 24V at the input (of the board), less than 0.4mA flow. I don’t have the specs in my head but that is definitely well within the acceptable range for that chip.

    With 5V at the input of the board, the input at the IC pin is also at 5V because no current flows. So it also works flawlessly with 5V logic.


  2. Thanks for your reply.
    How fast does it trigger when applying a 5v signal?
    I think the on/off frequency will be very low probably on the few hz range. Have you checked it?

    1. That all depends on the values you chose for R and C. In most (but not all) my applications, I want it to be slow in order to e.g. debounce a mechanical switch. So I chose R=51kOhms and C=100nF. That gives a time constant of about 5ms. If you want it faster, just reduce C (or remove that C alltogether). For the probe, for example, I’ve used R=51kOhms and C=1nF for a time constant of only 50us.

  3. This is really cool, and I would love to experiment with them on my own projects.

    Do you make/sell the boards, or would you prefer we have them made independently?

    1. You can get them made for little money from dirtypcbs.com. That’s where I got mine. The gerber files you need to order them are on github. Make sure you use Rev B, there is a mistake on the Rev A board.

      1. Thanks for the recommendations, and again for the great work. If I end up using these, which I likely will, I’ll have to come up with something to reciprocate in thanks.

        BTW, while I was driving across country for the holiday I got to wondering if I/we 3D printed a standing mount if we could pack the boards a bit tighter and use them like cooling fins. I’m not sure if it would be helpful, or necessary, but when you are in the middle of a 13.5 hour drive, the mind tends to wonder 😉

  4. Great project as usual!

    Out of interest, why did you settle on using Eagle instead of KiCAD?

  5. Lukas,
    I am following your blog the last few years. I am wondering, what is you daytime job?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.