PWM Spindle Control Using Mach3
PWM Spindle Control Using Mach3
PWM Spindle Control Using Mach3
The block diagram I came up with using Open Office Draw shown below was essential during initial planning and design of the cnc lathe electronics.
Revision A
Page 1
25/07/2010
Revision A
Page 2
25/07/2010
Pulley Ratio
Mach3 needs to know the difference in rpm between the driving motor and the spindle in terms of an accurate ratio. This ratio (which needs to be expressed as Spindle rpm to Motor rpm) must be calculated or measured and entered into Mach3 in the dialog box shown in Figure 4. Pulley setup is covered in detail in the Mach3 Mill Manual in Section 5.5.6. If the spindle is driven directly by the motor, the ratio is 1:1. Mach3 allows for up to 4 pulley ratios to be setup individually. Because I have only one pulley, I setup for Pulley 1 (the default) only. To calculate the ratio, I used the method of measuring accurately the rpm of the motor shaft and spindle shaft and dividing the spindle rpm by the motor rpm. (Example below) I use an inexpensive laser digital optical tachometer shown in Figure 1 to do the measurements. I attached small pieces of adhesive reflective tape supplied with the tachometer attached to the motor and spindle shafts. The reflective tape gives a good return for the laser beam resulting in stable rpm readings. Pulley Ratio Calculation 1. Turn on the spindle using the manual mode on the VFD and adjust the speed control potentiometer until the spindle rpm as read on the tachometer is exactly 500rpm. 2. Measure and note the rpm of the motor shaft whilst the spindle is at 500rpm. (in my case, this was 1725rpm) 3. Divide 500 by 1725 which = 0.289855 (Pulley Ratio) 4. Enter 0.289855 into the ratio dialogue box as shown in Figure 4. This is all Mach3 needs for the pulley ratio.
Revision A
Page 3
25/07/2010
Figure 2 Reflective tape adhered to the motor pulley and spindle shaft
Revision A
Page 4
25/07/2010
Figure 4
Revision A
Page 5
25/07/2010
Figure 6
Revision A
Page 6
25/07/2010
Figure 7 Details of how to mount the IR Diode Limit Resistor to 5VDC on C23 BOB
Figure 8 Index Pulse Generator Fitted to Spindle Shaft with a Single 8mm Slot Disc
Figure 9
Revision A
Page 7
25/07/2010
Figure 10 Output 1 and 2 were selected as Forward & Reverse Relay control. In the example above, Output 1 (CW Rotation M3) is configured to control Relay 1 on the BOB via Pin 1 of Port 1. Output 2 (CCW rotation M4) is configured to control Relay 2 on the BOB via Pin 16 of Port 1. Because each relay on the BOB has VCC on one side of the coil, Active Low needs to be selected to activate each relay when either M3 or M4 is commanded by Mach3.
Figure 11 Spindle needs to be checked and a Pin defined for the PWM signal output to the PWM to DC Voltage Converter. I chose Pin 14 Port 2 Active Low which is connected to the PWM to Analogue DC Converter Board shown in Figure 16. Note: Even though the Mach3 Mill Manual specifies that you do not need to define a direction pin for PWM Control, I found that it needed to be defined to make the Mach3 / SmoothStepper combination happy. I defined it as Pin 1 Port 2 but it is not connected to anything. I dont understand why this is necessary, but it works for me. Revision A Page 8 25/07/2010
Figure 12 Index needs to be checked and an input pin assigned for the index pulses generated by the pulse generator shown in Figure 12. In this case Pin 3 of Port 2 was used. Active Low was also selected.
Figure 13
Revision A
Page 9
25/07/2010
Figure 14
Figure 15
Revision A
Page 10
25/07/2010
Figure 16
Figure 17
Revision A
Page 11
25/07/2010
Figure 18
Revision A
Page 12
25/07/2010
Figure 19
Figure 20
Revision A
Page 13
25/07/2010
VFD Settings
The following basic list (not comprehensive) gives details of the settings that worked for me: Minimum Reference 20Hz Maximum Reference 120Hz Ramp Up Time 1.25s Ramp Down Time 1.25s (Anything less than this resulted in VFD over current warnings during spindle slowing) Motor Speed Low Limit 20Hz Motor Speed High Limit 110Hz Terminal 18 Digital Input set to Start (This input is used for M3 CW Rotation) Terminal 19 Digital Input set to Start Reversing (This input is used for M4 CCW Rotation) Terminal 53 Analogue Input Low Voltage 0.75V (approximates the output from PWM Converter at Min speed) Terminal 53 Analogue Input High Voltage 9.0V (approximates the output from PWM Converter at Max speed) Terminal 53 Low Reference Feedback Value 20Hz Terminal 53 High Reference Feedback Value 130Hz Terminal 53 Filter Time Constant 0.25s Terminal 53 Mode set to Voltage (the default) Local Control Potentiometer Low Reference 20Hz Local Control Potentiometer High Reference 68Hz
Revision A
Page 14
25/07/2010
Figure 21
Figure 22
Revision A
Page 15
25/07/2010
Tools Required
1. 2. 3. 4. 5. Laser Optical Tachometer (Optional) Trim Tool for Potentiometers No 2 Philips Head Screwdriver VFD Operation Manual Digital Multimeter
Calibration Procedure
1. Set the VFD to Remote Control. 2. Issue M3 S300 from the MDI in Mach3. The spindle should start with CW rotation at approximately 300 rpm. 3. Overcome the Mach3 bug by pressing the Spindle Speed Reset button. 4. Using the multimeter, monitor the Analogue control voltage. 5. Adjust the calibration potentiometer on the PWM Converter board until the spindle speed is 500rpm. 6. Enter 300 into the S DRO Box and press enter. The spindle speed should be approximately 300rpm. Record the Multimeter Voltage reading. 7. Enter 900 into the S DRO Box and press enter. The spindle speed should be approximately 900rpm. Record the Multimeter Voltage reading. 8. If necessary, adjust a combination of VFD Settings such as Analogue Low and High Voltage, (the voltages recorded in Steps 6 and 7 will give you clues as to what to try) and the Maximum Frequency Limit. 9. Repeat Steps 6, 7 and 8 until you are satisfied.
Conclusion
I hope you find this document useful. If you have any suggested improvements, please let me know via the Mach3 forum and I will look at making and issuing amendments.
Revision A
Page 16
25/07/2010