What’s worked and what’s not about using an AC servo motor (DMM Tech DYN4) on a LinuxCNC CNC retrofitted Precision Matthews PM-25MV milling machine. Many of these questions came from viewers and I hope this summary video will help the next person. I’ve tried to be very factual but mistakes are likely about the cause for problems that I didn’t fully solve. Next video will describe the LinuxCNC DYN4 serial interface.

Table of contents

  • 00:00 Introduction
  • 00:32 What are the advantages of the stock BLDC motor?
  • 00:44 Why upgrade the BLDC motor?
  • 01:22 Why not just replace the original drive?
  • 01:40 Why a servo motor? Why not a VFD driven induction motor?
  • 02:20 Why not a servo motor?
  • 03:03 What’s the simplest way to interface the servo motor?
  • 04:24 Is there a more featureful way to interface the servo motor?
  • 06:05 How about torque control mode?
  • 06:28 Why not use the stock v-belt? Aren’t timing belts noisy?
  • 08:03 Why use the motor’s encoder? Isn’t a spindle mounted encoder better?
  • 11:21 Could I have made a more complicated setup?
  • 13:12 Why not use a larger power servo than the original 750W BLDC?
  • 15:02 Why select a servo with a brake? Doesn’t the brake harm performance?
  • 16:09 Is there electrical noise from the servo drive?
  • 18:20 Should the high-voltage electronics be installed into their own enclosure?
  • 19:06 Could the DYN4 serial interface be used?
  • 20:05 Has surface finish improved?
  • 22:59 Are the electronics for a CNC retrofit expensive?
  • 23:39 Does the motor run hot?
  • 24:37 Why has this video taken so long to complete?
  • 25:19 Are the LinuxCNC configuration files available?
  • 25:29 Would I do this all again?
  • 26:10 Thank you

Other links

 

Notes and transcript

Today I’ll share with you my experience of replacing the stock BLDC motor on a Precision Matthews PM25 milling machine with a servo motor from Dynamic Motor Motion. I’ll describe what worked well and what didn’t, in a question-answer format.

I must acknowledge Stephan and Michael at DMM. They answered what had to seem like an endless stream of questions. Also, Jon Elson at Pico Systems for support with the Universal Stepper Motor Controller.

 

What are the advantages of the stock BLDC motor?

  • It’s simple. It works. If you are satisfied, there’s no need to replace it.
  • The drive is repairable, with the exception of the microcontroller’s code.

 

Why upgrade the BLDC motor?

  • I wanted better performance, especially at low speeds for tapping and drilling. The speed of the BLDC sags under load, and overruns when clear. Neither are ideal for maintaining a constant chip load.
  • I wanted diagnostics, including speed and torque.
  • I wanted higher speeds, without compromising torque.
  • I wanted a more reliable detection of a spindle fault. The original BLDC drive has a fault indicator LED, but it lights too long after the actual fault occurs to be useful.
  • I wanted an easily replaced and documented motor and drive.

 

Why not replace the original drive?

  • Replacing the stock BLDC drive could satisfy some of the goals. I tried this, using an Anaheim Automation drive, which is expensive, and the results were terrible. I have posted a video detailing that experience.

 

Why a servo motor? Why not a VFD driven induction motor?

  • Servo motors tend to have higher power density than induction motors. The PM25 is a small mill and I didn’t want to add significant weight to the head.
  • Servos use permanent magnets while induction motors use coils. This allows the stator of a servo motor to be lighter and more responsive than the induction motor.
  • Servo motors deliver full torque at start, though induction motors may as well with high performance VFDs.
  • Servo motors have built-in encoders and their drives often can passthrough the encoder to the controller, possibly eliminating the need for an external encoder.

 

Why not a servo motor?

  • Servo motors may be the most expensive solution.
  • Servo motors need to be tuned. They compare a measurement to a target and pass the difference to a control loop formula to adjust some aspect of the motor, particularly torque current. The control loop formula has a small number of parameters, gain settings, that must be adjusted for the system to perform well. Sometimes autotuning is an option. If the load changes significantly, it’s possible that retuning will be required. In a milling application, turning a tool in the air is a different load than heavy interrupted cuts.

 

