NEW      ***    mikroCNC now supports ETH-MCI motion controller

Control of spindle revolution speed using PWM or STEP/DIR signals

Friday, 30 September 2016

pdfRead this article in paper form

Besides relays that are used for switching spindle on and off, Mach3 supports two ways for controlling spindle revolution speed.

  • using PWM signal and
  • using STEP/DIR signals.

In the following text it will be described in detail how to control spindle with USB-MC motion controller using PWM or STEP/DIR signals. Other Audioms Automatika doo Ethernet or USB lines of motion controllers could be also used.

In order to activate mentioned spindle control, inside Mach3 software, dialog Ports&Pins/Spindle Setup (figure 1) should be opened and in Motor control group option Use Spindle Motor Output should be turned on. Also in this dialog it is possible to choose PWM control or Step/Dir Motor option.


Figure 1 Ports&Pins/Spindle Setup dialog - Motor control group

In case of PWM regulation it is possible to specify minimum duty cycle using the field Minimum PWM shown in the same group. Field PWMBaseFreq is not used (crossed field on figure 1). PWM frequency can be specified via additional dialog for USB-MC motion controller Plugin control/USB-MC Config... (General setup tab – figure 2).

 Spindle PWM STEP DIR2

Figure 2 USB-MC configuration dialog

Also it is required to turn on spindle axis and configure pins and port for STEP and DIR output signals (figure3). In case of PWM control, only STEP pin and port are required to be configured because this signal line is used for PWM output and DIR pin and port are then not in use.

In example shown on figure 3, these are the pins 11 and 12.

NOTE: USB-MC motion controller supports simultaneous operation of 6 axes controlled by STEP/DIR signals. In case that spindle STEP/DIR axis is used, axis C must be turned off. If PWM spindle regulation is used then this limitation is not present, i.e. all seven axes (figure 3) can be turned on.

Spindle PWM STEP DIR3 

Figure 3 Dialog for setting up pins and port for STEP and DIR output signals

When STEP/DIR spindle regulation is used it is required to specify parameters for number of steps per revolution (Steps per), maximum speed Velocity (rpm) and acceleration (Acceleration) for the motor that is used to drive the spindle (figure 4).

Spindle PWM STEP DIR4 

Figure 4 Motor Tuning and Setup dialog

NOTE: After changing parameters for Spindle motor it is required to restart Mach3 so that new values are put into effect.

Pulley Selection dialog

For both types of spindle speed regulation, dialog Config/Spindle Pulleys (figure 5) is applicable. Parameter interpretation differs a little depending on control type.

Maximum and minimum speeds are specified using fields Max Speed and Min Speed (rpm). These parameters practically define a valid range for S command, i.e., if Max Speed=100, and Min Speed=5000, valid S command range is from S100 to S5000.

In case of PWM control, value of Max Speed relates to duty cycle 100%. So, in example like on figure 5 where maximum speed is 8000 rpm and minimum is 0 rpm, when command S4000 is given, PWM duty cycle would be set to 50%.

Spindle PWM STEP DIR5 

Figure 5 Pulley selection dialog

General equation to calculate PWM duty is:

Eq1 en

where given_spindle_speed is speed that is given using S command.

In other words, as given speed goes from Min Speed to Max Speed, resulting PWM duty cycle is changes from 0 to 100%, like it is shown on figure 6.a.

SpindleVel graph en

Figure 6 Spindle revolution speed diagrams for a) PWM control and b) STEP/DIR control

In case of STEP/DIR control, Max Speed relates to parameter Velocity from figure 4, so the same command S4000 would produce resulting speed that is 50% of Velocity parameter. If transmission is 1:1 (direct motor drive, no reduction) it is required to set Max Speed to the same value as Velocity so that correct speed calculation is performed.

General equation for STEP/DIR control is:

Eq2 en

As minimum speed that is possible to command is Min Speed, from previous eqauation it follows that minimum resulting motor speed is:


In other words, if given speed changes from Min Speed to Max Speed, MotorSpeed changes from Vmin to Velocity as it is shown on figure 6.b. On this picture MotorSpeed is shown as v.

If commanded speed should be greater than Max Speed, Mach3 would present a warning "To Fast for Pulley. Using Max."

Min Speed (rpm) represents minimum valid spindle revolution speed for the given pulley. If, e.g. by using S command, speed is requested that is lower than Min Speed, Mach3 would issue a warning and set speed to specified minimum. In case of PWM regulation, if commanded speed would result in duty cycle lower than specified minimum in SpindleSetup (figure 1), Mach3 would respond with warning "PWM Bumped to minimum setting" and would set PWM duty cycle to given minimum value.

Minimum revolution speed is often specified to protect spindle motor from overheating, considering that motor fan has poor efficiency on lower rpm.

Ratio field represents relation SpindleRPM / MotorRPM, i.e. transmission ratio for spindle drive system. This parameter is used by Mach3 to recognize true revolution speed of spindle when utilizing Index input. If Index sensor is located on the motor and not on spindle itself, depending on transmission, this ratio can be different than 1 and it needs to be specified for correct calculation of spindle revolution speed. More about of setting up of Index input can be read on page.

Transmission ratio can be found analytically or by measuring motor and spindle revolution speeds using appropriate instrument (tachometer).

NOTE: After changing Ratio parameter it is required to restart Mach3 so that new values can be put into effect.

Reversed option enables changing of rotation direction for every pulley individually. When using STEP/DIR regulation DIR output signal is inverted. For both regulation types turning on this option results in reversing of spindle relay functions, i.e., M3 and M4 commands.

PWM output can be used for other purposes, for example to control laser power. USB-MC motion controller supports advanced functions for this application (see dialog General setup/Laser PWM options in USB-MC controller configuration window, figure 2).

Audioms Automatika doo Support team

logo footer

Develop and produce motion controllers, stepper and DC servo motors drives.

Follow us:

Facebook Twitter Youtube

Contact & Ordering

Ibarskih rudara str. 3/8, 34000 Kragujevac
Serbia, EUROPE

Web: www.audiohms.com
E-mail: prodaja@audiohms.com

Technical support
E-mail: office@audiohms.com