Electronics

### PWM Spindle DC Motor Driver

Mar 12

An open source design for a Spindle DC Motor Driver for Arduino based controllers. This project can be built on a stripboard for DIY or prototype purposes and is also presented as a PCB design using SMD components for commercial or semi-professional production.

#### Introduction

This project was designed to solve the problem of controlling the small spindle motors commonly found on Grbl based CNC machines such as the CNC 1610 and CNC 3018, available from numerous suppliers including Amazon and eBay. The design should be capable of controlling any small DC motor up to 36V with a maximum load current of around 5A. It can handle the large in-rush currents when these motors power on and has been tested with motors that briefly demand over 10A.

The control input has been designed for logic level operation at 5V so as to be compatible with the Arduino Uno and similar boards. It should not be used with 3.3V logic levels, although a future project is in the planning to allow for this as well. The control input can be either a straightforward 5V digital output or a 5V pulse width modulated output (PWM) with a frequency up to around 20kHz.

DC motors always provide an interesting challenge when being controlled from a logic level device, as the initial in-rush current when the motor starts to spin is a direct function of the DC resistance of the motor coils. In the case of the small 775 size spindle motor used to develop and test this project, that in-rush current was to be greater than 24A.

The 24V 775 motor's DC coil resistance was measured at between 0.8Ω and 1.0Ω. By Ohm's Law,

$$I={V \over R}$$ substituting, $$I={24 \over 1}$$ $$=24A$$

If the DC coil resistance were taken to be 0.8Ω, then this would become $$I = 24 / 0.8$$, which is 30A.

The load current drops rapidly as the motor starts to spin due to the back EMF generated and the same motor therefore draws just 0.39A (measured) under full speed no load conditions. Applying a small load to the motor resulted in a load current of 1.5A (measured). A 24V power source was used for these measurements.

When the motor is switched off, the supply voltage is naturally removed (becoming 0V). As the motor does not immediately stop but continues to spin for a few seconds, it continues to act as an electrical generator. The resulting back EMF will produce a current flow through the motor that is in the reverse direction to the normal supply current and this reverse current will damage any transistor used to control the motor. This current cannot exceed the load current of the motor prior to being switched off and so we have a maximum reverse current to deal with for this motor of between 0.39A and 1.5A.

#### Circuit Description

The trigger or PWM input to this circuit is driven directly by an output from a 5V logic level device such as an Arduino Uno. The resistor R1 has had the 150Ω value so as to limit the output current of the Arduino pin to a safe level of 33mA even in the event of a MOSFET transistor failure resulting in a short circuit between the gate and source pins. The 10kΩ resistor R2 ensures that the MOSFET gate pin is pulled low during the Arduino boot sequence, ensuring that the motor is not inadvertently powered on during this time.

The Arduino Uno can supply an absolute maximum of 40mA on a digital output pin, according to the ATmega 328P datasheet. With a 5V logic level,

$$R={V \over I}$$ $$R={5 \over 40 \times 10^{-3}}$$ $$R=125 \Omega$$

The next commonly available resistor value that is higher than 125Ω is 150Ω. The maximum current drawn by the ATmega 328P pin would therefore be

$$I={V \over R}$$ $$I={5 \over 150}$$ $$I=33mA$$

This provides for a margin of safety were the MOSFET transistor to fail.

The 24V power rail used in this project has a degree of filtering provided by the 220uF capacitor C1, reducing greatly the high frequency EMI produced by the DC motor. This capacitor also helps provide the initial impulse current required when the motor starts up.

Capacitors C2, C3 and C4 along with the inductors L1 and L2 provide a low pass filter that is designed to reduce the level of high frequency EMI produced by the motor entering the power rails connected to the rest of the electronics in the CNC machine. The values of these components were chosen so as to not affect the PWM frequencies used (either 1kHz or 8kHz for a typical Grbl controlled CNC machine) whilst attenuating frequencies above 1MHz. The values of 0.1uF for C2, C3 and C4 and 3.3uH for L1 and L2 were with these objectives.

For a second order LC low pass filter, the cut-off frequency is given by

