Tag Archives: cnc

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:

Dividing Head Controller

This post ist about the CNC conversion of a manual dividing head aka indexing head. If you’re not familiar with that kind of equipment, there’s a wiki page here.  One makes use of interchangeable indexing plates and and the internal worm gear to accurately divide the circle. Parts like cogwheels and the like can be machined this way. A video of the finished project can be found here on my youtube cannel.

The downside is that a high level of concentration is required to not mess things up. Often a single distraction is all it takes to ruin a part. Besides the fact that constantly changing indexing plates can get tedious. So I decided to mount a stepper motor to that indexing head and to design a controller to take care of that motor.

There are many affordable and well-designed stepper motor drivers out there so I decided to use one of those rather than building my own. So an external driver takes care of translating the 5 volts logic step / direction signals into the (typically 12, 24 or 48V) power signals required to drive the stepper motor. What this circuit does is to provide a user interface and to generate that step / direction signal.

I decided to use this motor driver from Planet CNC that comes with a 2×5 pins 100-mil header for the logic signals. So I also put such a connector with a corresponding pin-out on my board. Then a single ribbon cable (provided with the motor driver) is all it takes to hook up the driver.

The user interface consists of a 4×20 character LCD display and two rotary encoders with push buttons. The display is a Midas MCCOG42005A6W that I have used in several of my other projects before. It is very compact and comes with an I2C interface which saves quite a few pins on the microcontroller. There is also a buzzer to provide some acoustic feedback on button presses and the like. If it enoys you, you can always turn it off in software.

As in all my designs, the rotary encoder signals are nicely debounced in hardware as described here.

The board runs on a 24V supply that is also used to drive the motor. The microcontroller, a Microchip PIC1826J50, runs on 3.3 volts. Furthermore, the motor controller requires a separate 5V supply to power its logic. So I first designed a switching converter that generates a 5V output from any input voltage in the range of 6 to 30 volts. A linear regulator then produces 3.3 volts out of that 5V rail to power the PIC and other on-board logic. Unfortunately, a bug as creeped into my PCB layout – hence that fix with a piece of wire just below the coil.

With the PIC running on 3.3 volts and the motor driver at 5 volts, I also had to provide some logic-level conversion.  A 74AHCT125 line driver / buffer and a few resistors take care of that.

The PIC also comes with a USB interface so that the board could be controlled remotely from a PC. All the hardware for that is present on the board but I haven’t written any software for that yet. Most of that can be copy-pasted from other projects such as the solar charger but I simply haven’t done any of that yet.

Finally, there is a temperature sensor and a fan output on the board. I’m not currently using it but if there is need for a fan for the motor driver and/or the power supply, you can connect a fan directly to this board and have it temperature controlled. For the fan output, the buzzer and the display backlight are driven by a TPL7407L that already includes the free-wheeling diodes necessary to drive inductive loads such as a fan.

I’ve mounted all the power supply, the motor driver as well as this board in a nice, compact case that I bought at a flea market earlier this year.

Nice, solid ground connections are provided to all relevant components. The USB connector is accessible from the back through an extension cable.

The other USB connector belongs to the motor driver and is used for configuration.

Finally, the two knobs for the rotary encoders were turned out of aluminum at the lathe.

The rest of it is mainly mechanics. This may seem somewhat off-topic on this blog but expect to see more of it in the future 😉

Here are the parts required for the mechanical part of the CNC conversion. With the exception of the two cog wheels for the timing belt, they are all machined out of aluminum on a manual mill.

First, a spacer is mounted using three existing, M5 threaded holes.

The main body is then screwed onto this spacer and the cogwheel is mounted.

The hub of the cogwheel was turned out of steel and then press fitted to the aluminum cogwheel. This provides for a firm, true-running.

Then the motor with the 22 tooth sprocket can then be mounted together with the 15mm HTD-5M timing belt. Together with the 44 teeth cogwheel on the other end, this provides a 2:1 geering. The dividing head’s internal worm drive adds another factor of 90:1.

Since the motor, a Sanyo Denki 103 H7823 1740, has a resolution of 200 steps per revolution, this translates to a very convenient 0.01 degrees per full step.

Now all that is left to do is to fix the cover plate. As usual, all the relevant files are on github:

Arduino Ultrasonic Anemometer Part 6: Mechanical design

If you’ve read through my previous posts of this series you know that here is an Arduino and two home-made PCBs together with 4 transducers waiting to work together as an ultrasonic wind meter. If you haven’t you may click here for an overview of posts on my anemometer project: https://soldernerd.com/arduino-ultrasonic-anemometer/https://soldernerd.com/2014/11/19/arduino-ultrasonic-anemometer-part-6-mechanical-design/

Milling the base plate.

For this wind meter to work, the four transducers need to be held in place somehow. Even during testing and development I wanted some reliable mechanical setup so that I don’t need to worry about it all the time. For this prototype I don’t need anything waterproof that I can put outside for a prolonged period of time. Anyway it will be sitting on my bench most of the time so wood works just fine for me.

Here two videos of the CNC milling machine at work:

The transducers are 16mm in diameter. 16mm plastic pipes are readily available from hardware stores. They are intended for electrical wiring so you also get matching angles and the like. So I got myself 8 90-degree angles and a 2m pipe from a local hardware store. I think I’ve mentioned before that I want the transducers to sit in a 20cm distance so make the wind meter rather compact.

More CNC milling.

I’ve just recently attended a CNC machining course at the Zurich Fab Lab (http://zurich.fablab.ch/) so I decided to do my first CNC milling project and use my newly aquired knowledge to make a wooden base to hold the plastic tubes (and PCBs) in place.

Mounting the PCBs. Still using my Arduino Mega here.

I’ve used some left over 18mm melamine-coated multiplex. It’s extremely sturdy and has a nice smooth surface. I ran my first tests with a Arduino Mega so that’s what you see above but I’ve replaced that with a Uno by now. So all the software development will take place on an Arduino Uno and its Atmega328.

My prototype sitting on the bench

Besides the two boards you already know, there is a 2×16 characters LCD. I thought it would be nice to have a display connected to the Arduino when writing the software. Just to see what you’re doing. An easy way to drop some debugging output and of course display the measurements once we are ready to actually run this thing.

View from above

There is a little PCB attached to the LCD display. It mainly holds a trimmer to adjust the contrast as well as a resistor for the backlight LED. Since I had to make a board anyway I also included a 10uF plus 100nF ceramic capacitor as well as a protection diode.

Lots of wires to connect everything

As you can see from the photos above, there are definitely more and longer wires than necessary. But for a prototype I’m always reluctant to soldering things and cutting wires to their minimal or optimal length. I like to be able to just unplug a board and do some changes to it.

When I started writing my software I didn’t have a clue which signal will be on which pin. I just plugged them in as I went along. And I changed it several times until I was finally happy with it. So I do need some flexibility. But it also makes the setup a bit of a mess I must admit.

Ok, the hardware is working now. Time to write some software and see if we get it all up and running. See you next time.

Click here: https://soldernerd.com/2014/11/21/arduino-ultrasonic-anemometer-part-7-basic-software/