What’s the simplest way to interface the servo motor?

  • The DYN4 has three control modes: position, velocity, and torque. A control mode selects what is measured to calculate servo loop error.
  • Velocity control mode is the easiest to interface. Many motor drives, BLDC, induction, servo, will have provisions for varying speed proportional to an analog signal. The original BLDC drive used a 0-5v signal to control speed and a separate signal to control direction. The DYN4 uses a +/-10v signal to control speed and direction.
  • In LinuxCNC, the analog signal can be tuned with a lookup table of voltage and measured speed. Linear interpolation is then used to calculate the voltage for any speed.
  • Despite attempts at tuning the DYN4, the torque response at low speeds was worse than with the BLDC. I could stall the spindle using my hands at speeds below a few hundred RPMs. With more aggressive gain settings the motor sounded bad.
  • Your luck may be better. And if you only want to swing a tool with good performance, a servo motor and velocity mode with an analog input should be ideal.

 

Is there a more featureful way to interface the servo motor?

  • Position mode gives great performance at low and high speeds.
  • With some programming, position mode enables orienting the spindle for clocking tools for consistent runout or aligning with the spindle lock for manual tool changes.
  • Position mode is commanded by sending pulses to the drive, like a stepper motor drive. In LinuxCNC, the pulses are generated using a HAL stepgen component which may be implemented in software or in hardware such as with the Pico Systems USC. One of the stepgen parameters is commanded velocity.
  • On the DYN4, two I/O pins receive these signals and can be configure for step-direction pulses or A/B phase pulses. The Pico Systems USC couldn’t generate sufficiently fast step-direction pulses to drive the DYN4 to higher RPMs with high PPR electronic gearing. Switching to A/B phase, requiring a change to the DYN4 configuration and a dip switch change on the USC, solved the pulse bandwidth problem.
  • The USC has four step generators, but they all share the same parameters. The slowest drives set the limits, which in this case, the Leadshine drives on the XYZ axes have longer pulse minimums than the DYN4. Regardless, with an electronic gearing of 512, at 5500RPM, the minimum pulse frequency is about 50kHz or a pulse width of 20 ms so doable within the required longest 10 ms pulse width of the Leadshine drives.

 

How about torque control mode?

  • I didn’t try torque control mode, only velocity and position control modes. Torque control mode is interesting because it means that much of the servo control loop is directed by LinuxCNC. This may only useful if experimenting with control loops.

 

Why not use the stock v-belt? Aren’t timing belts noisy?

  • A v-belt runs uninterrupted in grooves and will have little slip if properly tensioned with large pulleys.
  • A timing belt has teeth assuring synchronicity, but the periodic engagement of the teeth creates noise.
  • The sound of the servo and timing belt are different and I don’t feel that the noise of the timing belt significant. Securing the drawbar helped reduce the complexity of the sound more than the belt choice.
  • While not a direct comparison, sound levels between the BLDC with a v-belt and the DMM servo with a timing belt are:
    1. At 500 RPM, both are 62+/-1dB without a fan and 65dB with a fan.
    2. At 2500 RPM, both are 79+/-1dB (fan made no difference.)
    3. For completeness, the servo at 4700RPM is 86dB
  • Regardless, a pulley cover attenuates much of the noise and should be installed to protect your fingers.
  • The additional noise implies vibrations. Are vibrations transmitted to the tool? There are greater sources of vibration in my setup than the choice of belt.
  • The timing belt provides significant functional advantages and any disadvantage seem minor and academic. Choose what you prefer, can get, and can afford. All being equal, go with the timing belt.

 

