[Home]Analog Spindle Speed Control

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

This wiki concerns setting up 0-10V analog spindle speed control with the [Mesa Electronics M5i20/7i33], interfacing to an 3-Phase AC spindle motor and Variable Frequency Drive (VFD). It may be useful for other drive types as well. Be aware that improper connections or settings could damage equipment and/or cause injury.


"The KB Electronics style DC speed controller circuit, other similar speed controllers as found in Asian imported mini lathes and mini mills and some VFDs are at mains voltage potential. This voltage is lethal." There is a least one low-cost signal isolator that can help in this situation: [Digi Speed GX interface]


I based my HAL setup on the Demo Mazak configuration. My machine, however, is significantly more simple, as there are no gear changes or spindle orientation requirements. I extend my thanks to all those who contributed to the Mazak retrofit and provided these examples.

Once the 5i20 was operational, I connected one of the analog channels on the 7i33 accessory card to my VFD per the drive manufacturer's documentation. The 7i33 allows 0-10V only; I used 5i20 digital outputs to control spindle enable, forward, reverse, and the other necessary signals. Be sure to consider the need for Emergency Stop and fault interfacing.

The following Demo Mazak snippets are a useful reference: [demo_mazak.hal]

# link the final motor command to the DAC
linksp sp-mtr-rpm-cmd motenc.3.dac-03-value
# set scaling - 10V = 4500RPM at the motor
setp motenc.3.dac-03-gain -0.002222
# correct for offset, it causes drift and hunting
setp motenc.3.dac-03-offset -8

The HAL signals and pins will of course need to be updated to match the hardware on hand. The corresponding lines that I used are below: [m5i20_io.hal]

# Set up spindle speed
net SpindleOn motion.spindle-on
net spindle-rpm-cmd motion.spindle-speed-out
setp m5i20.0.dac-03-gain [SPINDLE]DAC_SCALE
linksp SpindleOn => m5i20.0.dac-03-enable
linksp spindle-rpm-cmd => m5i20.0.dac-03-value
setp m5i20.0.dac-03-offset 80

Next, a bit of calculation is in order to correctly scale the analog signal to the actual spindle speed. I found a tachometer quite useful for confirming the chosen values.

To determine the scale, I set the VFD to my desired maximum motor speed; in this case, 120Hz. I ran the spindle with the VFD set to local control and measured the true final speed with the tachometer. This may not be necessary it details are known about the machine's final drive ratio. Once the true speed is known, simply divide the maximum analog output voltage by the measured speed. In this example, the measured speed was 2413 RPM, and the expression would appear as follows: 10 / 2413. The result is approximately 0.004144. I negated this value to get a correct output from the 7i33.

The entry [SPINDLE]DAC_SCALE from the HAL code above is simply a pointer to a location in the EMC ini file, which must be added to the default. This location is where our offset, 0.004144, would be recorded: [m5i20.ini]


DAC_SCALE =		-0.004144

Alternately, the offset could be added directly into m5i20_io.hal is this manner: setp m5i20.0.dac-03-gain -0.004144

Now that the IO and offsets are configured, when EMC commands 2400 RPM, the value is multiplied by 0.004144 and the DAC outputs 9.945 Vots. The VFD responds to the 9.945 Volt signal by accelerating the motor to 2400 RPM.

Please verify the VFD minimum and maximum settings are appropriate for your motor's construction, duty cycle, and cooling setup. I set the minimum speed command to 0.375 Volts, which allows a 90 RPM minimum spindle speed. Note that I have external cooling to allow the motor to safely operate at this low speed. A self-ventilated motor would likely be damaged if operated below 50% of the nameplate speed while under heavy load.


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited August 26, 2008 3:47 am by GNieport (diff)
Published under a Creative Commons License