Modifying an EMCO Compact 5 CNC to control it via the open source software EMC on Linux

October 16, 2008

This webpage will explain how two people modified an EMCO Compact 5 CNC to control it with a PC running the open source software Enhanced Machine Controller (EMC) on Linux. We will describe exactly what changes we made to the EMCO, the custom interface we had to make to connect the PC to the EMCO and the software configuration used. We hope this will inspire other people who would like to do similar projects.

The project story

This project is the work of two friends: Jerry Spaulding and David Foster. They both took the Portland Adult Ed Machine Tool class in the fall of 2007; Jerry because he had plans to build his own 3-D CNC machine and David because he just likes those types of classes. The class was taught by Joseph Bolduc and they learned how to use milling machines and lathes, but only briefly mentioned CNC machines. Jerry asked Joe about two EMCO Compact 5 CNC machines that were sitting idle in the shop. Joe said they were donated several years ago, but never used because he didn't have the time or resources. (For those who don't know this machine, it was originally built in the early 1980's and used a tape control system and TV monitor, both of which greatly limit the usefulness of it today) Jerry asked if he could try to modify one of the EMCOs to control it by a PC. Joe said sure and thus the project was born. It was also during this time that David volunteered to help out. Neither Jerry or David have a background in machine tools, but they're both excellent programmers, have some experience with circuit design and love working on projects like this!

The first step was figuring out if this was possible. We found a webpage where someone had already done something remarkably similar, but it contained very little information describing the project. So we looked elsewhere and found the Yahoo Emco CNC Users group which has a wealth of information, manuals, files available. We obtained some great info there, including the indespensible maintenance manual. We also got a high resolution copy of the wiring diagram for the board interconnects which proved extremely useful. During our research we found that the majority of people who modified their EMCO Compact 5 CNC/PC machines had does it using commercially available controller boards and often replaced the stepper motors along with the controller board. That is one way to go, but being the cheap guys we are, we decided to try to do it ourselves.

The goal of the project is to control the stepper motors, which in turn control the X and Y axes of the cutting tool. The work piece is clamped into the main spindle, which is not controlled by the PC. Using the maintenance manual we were able to determine which boards we could get rid of and which boards we needed. We removed the extraneous boards and started trying to figure out what to do next. One thing that needed to be addressed was being able to turn the machine on. These EMCOs came with keylocks and without the key you can't turn it on. Unfortunately Joe did not have the keys for the machines, so we were forced to remove the keylock and connect all the keylock I/O as if it was always turned on. This too a bit to figure out, but we labeled the wired and connected them with wirenuts. Now the big red emergency-stop switch is used to turn the machine on and off. Of course if we had the key, we could have avoided this step.

Joe had obtained an old PC (1GHz) and I got an old 19" monitor. Jerry installed the EMC2 Live CD on the PC, which is just a custom version of Ubuntu Linux with EMC. This was our PC control setup. Jerry also created a breadboard interface that we could start using for testing.

The Interface Board

The initial breadboard we used was based on information Jerry had obtained from the owner of this webpage. Jerry created a custom parallel port interface to the breadboard (cutting off one end of a parallel cable and sticking the wires we wanted in the breadboard) and making another custom cable to connect it to the stepper controller board. It took us many weeks of debugging many different issues, but we finally got a board where we could control the stepper motors from EMC. Some of the issues we had to deal with along the way were accidentily blowing the stepper controller board (luckily we had a backup), metal shavings in the case causing blown fuses and other board issues, encoders that weren't aligned, figuring out the correct wiring for the stepper control signals, determining how limit switches would be integrated and lots of general circuit issues. A picture of the breadboard during this process is shown in one of the pictures below.

Once we had a working breadboard, the next step was to transfer that circuit to a PCB for more compactness and reliability. David had created and etched a few boards before using a homebrew method that worked pretty well. Long story short, it took several iterations of PCBs (and several weeks) before they finally got one that worked as required. The numerous boards were a factor of poor board design/etching, incorrect circuit and other things. In one case, all of the part connections on the board were a few percent too small because of using an intermediate PDF step to print the board masks and thus resulted in parts (like the DB-25 connector) that couldn't fit the board. It should also be noted that some parts of the circuit were re-designed slightly during this period to increase the functionality of the circuit. Two LEDs were also added for a visual check of PC and EMCO power.

Circuit Explaination

The circuit is basically just some optoisolators and inverters. The stepper motors we were controlling would be working in normal full step mode. Full step mode energizes two phases at any time according to the sequence AB->!AB->!A!B->A!B->repeat, where A/!A and B/!B are the pairs of control signals that control the two stators in a motor. Since the control sequence only ever has one signal of the pair "on" at a time, we can do something a little sneaky where EMC will just output the A and B control signals for a stepper motor and we'll create the inverse signals (!A and !B) in our interface circuit. Since we're controlling two stepper motors, EMC will actually output two pairs of control signals (AX/BX and AY/BY). These signals come from the PC and are routed to the input of an optoisolator via a small resistor. The purpose of the optoisolator is to electrically isolate the EMCO CNC from the PC. This can prevent damage from occuring in the PC if there are ever any problems with the EMCO. The output of the optoisolator is on the EMCO power domain. The signals are then routed to inverters and thus we now have both (AX/!AX, BX/!BX) and (AY/!AY, BY/!BY); these are the 8 control signals that the stepper controller board requires.

We've decided for the time being not to try to control the spindle motor via EMC due to complexity, but we did decide to feedback the spindle motor encoder signals to EMC so that it could use that information for threading and other operations. The Compact5 has two spindle encoders, located near the spindle belts on the side of the machine. One encoder generates a signal once per revolution. The other encoder has many slots in the encoder disk and will generate many more (I can't remember the exact number at the moment, but it would allow EMC more resolution of the spindle angle at any moment). These encoder signals are pretty weak, so we routed them thru some free inverters in the 7414 inverter chip to clean up the signal enough to drive the optoisolators. These optoisolators go in the reverse direction and the output of them are on the PC power domain where they are connected to some pull up resistors and the PC.

The other signals we're dealing with are limit switches. EMC can home the toolpost using the limit switches. We added connections for up to 6 limit switches (which will be multiplexed onto three PC inputs, two switches per input). This was a limitation on the number of inputs on the parallel port and in EMC to use. The plan is to attach 4 limit switches to the Compact5, two for the X limits and two for the Y limits. We did some preliminary tests with limit switches and they appear to work nicely. We took the easy route and kept the limit switches on the PC power domain, so we didn't need to deal with optoisolators. The limit switches connect to the three input lines via some pullup resistors. When the switches are activated, they will pull the inputs to ground.

A schematic of the circuit that was created with Eagle CAD is below, along with the layout of the PCB. The schematic, board and additional library for Eagle CAD are available below as well. A freeware version of Eagle CAD is available and was used to create this. Click on the schematic and board for larger images.

Parts List
25mm LEDPower indicators
2.1"x2 pinhead lock connectorencoder and CNC power connectors
2.1"x6 pinhead lock connectorstepper controller connectors
12x8 pinhead shroud connectorLimit switch connectors (4 free pins)
12.5mm power connectorAlt CNC power connector
27414N inverterInverting control and encoder signals
3dual optocouplerpassing control and encoder signals
1female 25-pin d-sub headerPC connection
4220 ohm resistorPC side control signal limiters
412k ohm resistorCNC side control signal pullups
510k ohn resistorPC side encoder and limit switch pullups
1390 ohm resistorPC side power LED limiter
1680 ohm resistorCNC side power LED limiter

Project pictures


I can be reached at