Why use the motor’s encoder? Isn’t a spindle mounted encoder better?

  • An encoder measures the rotational position of the spindle and is needed for rigid tapping which requires synchronizing the z-axis with the spindle. Any error and the threads are misformed or the tap breaks.
  • Encoder passthrough from the drive is available regardless of the control mode. Both the pulses per revolution and encoder passthrough have configurable scaling factors. I configured 512 pulses per revolution so native encoder count is dividable without a remainder. Though I’m not sure this is important.
  • A spindle mounted encoder is ideal because the spindle is rigidly attached to the tool. However, a spindle mounted encoder is a pain when it interferes with changing tools.
  • A servo motor already has an encoder and some drives pass the encoder signals through, perhaps as virtual encoder, like with the DYN4, after performing a configured scaling.
  • Error between spindle and motor mounted encoders are most likely because of belt elongation.
  • A Gates engineer estimated maximum elongation of the belt that I selected to be 0.009” over the span between the pulleys and this does not change with age. Roughly 0.14% elongation and proportional rotational error of the tap in the worst case. Is this significant?
  • There are greater sources of error in my setup. The encoder signal integrity from the drive being the largest. The noise level on the DYN4 encoder passthrough is terrible. I made an opto-isolator board to clean this up.
  • The USC can sample encoders up to 1MHz and the H11L1 opto-couplers have 1MHz non-return-to-zero bandwidth. The poor encoder passthrough seems to be because of noise from the IGBT switching. The DYN4 block diagram shows a lot of isolation but there is strong 20kHz noise on the logic ground, encoder lines, and unfortunately it reaches the pulse lines.
  • I somewhat trust the passthrough signals at low speeds, but at high speeds the exact position is quickly lost. But who rigid taps at 5000RPM?
  • Rigid tapping is a cool demonstration of synchronization. However, for my small operation thread milling is generally better than rigid tapping. Thread mills are much more expensive and slower than taps, but the range of threads that can be cut by a thread mill is infinite including configurations impossible do cut with a tap.

 

Could I have made a more complicated setup?

  • Oh yes, I did.
  • I thought it would be clever to drive the LinuxCNC stepgen to the DYN4 with a PID control loop. The control loops takes the commanded velocity and the velocity measured from encoder passthrough. Then, LinuxCNC PID loop adjusts the pulse frequency as needed to get the DYN4 to the commanded speed.
  • This did not work initially because of a bug in LinuxCNC. When the enable line shared by the PID loop, encoder, stepgen, and drive, was toggled, the LinuxCNC encoder reset to zero causing a huge step change in velocity, which the PID control loop franticly responded to, resulting in a DYN4 Lost Phase fault. To workaround this, I created a realtime HAL component to filter the discontinuity.
  • This complicated strategy works if the encoder signals are solid. At high speeds, the USC misses about 10% of the encoder pulses from the DYN4. Then LinuxCNC thinks the motor is running 10% slow, and commands DYN4 to run 10% faster than it should be.
  • Add a little more noise to the encoder signals and LinuxCNC counters step change like noise with its own very fast response, all goes nuts, and the DYN4 throws a Lost Phase fault. And there is no way to reset the fault without power cycling the drive.
  • In the end, this was a time vampire. If the servo drive works well, it should run at the commanded speed without an additional control loop. No need for the extra complication.

 

Why not use a larger power servo than the original 750W BLDC?

  • I wanted to compare BLDC and servo motors of the same power. I hear that servos are superior, but I’m suspicious of that statement when not backed up by experience with both.
  • I wanted a setup that I could use on the same 120V 15A circuit. However, the DYN4 on 120V is only rated to 3000RPM. So, I installed a 240V 15A circuit to reach 5000RPM. With the new service, starting over, I would have more options to consider.
  • Someone suggested and DMM confirmed that there is a special order 1kW motor that is the same size as the 750W servo, for roughly twice the cost, and both use the same DYN4 drive. So, there is a simple upgrade path for a 30% boost in power, in exchange for a stack of greenbacks.
  • Based on power meter measurements, I suspect that the original BLDC motor is closer to a 1kW motor even if it’s only capable of that in bursts. Metal removal rate is proportional to power, so there’s a chance the 750W servo is a step backwards when crudely compared to the original BLDC delivering its highest power. But the servo performs better over a larger range of speeds.
  • If selecting a servo today, I would choose a larger servo, at least 1kW. I had a power meter on the BLDC drive and I would see measurements of 1kW when drilling or facing. Based on drilling tests, the DYN4 has little over-the-limit tolerance and throws a Lost Phase or Over Heat fault near 750W. That’s pretty annoying.

 