$$f_c={1 \over {2 \pi \sqrt {LC}}}$$ $$f_c={1 \over {2 \pi \sqrt {3.3 \times 10^{-6} \times 0.1 \times 10^{-6}}}}$$ $$f_c=277kHz$$

This will result in an attenuation of approximately -30db at 1MHz as the filter provides 12db of attenuation every time the frequency doubles. There will be negligible attenuation at 1kHz and 8kHz.

The inductors L1 and L2 must also be chosen so as to have a sufficiently high current rating of greater than 1.5A, to match the motor when running under load conditions.

In order to stop the MOSFET transistor being damaged by the motors back EMF, a flywheel diode is connected across the motor load circuit close to the transistor. This diode must be able to handle a forward current of greater than 1.5A and a reverse voltage of greater than 24V. Fast switching characteristics are desirable, especially with a PWM circuit where the diode may not have time to recover fully from one cycle before the next has started. A Schottky Barrier Rectifier diode is ideal in this application.

The N-Channel MOSFET transistor is chosen principally for it's ability to handle the large in-rush current. The IRF540N device has a continuous drain current rating of around 25A with VDS of 24V and a VGS of 5V. The RDS(on) value of 44mΩ also ensures that the maximum power dissipated in the transistor can be to be around 33W.

For the IRF540N transistor, the drain source resistance (RDS(on)) is 44mΩ. Assuming a motor DC coil resistance (RM) of 800mΩ and L1 and L2 having a DC resistance of 54mΩ (RL1 and RL2). Where the supply voltage (VS) is 24V, and the in-rush current (IM, previously calculated) is 30A,

$$V_{GS}=V_S \times {R_{DS(on)} \over {R_{DS(on)} + R_M + R_{L1} + R_{L2}}}$$ $$V_{GS}=24 \times {44 \times 10^{-3} \over {44 \times 10^{-3} + 800 \times 10^{-3} + 54 \times 10^{-3} + 54 \times 10^{-3}}}$$ $$V_{GS}=1.109V$$

Where the MOSFET power dissipation is PD,

$$P_D=V_{GS} I_{M}$$ $$P_D=1.109 \times 30$$ $$P_D=33W$$

The LED D1 is included as part of the MOSFET load circuit purely to give a visual indication of the state of the output and was found useful for diagnostic and testing purposes. Note that this LED is far better placed in the output load circuit rather than in the input (transistor gate) circuit, as this places an additional burden on the current drain from the Arduino. The current limiting resistor R3 was to be 10kΩ.

Experience has shown many LEDs to be a little bright for use as indicators directly mounted on a PCB unless the forward current (IF) is kept quite low at around 2.5mA. With a supply voltage (VS) of 24V and an LED forward voltage (VF) of 2V, the voltage across R3 (VR3) is

$$V_{R3}=V_S-V_F$$ $$V_{R3}=24-2$$ $$V_{R3}=22V$$

The value of R3 is now

$$R_{R3}={V_{R3} \over I_F}$$ $$R_{R3}={22 \over {2.5 \times 10^{-3}}}$$ $$R_{R3}=8.8k \Omega$$

The next highest common value now being 10kΩ.

#### Circuit Construction

The choice of construction method depends upon the intended use and equipment available. If you want a small number of circuits for home or small workshop use or do not have access to the equipment required to assemble surface mount devices, then the stripboard based method may be the way to go. For a more professional product, then the surface mount devices on a printed circuit board are definitely the way to go. Both methods of assembly have been tested and proven.

##### Stripboard
###### Parts List

The following parts will be required to make the stripboard version of the circuit. Please note that there are alternatives available for many of the parts on the list and so you may need to buy equivalent parts that may be more easily available in your locality. Also, the information links provided are intended to show examples of products that meet the requirements of the project and are not a recommendation of any particular supplier or product.

