Staff MemberModeratorBuilder

Please bear with me, this is perhaps a bold undertaking and it will take me some time to complete the whole document. There are many aspects to be covered and I just don’t have the available time to do it all in one hit.

Wiring a CNC machine is basically extremely straightforward but there are a number of simple rules which, if followed, will almost certainly guarantee trouble-free machine operation. Get it wrong (for a stepper motor driven system) and lost or gained steps, even random EStop’s will often be the result.

Whilst there are always alternatives, this information is based on ‘tried and tested’ methods from my experience of building and operating CNC machines over the last 10 years or so and I will update the information presented here, as time permits, in order to cover most aspects of machine wiring. I will not be definitively detailing all the various aspects, this would take far too long – instead, it is up to the reader to do their own research (Google) on any points which are not immediately obvious or perhaps not completely understood.

1. Electrical Safety.

Our own personal safety is paramount and although the electrical regulations may seem a bit OTT they are there for good purpose and should always be followed. I would not enter a construction site without wearing a ‘hard hat’ and I would not operate machinery without the ‘safety guards’ being in place likewise I don’t take chances with electricity and I am still here to tell the tale.

The following typically relates to EU regulations - in other parts of the world the electrical regulations may differ so treat this as a guide…

By careful design – placing the mains operated PSU in a suitable metal enclosure which is in turn correctly bonded to Protective Earth and by using a Class II (double insulated) spindle motor the overall build will meet the Class oI standards and there should be no worries about the electrical safety of the machine.

If however a cheap, imported, variable frequency spindle is used (few comply with the Class II regulations) or the casing of the mains operated PSU is in electrical contact with the machine frame - this can change the overall equipment rating to Class I - then all metal or electrically conductive parts of a machine which an operator can touch (or could possibly touch) must be correctly bonded to Protective Earth. Please bear in mind that this is a legal requirement in industry – and for good reason.

2. PSU connections.

If using separate drives (one for each axis) the power connections (+ & -) must each be separately wired back to the PSU. Do not ‘daisy-chain’ the power connections.

3. Wire sizes.

Take the time to research the wire size required for the voltage and current each drive or stepper motor etc. will take then always select a suitable wire size for the job (one size up is always better than one size down).

4. Signal Ground (GND) and Protective Earth.

Signal GND and Protective Earth should always be treated as two entirely separate circuits.

Fit a ‘star type’ solder tag (connected to Protective Earth) at the controller location and connect all Earth wires, including the screens / shields of input signal wires to this one tag.

Avoid Earth loops as these make wonderful antennas for electrical noise.

Signal GND wires connect to their respective GND points on the controller.

5. Connecting wires to screw terminal blocks.

For many years the practice has been to solder tin the twisted wire end then bend the end back double, insert and secure within the screw terminal block. You will find that when using this method, 12 months down the line, the screws can always be tightened another ½ turn or so indicating a potentially unreliable connection.

It is no surprise that most manufacturers now use wire end ferrules (boot-lace) which are crimped to the wire end before inserting into the screw terminal. This involves a lot more effort and does require the use of a ‘crimping tool’ but the increased reliability of the connections will speak for themselves.

6. Electrical Noise.

Electrical noise is everywhere and it is almost, if not, impossible to eliminate.
What can be done is to negate it’s effect on the controller by always using screened / shielded cables for any inputs, such as limit / home / EStop switches and probe inputs etc. The screen / shield of these switches should be connected, at one end only, to the star Earth tag, mentioned earlier.

In extreme cases where false triggering of inputs still occurs there are a couple of additional things that can be done…
Increasing the ‘debounce interval’ in the motion control software usually does the trick but where this option is not available then fitting miniature 0.1uF capacitors, one connected between each used input and GND (at the controller / breakout board end) will almost certainly suppress most noise spikes and resolve the problem.

It should perhaps also be mentioned here that some switches (in particular the cheaper mechanical type) may have poor contacts which are susceptible to mechanical vibration – if tapping them gently (perhaps with a screwdriver handle) causes them to trigger then they should be replaced with higher quality switches.