Why select a servo with a brake? Doesn’t the brake harm performance?

  • I imagined the brake holding the spindle when changing tools. In reality, the brake is only capable of stopping and holding the motor that it’s sized to and a brake sized for a 750W motor is pretty small compared to the torque of a long wrench.
  • With the brake, the inertia ratio between the servo motor and the PM25 spindle with a representative tool mounted is roughly 2.5:1 and well within the 10:1 that DMM recommends and 20:1 maximum.
  • The brake is expensive, is a pain to wire properly, it takes up a lot of space, and there is no right-angle connector.
  • The brake may still be useful for broaching, which I’ve never done on the mill, and for emergency stops. Keep in the mind that in position mode, the control loop holds position when the drive is enabled and an emergency stop could be performed by shorting the motor coils, though the DYN4 doesn’t seem to have an emergency stop mode.
  • Would I order a brake for a spindle application again? Probably not. Would I order a brake for a Z-axis motor? Absolutely.

 

Is there electrical noise from the servo drive?

  • Oh yes. The servo drive has a switching frequency of 20kHz. The output is potentially full current square wave signals. There is great potential for noise.
  • I redid the CNC electrical, moving it into a cabinet for safety and to create a solid ground plane.
  • I tried ferrite cores. Using an oscilloscope with differential probes, and a spectrum analyzer with a short antenna. I could see little difference with the cores.
  • There were frequent false faults when starting the motor. Turned out to be noise on the alarm line. Adding a debounce HAL component helped, but this is a software fix that reduces the probability of a false fault while also increasing the response time to a real fault by 100ms.
  • The VistaCNC iMach3 P4-SE pendant is very sensitive to the smallest amount of noise. I’m reminded how much I use the pendant every time it stops working and the DYN4 would kill it fast. The electrical estop is a strong vector for electrical noise into the pendant. I removed the pendant from the electrical estop loop, and attached it into a USB hub outside of the cabinet. The extended emergency e-stop is a great idea, but it costs additional $48, and the nuisance e-stop trips are annoying. After a few of those one starts looking for a way to bypass the extended e-stop anyway. Looking at the connector and inside of the extended emergency stop box, my suspicion is the lines carrying the e-stop current are not shielded from the USB signals, and maybe there is no shielding at all.
  • The DYN4 has mystery Over Heat faults. After installing a line reactor and recommended filtering, the input AC line waveform is slightly distorted when the drive is operating but there are never spikes outside of 240VRMS +/-10% specification.
  • Finally, be sure to ground the motor and the mill. First, this should be done for safety but also to potentially reduce wear on bearings due to induced currents passing through the bearings.

 

Should the high-voltage electronics be installed into their own enclosure?

  • Might be nice.
  • I first installed the electronics on the wall because I didn’t have a plan, I wanted to easily make changes, and keep costs down. Now, I’ve made an electrical cabinet from wood and a piece of sheet metal for the ground plane.
  • I couldn’t find enclosures that were large enough that were not overly expensive. Two smaller enclosures might have multiple advantages over one large cabinet.
  • The isolation might help with electrical noise. The fiberglass cabinets are easy to work with, but I like the idea of EMI isolation of the metal cabinets. Let me know if you have suggestions.

 

Could the DYN4 serial interface be used?

  • The serial interface may be preferred over all the other methods for controlling a spindle motor. The low baud rate and error checking should make serial communication pretty tolerant to noise. Commands are sent to the drive and the drive is trusted to execute them. Trust but verify.
  • I created a Python module to communicate with the DYN4. The code is available on GitHub. I have a DYN4 with older firmware but I implemented all the reads and the write commands that I needed.
  • I used the module to create a userspace LinuxCNC HAL component to command the drive. LinuxCNC prefers realtime control, which places constraints on programming. But with userspace components one has more flexibility including using Python and modules like PySerial.
  • There is a realtime serial component but this requires a hardware serial port. USB may not be practical to control with realtime constraints.

 