Part Description Manufacturer Part Number Quantity Information Link
Board Stripboard 50mm x 70mm Various - 1 Amazon
TO-220 / TO-262 Heatsink 20mm x 15mm x 10mm Heatsink Various - 1 Amazon
J1, J3 2-way Screw Terminal Block Wurth 691101710002 2 Wurth
J2 2-way Pin Header Wurth 61300211121 1 Wurth
R1 150Ω 0.25W Carbon Film Resistor TE Connectivity CFR16J150R 1 TE Connectivity
R2, R3 10kΩ 0.25W Carbon Film Resistor TE Connectivity CFR16J10K 2 TE Connectivity
C1 220uF 50V Electrolytic Capacitor Panasonic EEUFR1H221 1 Panasonic
C2, C3, C4 0.1uF 50V Ceramic Capacitor Kemet C322C104K5R5TA 3 Kemet
L1, L2 3.3uH 1.9A Inductor1 Bourns 5300-07-RC 2 Bourns
D1 3mm Red 2V LED Kingbright L-934ID 1 Kingbright
D2 1N5822 40V 3A Schottky Barrier Diode ON Semi 1N5822 1 ON Semi
Q1 IRF540N Infineon IRF540NLPbF 1 Infineon

1 The choice of inductor will limit the maximum continuous current load that the circuit will handle.

###### Stripboard Layout

Key

Vertical copper strips on the stripboard are shown in green. Wire links are shown in red and track cuts are shown as blue circles.

Track Cuts

The tracks should be cut at the locations D13, G7, G12, H12, I7 and J13.

Wire Links

Wire links should be soldered between pairs of locations at B11 - G11, D3 - K3, D15 - I15, F5 - I5, G9 - H9, J15 - K15. A 'solder bridge' should be formed between G13 - H13.

###### Step by Step Guide

Step 1 - Track Cuts

Firstly, cut the board to size using a hacksaw. You will need the board to be 11 strips wide and 16 holes high.

You should then make the track cuts in the locations shown (also listed above). This can be done easily using a 2.5mm drill bit, either by twisting it carefully until all the copper at that location has been removed, or by simply drilling through the board. You should confirm that the tracks have been broken using a multimeter if possible.

Step 2 - Wire and Solder Links

The wire links should now be added to the board as shown and listed above. The links here have been colour coded - red for 24V, green for ground and blue for signal, although this of course is not compulsory. The links can be made with any suitably sized single cored wire (commonly sold as 'bell-wire').

Resistor R1 (150Ω) has also been added at this stage, as it forms part of the 'solder bridge' on the reverse of the board between locations G13 and H13. The resistor is first soldered into place between locations E13 and H13, with the H13 leg of the resistor being bent across to also cover location G13 before soldering as shown in image 2b.

Step 3 - Add Resistors R2 and R3

Resistors R2 and R3 (both 10kΩ) should now be soldered in place. R2 is between locations G14 and J14. R3 is between locations G10 and J10.

Step 4 - Add Capacitors C2, C3 and C4

Capacitors C2, C3 and C4 should be soldered in next, with C2 between locations B8 and D8, C3 between F4 and H4 and C4 between D10 and F10.

Step 5 - Add the LED D1

The LED D1 should now be soldered in place between locations I12 and J12. Note that D1 is a polarised component and needs to be connected the right way round. LED polarisation is normally indicated by a shorter leg or a flat on the LED body indicating the cathode or negative pin. The cathode pin should be soldered into location I12.

Step 6 - Add Screw Terminals J1 and J3

Screw terminal J1 should now be soldered in place between locations B1 and D1. J3 should be added between locations G1 and I1.

Step 7 - Add Capacitor C1 and Diode D2

Capacitor C1 should now be soldered in place between locations B5 and D5. This capacitor is a polarised component and the body should be clearly marked to show the negative lead, which is located in D5.

Diode D2 is also a polarised component, with the cathode leg being easily identified by a stripe or line running round the body of the diode. The cathode leg should be soldered in location B16, with the anode in location D16. Note that the diode has been mounted vertically and so the legs of the diode should be carefully bent into shape before soldering it in place. The wire used for the legs of this diode is probably also too wide for the holes in the stripboard, so you will have to enlarge the holes to 1.2mm diameter in locations B16 and D16.

Step 8 - Add Inductors L1 and L2

Inductors L1 and L2 should now be soldered in place, between locations G6 and G8 for L1 and locations I6 and I8 for L2. Note that both these components are mounted vertically.

Step 9 - Add MOSFET Transistor Q1

The MOSFET transistor Q1 should first be attached to the heatsink being used as this will determine the height at which the transistor / heatsink combination sits on the stripboard.