VFD’s controlling HF spindles are perhaps the greatest single producers of electrical noise and the manufacturer’s wiring instructions should be heeded to the letter when they are installed. Again screened / shielded cable should be used between the VFD and the spindle motor. When using a VFD it is also good practice to incorporate an RFI filter in series with the incoming mains supply to the machine. These filters come in all shapes and sizes but this type is perhaps typical.

7. Stepper motors (and their drivers).

They come in various shapes and sizes with their physical dimensions defined, for the most part, by the NMEA specification and they usually come with either 4, 5, 6 or 8 connecting wires / terminals.

The four wire types are only suitable for connection to bipolar stepper drivers, five wire types are only suitable for connection to unipolar stepper drivers and the 6 & 8 wire types can be connected to either bipolar or unipolar stepper drivers.

Unfortunately there is no international standard for stepper motor wire colors so it is always prudent to check each motor with a multimeter (set to continuity) to identify the A, A and B, B pairs before connecting them to their drivers.

Reputable manufacturers always mark their product with a voltage and current rating. Whilst it is acceptable and is common practice to exceed the manufacturer’s marked voltage rating by up to 25 times - the marked current rating should never be exceeded.

In operation stepper motors should run warm but not so hot that you cannot touch them. There are exceptions, in extreme operating conditions, but as a general rule the outer casing should never be allowed to exceed 60 deg.C. This 60 deg.C rule also goes for the stepper motor driver – if it’s heatsink gets too hot to touch a cooling fan must be fitted. Basically, if a stepper motor is marked 2 Amps it should be operated at 2 Amps but if it gets too hot then reduce the driver’s current setting accordingly.

It is prudent to use as high a voltage as the stepper motor driver will allow in it’s specification. Within reason, the higher the voltage the greater the maximum speed the stepper can obtain and the higher the current setting the greater the stepper motor’s torque.

Stepper motors have their maximum torque when stationary – as rotational speed increases then torque decreases and this continues up to the point at which the motor stalls (ceases rotation and just sits there makes a whining sound).

Modern stepper motor drivers incorporating, just as an example the Toshiba or Allegro driver chips etc., use smart technology to reduce the current through the motor’s windings when stationary but if a rotational load is applied to the stationary motor’s shaft it is sensed by the chip (using a form of emf feedback) to increase the current in order to maintain it’s present position. This behaviour negates the problems that existed some years ago (back in the Stone Age) where full-step positional holding torque was greater than micro-step positional holding torque. This emf feedback is also used by the driver chip to sense the oncoming stall which can occur as a result of ‘mid-band resonance’ which, thankfully, is now almost a thing of the past as the chip adjusts it’s pulsing frequency to combat the impending stall. The modern driver chips really are smart and it always makes me smile when constructors build their own drivers using discrete components and H-bridge or similar circuits – the technology has moved on by miles since stepper motors were only operated in whole-step or half-step modes.

Most of the steppers we will use have 200 whole steps per revolution and this is then sub-divided by the controller chip into micro-steps. Unfortunately, micro-steps are not that accurate and a lot depends on the build quality of the particular motor with, just for example, those made by reputable manufacturer’s being many times more accurate than the unbranded, imported types. There is no advantage in using micro-steps greater than 1/8th or 1/10th – higher values will not produce any greater accuracy.

Again, back in the Stone Age when steppers were only operated in full step mode it was common practice to see two steppers both connected (in series or parallel) to one stepper driver circuit. Since the introduction of micro-step drivers this practice is no longer acceptable if you want the two motors to remain in sync. The driver chips do not have on-board memory to remember the last micro-step position at switch-off and at subsequent switch-on they assume the nearest full-step position. The two stepper motors (connected to the same driver) may not both rotate in the same direction to assume this nearest full-step position - if they drive the gantry it will soon become out of square and software homing routines (which are usually used to square the gantry) will not be able to fix the problem. So, if you want a square gantry it’s one stepper driver for each stepper motor.

A lot depends on the stepper motor, it’s associated driver and how it is set-up but stationary motors, when energised, may produce a low-level, high pitched, hum. Other than being annoying, especially to younger ears, it is not a fault it is just one of those things associated with stepper motors.

The wiring connection between the stepper motor and it’s controller does not need to be screened / shielded but if, like me, you have suitable shielded cable then it is always best to use it.

