Motion Control

Motion control. The main function in any CNC based machine. For almost all CNC machines the feed rate is given by the G-code and is usually fixed during a cutting or milling operation. For EDM machines, this is a very different story.


The feed rate in EDM machines is determined by the cutting process itself and is not fixed. The feed rate therefore depends on material thickness, material type, flushing conditions, dielectric used, the profile of the arc current (frequency, duty cycle, current) etc etc… It is safe to say that the feed rate is pretty much unknown. So how do you determine the required feed rate?

A too high feed rate will close the gap between the EDM wire and the work piece and will lead to a short condition. If the feed rate is too low you can EDM, however you’ll waste a lot of time and cutting is far from optimal. Next to that, the properties of the cut will be uncertain.

What is key is that the width of the gap needs to be kept constant during cutting. The width of the gap cannot be measured directly, however the voltage across the gap when current is flowing through the arc is proportional to the gap width, so by measuring the voltage you get a good indication about the gap width.

So how to measure the voltage? What most DIY designs do is that the voltage across the gap is measured and passed through a low-pass RC filter. The output of this filter is then used in a control loop to control the gap width. This does however introduce a problem.

The EDM process strongly requires that the arc parameters (frequency, current, duty-cycle) are adjustable, since each material, thickness and desired finish requires a different arc parameter set.

Now let’s do a thought experiment to explain the problem. Let say for instance that you managed to find an arc parameter set that cuts like a dream through your work piece. You have tuned your gap width control loop and everything runs just like you want it to. The parameter set you are using is 15A, 50KHz, 30% DC. For this parameter set the RC filter output gives an unique analog voltage for the perfect gap width. The control loop is tuned to maintain this voltage and if done correctly the control loop will keep the correct gap distance by adjusting the feed rate during cutting.

Now, a new work piece is started, the finish is less relevant and it is a thick piece that you just want to cut as fast as possible. In order to do so, you increase the current and duty cycle. The perfect gap width will still give almost the same gap voltage, however the duty cycle has now changed. Because an RC filter is used to get the analog control voltage, the voltage readout will be very different for the same gap width. The control loop is tuned for the voltage of the other work piece so now the control loop realises a gap width that is way off.

The problem is that varying the process parameter duty cycle greatly affects the analog voltage that represents the gap width.

It is possible to make the analog gap width voltage less dependent on the process parameter duty cycle. This can be done by sampling the voltage at the correct moment in time and holding that voltage until the next cycle. The design of the power supply of this EDM machine incorporates that.


Once an analog voltage that represents the gap width is available, a control loop can be made if the motion control platform has an option to set the feed rate dynamically during execution of the G-code. Some designs do not set the feed continuously, but in a discontinuous manner (hold-go). In my opinion, that is a rather crude control method and the gap width error will keep fluctuating wildly without converging. That is an approach that will definitely translate negatively into the finish of your work piece.

What will work a lot better is letting the control loop set the feed rate from 0%….100% continuously. However, the control loop will have to deal with a wildly fluctuating control voltage so control overshoot is likely to occur. If overshoot occurs and you can only set the feed rate magnitude and not direction the loop will have to wait until enough material has eroded away before the error can be corrected. If the overshoot causes a short, no material will be cut and the control will freeze (likely breaking the wire). That is not an optimal solution.

If however the motion control platform supports dynamic feed rate adjusting from -100%….100% (so it can also back up) the control loop can continuously “work” to keep the gap distance error as small as possible, which is the best solution.

The possibility for reverse movement in G-code execution is however a very peculiar requirement which is not supported by most motion controllers. I performed a long search for an existing control solution that meets this requirement and found only one. The KMotion solution of the American company Dynomotion.

I already use their platform in my CNC mill so I know how to use it. It is very flexible and allows you to add your own C code for custom control. Once I discovered that this platform supports setting the feed rate dynamically including direction, the choice to use this platform was a no-brainer.

Of course, it is possible to make your own CNC motion controller. I would start by modifying an open source G-code interpreter like GBRL by adding a motion buffer that can reverse the motion and change the feed rate on the fly. This is quite some effort, so I decided to go for KMotion which is quite affordable compared to the amount of effort I would have to do to make my own controller.

I’ve build my motion control electronics in a repurposed electrical cabinet, salvaged from the scrap yard and repainted:

The Dynomotion control solution sits at the bottom. The USB entry is a Olimex USB isolator to prevent an earth loop with the control PC which could potentially create problems. I 3d

printed a small isolation bracket to mount the olimex PCB to the cabinet and to keep it from making electrical contact. Remaining holes and/or openings in the cabinet are closed by copper EMI tape.

The Dynomotion card power comes from a custom 5v 3A linear power source. Usually a standard PC power supply is used. Those supplies are however switched and usually quite noisy. Since I’m making analog measurements with the card I prefer to have a noise free linear supply. So I decided to make my own. The additional heat and power usage are not relevant.


More info and pictures will follow….