The transistor Q1 should then be soldered in to place, with the gate (pin 1) in location H16, the drain (pin 2) in I16 and the source (pin 3) in J16. Please note that the mounting plate of this transistor is connected to the drain pin and so you should use an electrical isolating kit with your heatsink.

Step 10 - Testing

It is strongly suggested that you check your circuit carefully using a multimeter, ensuring that the track breaks are effective and that no accidental connections between adjacent tracks have been made.

##### SMD PCB
###### Parts List

The following parts will be required to make the PCB version of the circuit. Please note that there are alternatives available for many of the parts on the list and so you may need to buy equivalent parts that may be more easily available in your locality. Also, the information links provided are intended to show examples of products that meet the requirements of the project and are not a recommendation of any particular supplier or product.

Part Description Manufacturer Part Number Quantity Information Link
PCB Dual sided PCB 35.56mm x 53.34mm, 1.6mm thickness, 1oz Copper, design and gerber files on this page Various - 1 Gerber Files
J1, J3 2-way Screw Terminal Block Wurth 691101710002 2 Wurth
J2 2-way Pin Header Wurth 61300211121 1 Wurth
R1 150Ω 0.25W 0603 Thick Film Resistor Vishay CRCW0603150RFKEAHP 1 Vishay
R2, R3 10kΩ 0.1W 0603 Thick Film Resistor Bourns CR0603-FX-1002ELF 2 Bourns
C1 220uF 50V Aluminium Electrolytic Capacitor Nichicon UCW1H221MNL1GS 1 Nichicon
C2, C3, C4 0.1uF 50V 0603 MLCC Capacitor TDK CGA3E2X7R1H104K080AA 3 TDK
L1, L2 3.3uH 6A Inductor1 Bourns SRP7028A-3R3M 2 Bourns
D1 Red 2V 0603 LED Wurth 150060RS75000 1 Wurth
D2 SS54B 40V 5A Schottky Barrier Diode HY Electronic SS54B 1 HY Electronic
Q1 IRF540NSTRRPBF Infineon IRF540NSTRRPBF 1 Infineon

1 The choice of inductor will limit the maximum continuous current load that the circuit will handle. This SMD component has a much higher maximum current rating than the THT component on the stripboard design.

###### PCB Layout

Manufacturing Information

Board Size: 53.34mm x 35.56mm

Layers: 2

Thickness: 1.6mm

Minimum Hole Size: 0.3mm

Material: FR-4 TG130

Minimum Track / Spacing: 6/6mil

Finished Copper: 1oz

Solder Mask: Green

Silkscreen: White (Top Only)

###### Construction Guide

The first step in producing the PCB based version of the PWM Spindle DC Motor Driver is to find a manufacturer of printed circuit boards. A quick search online will produce a list of companies who can provide this service for a low cost with a turn around time of around a week. Many of these companies will also source the components and assemble the boards as well if you require a small batch of boards for a number of CNC machines or for re-sale.

The components listed above will also need to be sourced if you are to assemble the boards yourself. These are common components that can be found from numerous suppliers but can be substituted with care for alternatives should this be necessary. If you choose to do this, pay careful attention to the maximum ratings of the substitutes, as well as the physical package / sizing to ensure that they will fit on to the PCB as designed.

The method chosen for assembly will depend on the equipment available and your own personal experience and preferences. Obviously a pick and place machine and solder re-flow oven would be ideal, but the PCB can also be successfully assembled by hand-placing solder paste and components, then using a hot-air gun soldering station to carry out the soldering process. Through hole components (connectors J1, J2 and J3) will have to be soldered in place using a soldering iron. With care, excellent results can be obtained this way.

See the SMD PCB Hand Assembly Guide if you want to have a go at assembling a circuit like this for yourself.

Schematic PDF

Layout PDF

Schematic PDF

Layout PDF

3D STEP Model

Gerber Files

#### License

You may use the designs described on this page for any commercial or non-commercial purpose that you wish, providing you credit Capella CNC with the creation of the original design on any product or updated design that you create or distribute. The simplest way to do this is to leave the Capella CNC logo and web address intact on any product or design that is produced.

This electronic design is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.