8. Limit and Home switches.

These switches can be mechanical, optical or electronic and each type have their own merits / shortfalls – I prefer to use good quality (Honeywell or similar) micro-switches but really it is just a matter of personal choice. When using mechanical switches it is prudent to use the ‘normally closed’ (N.C.) contacts which then go open circuit when the switch is activated. Many of the switches may then be connected in series, to a certain extent simplifying the wiring and by ‘daisy chaining’ switches reduces the number of Input #’s required.

Most machine control software’s incorporate a ‘homing routine’ whereby all axes can be referenced to a known position. This homing routine operates in a pre-define order, homing each axis in turn, using a switch (any switch) activation. As a bonus the same switch can be used as a Limit and as a Home.

With ‘Gantry’ type machines (for example, using the Y and A axes) it is necessary for each side of the gantry to have it’s own switch Input # in order that the machine’s control software can operate correctly and ‘square the gantry’ when the ‘homing routine’ is invoked. Although the E-Stop should, for safety reasons, always have it’s own dedicated Input # the other axes switches can all be connected in series to one Input #.

It should perhaps be noted here that the software polled E-Stop is not a totally safe system and it should always be remembered that the only safe ‘Emergency Stop’ instantly disconnects all power to all parts of the machine (including the spindle motor) and I will discuss the method by which I do this at a later time.

As mentioned earlier these Limit / Home switches are ‘inputs’ and as such should all be wired with screened / shielded cable. The screen / shield of these cables should only be connected at the controller end and to the single (star type) Earth tag.

The following diagram illustrates a typical way in which the Limit / Home switches can be inter-connected.

For those that would prefer to use the normally open contacts for the home / limit switches they would be connected in parallel and the following diagram is a typical arrangement of how they can be interconnected.

Avoid ‘daisy-chaining’ the connections between the screened / shielded cables or other components and Earth.
Each should have it’s own wire, connected to the single point Earth tag and this diagram Schematic2 depicts a typical wiring installation where screened / shielded cables have been used.
The home limit switch wiring (not shown in this particular diagram) have again been made with screened / shielded cables with their screens connected to the single point Earth tag in a similar manner.

When choosing screened / shielded cable it is preferable to use the type which has a ‘braided’ or ‘woven’ screen rather than the cheaper types which have a ‘foil’ screen.

9. Power supply.

In general, CNC machines perform better when using an unregulated power supply partly due to the rapid changes in current loading imposed by normal stepper motor operation and partly due to the back emf voltage created when stepper motors slow down rapidly. However, it makes life a whole lot easier to use a ready made, regulated, switch mode, power supply which are cheap to buy and readily available.

As a quick guide to deciding on the right PSU for a particular application the chosen stepper motor driver specification should be consulted first. It will specify the maximum voltage and current that the driver can handle (just for example 48 Volts @ 5 Amps) so we can decide on the PSU voltage – the higher the better if maximum stepper motor speed will be required.

Next consult the actual stepper motor’s specification (just for example 5 Volts @ 2.5 Amps). The stepper motor’s voltage rating can be exceeded, in most instances, by up to 25 times but the current rating must never be exceeded so count the number of stepper motors that will be used and add up all their rated currents (just for example 4 motors @ 2.5 Amps each = 10 Amps).

Now in reality stepper motors will never draw more than two thirds of their rated current so from the examples given above a 36 Volt or 48 Volt PSU rated at 10 Amps would be ideal for this theoretical application.

For those wishing to construct their own unregulated power supply the following diagram is typically what is required.

Start by calculating the total current required, decide on the desired voltage then choose a suitable transformer for the job (toroidal are best but probably the most expensive). The final DC voltage from the PSU will be 1.4 times the AC voltage output from the transformer.

The bridge rectifier and all the components / wiring chosen must be suitably rated for the current and voltage the PSU will provide.

The Capacitor value can be calculated from C = (80,000 x I ) / V where C = uF, I = Amps, V = Volts. The working voltage rating for the capacitor should be 25% higher than the output voltage of the PSU. It is also prudent to fit a bleed resistor across the terminals of the capacitor (to discharge it when the PSU is switched off) and a typical value could be 4k7 ohms ½ Watt.