Has surface finish improved?

  • The first improvements were seen while still using the 3d printed motor mounts and milling the aluminum mounts. There were sides that were completely smooth while the BLDC motor left a pattern, roughly five tenths deep, best description is that pattern looked like the tool was rocking. At certain speeds, servo motor created a smooth cut, but not all. This improvement most likely is due to maintaining a speed that minimizes the problems of a splined spindle.
  • The PM25 spindle has two sections that are splined together. The motor power is delivered to the upper half via a pulley and then to the bottom half through a spline. The spline allows the bottom half to move on a rack and pinion implementing a drill-press like spindle, but the freedom reduces rigidity.
  • When I converted this mill, I eliminated the drill press action. Then later, to reduce the play, I created metal-to-metal contact between the bottom-half and the head. The screws at top of the bottom-half where changed to low profile ones and the rubber cushion between the bottom half and the head, used to absorb the spring return of the manual spindle, was eliminated.
  • The metal-to-metal contact stiffened the bottom half but the spindle still had 3 thou of play depending on the orientation of the cutting force to the spindle. The spline has six teeth and so different amounts of play appear as forces align with opposing teeth. To reduce the play, I added an interference fitted piece at the top of the top half of the spindle which has set screws to adjust out spindle runout measured at the spindle nose. Six set screws would be easier to adjust than four. Besides eliminating the play, securing the splined shaft reduced rattling noise.
  • The earliest example I found of this improvement is from Hoss who 3D printed a part which mates with the spline. Think of the shaft is a lever acting on the nose of the spindle. The setscrew method seems an improvement because it’s possible to control runout while a wedge might make it worse.
  • After removing the remaining parts of the drill-press like action, including the spring and top hat spring cup, the bottom spindle cartridge is held in place by a single screw pushing on the side of the spindle cartridge. If that screw loosened, the bottom half drops. To fix this problem, put the spindle in tension by adding a custom nut to the top of the spindle.

 

Are the electronics for a CNC retrofit expensive?

  •  
  • Increasing the expense is that details about each component are often incomplete or inaccurate. So, engineering a system without tinkering seems unlikely. Then, as we’ve seen, either incompatible components need to be replaced or workarounds must be created.
  • Maybe that’s the purpose of reports like this video. A little bit of information about how a particular combination of parts worked for one person.
  • It would be fantastic to use the same electronics for multiple CNC machines. For instance, I have a CNC mill and lathe. The lathe electronics are nearly a subset of the mill’s electronics, and rarely have I used both simultaneously.

 

Does the motor run hot?

  • To perform a comparison without a lot of chart junk, I wrote software to generate lossless thermal images with consistent color palettes from FLIR thermography images. The code is on GitHub.
  • DMM said the temperatures were fine. I wanted to help the motor so I created a shroud that goes around the servo motor with a 24V industrial Noctua fan attached to the top.
  • The fan is 24V so that I can use the same supply as the brake. Currently, if the brake is off, so the motor can turn, the fan is operating.
  • I originally had a gasket between the servo motor mount and the mill head to isolate vibration. The servo motor doesn’t vibrate. I’m not sure the isolation is necessary and removing the isolation allows some heat from the servo motor to be dumped into the mass of the head.

 

Why has this video taken so long to complete?

  • Two months were lost waiting for timing belts. First, I ordered the wrong style belt and pulleys. Then I ordered the wrong length. Then I forgot to convert the quote to an order. Each time, another two weeks was needed for the order to be received. Let me know if you need a 3D model of the assembly or bill of materials.
  • I lost another month trying to sort out electrical and miscellaneous problems. Again, Stephen and Michael at DMM and Jon Elson at Pico Systems helped a lot.

 

Are the LinuxCNC configuration files available?

  • All the configuration files that I’m currently using are available on GitHub. You can also explore the past configuration.

 

Would I do this all again?

  • Maybe, but differently, more simply. At the start, write down the minimum requirement, a plan to fulfill the requirements, and be weary of deviating. I tend to add complexity because it’s interesting but takes a lot of time to get to a result that might not be useful.
  • Many of the challenges I encountered are of my making due to particulars of my system and what I was trying to do. Your system, your goals may be different. Regardless, I hope you have an easier time.

 

There are a few items that I’ll expand on in short follow up videos. Let me know if you have any suggestions. I’d be glad to answer questions here, Instagram, Twitter, blog, or email, whatever works for you.

Thank you for watching. Thank you for listening. Thank you for all the love.