PNC-300 CNC mill retrofit - spindle motor noise issues

While cutting a death star model for my son, I noticed that the z axis would occasionally lose or gain steps while the machine is in operation.

After trying a few things, I finally turned on the spindle without moving the axes, and was able to see that the add-on stm32f4-discovery board did count the missed steps. Sometimes even the x and y axes would we affected.

A look at the coordinates on the front panel of the machine did not, however, show any such missed steps.

(the coordinates are way off because of homing, and the fact that they come from two different runs)

That conveniently limits the source of the noise to the flat ribbon cable that takes the step instructions from the stepper motor drivers.

Since this only occurs with the spindle running, the universal motor in the spindle is the likely culprit. Lets have a look at the z axis with the system on and homed, but the spindle off:

We will measure right at the board input:

This is the result:

More noise than I like, especially considering, that I put a lot of filtering right at the back of that board to avoid this. But for a 5V system, it should not be a problem.

Now what this looks like when I turn on the spindle:

Wow. It is actually surprising how little the axis jumps around considering how much noise there is...

The first thing I tried to do is to add capacitance right by the input of the universal motor. I put 3 0.1 uF tantalum capacitors right at the connector of the motor like this:

With no noticeable effect...

Well, I do have a Schaffner noise filter on hand, so lets try that out.

That does actually look better. On a different scale:

1.9V maximum noise. The signal is a 5V signal, so this is still quite marginal, but there are no more lost or gained steps over a few minutes of trial operation....

The Schaffner filter is right by the motor, which is very inconvenient from a mounting point of view, so I am going to move it closer to the circuit board, inside of the cabinet.

Doing that, the noise did get worse, but was still better than with no filter. I may just switch the motor to a BLDC type, if this is still not enough.

So the signal in operation looks like this:

which seems adequate. To check, I ran a model on the machine which included a nice variety of fast and slow moves.

The cutting of the model took about 3 hours.

A comparison of the x,y and z counts on the STM32 board when the machine homes back shows no lost counts. Looks like the filter works out.

Update: After about 500,000 lines of movement instructions, not a single noticeable missed step.