10. Various notes on Transistor - Transistor - Logic levels (TTL).

i)Some elementary history…

When TTL was first introduced (before my time) there were just two logic levels.
Low or 0 volts or 0 (binary) and High or 5 volts or 1 (binary).

As time progressed, the introduction of shared bus communication between many devices led to a third logic state of Hi-Z (high impedance). This logic state is effectively an open circuit and TTL devices incorporating this are often termed Tri-state logic.

Again, the passage of time saw the introduction of portable devices with power saving features and this led to the introduction of the 3.3 volt TTL standard which, as far as we are concerned, now runs in the same race as the original 5 volt TTL standard.

So these are just some of the issues we have to contend with when interconnecting various devices and can explain why sometimes things just don’t work as expected.

ii)LPT Parallel Port …

As a result of the change in the TTL standard from 5 volts to 3.3 volts some (not all) breakout boards and machine controllers, particularly those of older design, may exhibit problems when operated via a PC’s LPT parallel port if it’s output is to the 3.3 volt standard. Whilst 3.3 volt TTL equipment is, in the main, happy to be driven by 5 volt TTL the same is not always true in reverse.

If adding a new or additional LPT parallel port card (PCI, AGP, PCMCIA, etc.) to an existing PC it would be wise to choose a parallel port card which has the 5 volt TTL standard outputs. This then covers every eventuality of driving both new and old equipment without the potential of encountering TTL voltage level drive problems.

iii)Active High / Active Low …

The terms ‘Active High’ and ‘Active Low’ relate to TTL logic levels…

When a TTL signal, which is normally at a logic level of 5 (or 3.3) volts, is activated and changes to 0 volts this is termed Active Low.

When a TTL signal, which is normally at a logic level of 0 volts, is activated and changes to 5 (or 3.3) volts then this is termed Active High.

As a general rule TTL devices can sink more current than they can source and as a result it is better, when there is a choice, to switch things with an ‘Active Low’ signal.

iv)Pull-Up resistors and Input signals.

Some breakout boards, machine controllers and even individual stepper motor drivers incorporate ‘pull-up’ resistors on their inputs. This means that the input is normally held High (5 or 3.3 volts) and therefore is intended to be operated by an Active Low signal (which then takes the input to 0 volts when activated). It is good practice to always study the manufacturer’s data to understand the type and levels of signals required for their correct operation.

Now this circuit would probably work in most, if not all instances, without the 74LS00 TTL chip. However, the actual make and model of the equipment to which the controller has been designed to interface is unknown to me.

Because, amongst other things, I don’t know if the incoming PWM signal is going to be a good quality square wave or if it will have an amplitude of 5 volts or 3.3 volts and because I don’t know if the ESC can handle the tri-state logic of the microprocessor the 74LS00 chip has been incorporated in order to cater for all input / output eventualities.

11. Software control of mains operated spindle motors / routers.

Many 3 / 4 axis control boards (as well as some breakout boards) incorporate a relay for switching a spindle motor on / off under software control and the Gcode commands M03 (on) and M05 (off) are intended just for this purpose.

However, it is potentially unsafe if not extremely dangerous to connect mains voltage directly to the relay connections on these boards and in addition the switching action will create electrical noise which will almost certainly lead to lost / gained steps in the motion drive system.

A suitable solution is to use an additional Solid-State Relay (SSR). These components are readily available, cheap to buy and switch the spindle / router load at the zero-crossing point of the a.c. mains waveform thereby negating any electrical noise issues. For safety reasons the SSR should be housed in a suitable enclosure to provide protection to the machine operator from the mains voltage present on the output terminals and connections etc.

​

There are various options for the SSR connexion and the following diagram illustrates the easiest and my preferred method. Current consumption of the SSR’s inbuilt opto-isolator is around 5mA @ 5 volts which is well within the 10mA recommended max. available from a standard parallel port.

Any spare Output pin from the parallel port can be used to drive the SSR and this should be configured, in the motion control software, as the Spindle and set as Active High.

​

As an alternative connexion, which makes use of the controller’s onboard relay, the following diagram refers.