Silicon Chip20A DC Motor Speed Controller - September 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Back Issues: Hare & Forbes Machineryhouse
  6. Publisher's Letter
  7. Feature: What’s in a name? by Mark Nelson
  8. Feature: The Fox Report by Barry Fox
  9. Feature: Net Work by Alan Winstanley
  10. Project: TOUCHSCREEN AND REMOTE DIGITAL PREAMP WITH TONE CONTROLS by NICHOLAS VINEN AND TIM BLYTHMAN
  11. Project: MICROMITE TO SMARTPHONE CONNECTOR VIA BLUETOOTH by TOM HARTLEY
  12. Project: 20A DC Motor Speed Controller by JOHN CLARKE
  13. Project: USB-PD Triggers, Decoys and Testers by Jim Rowe
  14. Feature: Circuit Surgery by Ian Bell
  15. Feature: Make it with Micromite by Phil Boyce
  16. Feature: Max’s Cool Beans by Max the Magnificent
  17. Feature: AUDIO OUT by Jake Rothman
  18. PCB Order Form
  19. Advertising Index

This is only a preview of the September 2022 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
BY JOHN CLARKE 20A DC Motor Speed Controller This small but powerful speed controller has a 20A rating and is packed with features. It suits a wide range of applications and is simple to build and use. Features include low-battery protection, soft starting and adjustable pulse frequency. It can handle DC motors that run from near 0V up to 30V. T here are a great many applications for DC motors where speed control is wanted or necessary. Since DC motors can be run directly from batteries, they are used in golf carts, electric scooters, bikes, skateboards, remote-controlled cars and boats – the list goes on. In most of those applications, you need a way to control the speed of the motor. Going flat out all the time isn’t always a good idea! A speed controller like this one is the ideal solution. It can handle DC motors with a rated voltage of up to 24V (30V maximum) and continuous currents up to 20A. This controller is presented as a bare electronic module built on a PCB that can be installed in a standard UB3 plastic case. It includes heavy-duty terminals for the power supply and motor connections, plus additional terminals for the speed control potentiometer that mounts off the PCB. The motor-driving components are mounted on substantial heatsinks for cooling. The adjustable features like softstart rate and feedback gain are set using onboard multi-turn trimpots with voltage test points. An onboard LED indicates the speed setting, as well as faults like low battery or motor disconnection. controlled using pulse-width modulation (PWM). That means that the motor is driven by a series of on and off voltage pulses rather than a variable DC supply, making it more efficient. Speed control of the motor is done by varying the pulse width. The ratio of the pulse width to the interval between pulses is the duty cycle. A low duty cycle will only provide a voltage to the motor for a small portion of the time, and the motor runs slowly. As the on-pulse duration increases, this greater duty cycle makes the motor run faster until it reaches 100% duty cycle and is driven continuously. Oscilloscope traces Scope 1 and Scope 2 show how this PWM scheme works. In Scope 1, the top (yellow) trace is the gate drive signal for MOSFETs Q1 and Q2. When it is high, the motor is powered. In this case, the duty cycle is very low at about 9.5%, so the motor runs slowly. The lower cyan trace is related to the motor current. This is used to maintain motor speed with a variable load. Scope 2 has the same two traces, but this time the duty cycle is much higher, and the motor runs faster. The motor is loaded less than in Scope 1, so the current reading is lower despite the higher duty cycle. Speed controller design While we have published many DC motor speed controllers in the past, this version has more features and better performance. The motor speed is What’s new One of the problems with controlling DC motors using PWM is that the motor can make extra noise due to the motor windings and other mechanical parts 30 vibrating at the PWM frequency. This can be alleviated to some extent by adjusting the PWM frequency to produce minimal noise. That noise tends to be reduced as the PWM frequency is increased, and is mostly eliminated at PWM frequencies above 20kHz (around the upper limit of human hearing). But increasing the frequency can cause problems too. It becomes harder to maintain the motor speed against a varying motor load using the traditional back-EMF feedback system. Very high PWM frequencies can also cause a loss of motor torque. These problems and solutions are described in more detail in the section titled, PWM motor driving pitfalls at higher frequencies. This controller gives you the ability to adjust the PWM frequency beyond audibility while addressing the problems of limited low-speed motor torque and control at elevated frequencies. Other features that are incorporated include soft starting, low-voltage cutout, LED status indication and optional motor disconnected detection. These features are easy to set up and adjust via trimpot adjustments. Soft starting This is where the motor is slowly increased in speed, up to the setting of the speed pot. Soft starting reduces the surge of current and a rapid build-up of motor torque compared to applying power suddenly. The PWM duty cycle Practical Electronics | September | 2022 is ramped up over a longer period, so that the motor starts more smoothly. The maximum soft-start period is two seconds for the full range from 0% duty to 100%. This period can be adjusted from zero to two seconds in 255 steps. Soft starting can be initiated in several ways. It applies when the controller is initially powered up, or when the speed control is started from the fully off position, and finally, after returning to regular operation from low-voltage shutdown. Features Low-voltage detection The low-voltage detection feature is included to prevent over-discharging a battery supplying power to the motor. Most batteries, including lead-acid and lithium chemistry types, will be damaged if discharged beyond a certain voltage. This feature switches off the motor drive at a pre-set threshold voltage. This is indicated with a 65ms flash of the indicator LED at 1Hz. The voltage must be below the threshold for more than ten seconds before the drive to the motor is switched off. This prevents any nuisance low-voltage trips that would otherwise switch off the controller due to a short-term voltage drop when the motor starts up. Once shut down, the voltage needs to rise above the low-voltage detection threshold by a certain amount before it will start up again. This hysteresis prevents constant switching on and off as the battery voltage recovers with the motor load removed, only to switch off again once the motor restarts. • • • • • • • • • • • Motor disconnection The optional motor disconnect detection prevents the motor from starting up if it is disconnected and then reconnected while the speed setting is above • • • • • • • • • • DC motor PWM drive Can drive motors rated up to 24V and 20A DC Motor and controller supply voltage can be separate 16 PWM frequency choices Motor load feedback control and gain adjustment Adjustable soft-start rate Motor speed curve adjustment Under-voltage cut-out with LED indication and adjustable hysteresis Duty cycle LED indicator Optional motor disconnect detection Specifications Speed adjustment range: 0% to 100% duty cycle Motor supply: from near-zero to 30V maximum Controller supply: 10.5V to 30V maximum (5.5-26V with ZD1 linked out) Speed indication: LED1 brightness varies with PWM duty cycle PWM frequency: 16 steps from 30.6Hz to 32.4kHz (see Table 1) Soft-start rate: 0-2 seconds in 255 steps for 0% to 100% duty cycle Speed curve adjustment: minimum speed can be set to 0-33% duty cycle Under-voltage (UV) threshold: 0-30V in 29.6mV steps UV hysteresis: 0-5V in 29.6mV steps in ication E ashes on for s at Motor disconnection detection: motor is shut down if monitored current drops to ero while ri in otor in icate with 0 ut c cle E ashin • Speed pot disconnection detection: indicated with a dimly illuminated LED zero. When the motor is detected as disconnected, the speed potentiometer needs to be wound fully anticlockwise and the motor reconnected before it can run again. The disconnected state is indicated with the indication LED blinking at 2Hz. Separate supply voltage Another feature is the ability to separate the controller’s supply voltage from the supply to the motor. This means that the motor can be run from a much lower supply voltage than that required to operate the DC Motor Speed Controller. So while the DC Motor Speed Controller requires a supply of at least 10.5V to operate (up to 30V), the motor can be run using a separate supply from near Scope 1: a pulse-width modulated (PWM) drive signal at a low duty cycle, about 9.5%. Current has little time to build during each pulse, so the motor runs slowly. Practical Electronics | September | 2022 0V up to 30V. The 30V limit is sufficient to allow for just about any 24V battery; eg, a fully charged 12-cell lead-acid battery is around 29V. You can use the same supply for both the controller and the motor, provided the voltage is in the 10.5-30V range, and that voltage is suitable for the motor. Circuit details The DC Motor Speed Controller circuit is shown in Fig.1. It is based around an 8-bit PIC16F1459 microcontroller (IC1) which provides the PWM drive signal and monitors the battery voltage, motor current and the voltage from several trimpots and the speed potentiometer. IC1 also monitors rotary switch S1, which selects the PWM frequency. Scope 2: another PWM drive signal, here with a duty cycle of 35.5%, which is roughly the same as driving the motor at 1/3 supply voltage, so it will run faster but not nearly at full speed. 31 IC1 has two PWM outputs, and we use both. One is at pin 5 (PWM1) and the other at pin 8 (PWM2). These PWM outputs have different functions, but provide the same PWM frequency and duty cycle most of the time while the motor is being driven. The PWM1 output is used to drive MOSFETs Q1 and Q2 via gate driver IC3. IC3 is an MCP1416, designed to provide a high-current drive with fast rise and fall times to the MOSFET gates. This ensures that they switch on and off quickly. Each MOSFET gate is isolated from the other using a 10Ω resistor. The resistors also prevent MOSFET switching oscillations at the gate threshold. These MOSFETs are logic-level types that fully conduct with a gate voltage of 5V. Non-logic-level MOSFETs typically require at least 10V for full conduction. The two MOSFETs are connected in parallel, sharing the load (motor) current. Low-value resistors are placed between the source of each MOSFET and ground, with Q1’s source resistor being used to monitor the current. The source resistor on Q2, while not used for load current measurement, is still necessary. That’s so that the total on-resistance of MOSFET Q2 and its source resistor matches Q1 and its source resistor. Since the MOSFET on-resistance is typically 0.014Ω, the 0.01Ω source resistor for Q2 helps maintain even sharing of the load current between the two MOSFETs. Without it, Q2 would carry about 2/3 of the load current and Q1 only 1/3. Diode D1 is included between the positive supply and the MOSFET drains to clamp the induced voltage spike when the motor’s drive is switched off. This diode is effectively connected across the motor terminals. It is a dual 10A schottky diode that can conduct 20A continuously when the diodes are connected in parallel. Paralleling the diodes ensures nearly equal current sharing. That is possible because the two diodes are on the same silicon die, and therefore have the same characteristics and operating temperature. The motor supply is connected to the GND and motor supply + terminals on screw connector CON1. This positive supply is fed to the motor via fuse F1, an automotive blade-type fuse with a rating selected to suit the motor. Three 470μF 35V low-ESR electrolytic capacitors bypass the motor supply after the fuse. These are to provide a high shortterm peak current supply. Feedback control Many DC motor speed controllers monitor motor back-EMF (electromotive force) to determine when variations in 32 the load might reduce the speed of the motor. This back-EMF is the voltage generated by the motor when the supply to it is switched off and the motor is still turning. The induced voltage reduces when the motor slows under load. Speed control is maintained by increasing the PWM duty cycle to increase motor torque and speed when its speed drops. But we don’t use the back-EMF sensing method for reasons described under the section PWM motor driving pitfalls at higher frequencies. Instead, we monitor its current draw. When MOSFETs Q1 and Q2 are conducting, the voltage across Q1’s 0.01Ω source resistor is proportional to the current being drawn by the motor. When the MOSFET is off, there is no voltage across this resistor. So we use a sample-and-hold circuit to capture the voltage while Q1 is conducting. MOSFET Q3 and the 100μF capacitor form the sample-and-hold buffer. The gate of Q3 is driven by the PWM2 output of IC1, which follows the PWM1 output. So when Q1 and Q2 are on, so is Q3, and the 100μF capacitor charges or discharges so that its voltage approaches that across the 0.01Ω current-sense resistor. When MOSFETs Q1 and Q2 switch off, so does Q3, isolating the 100μF capacitor from the 0.01Ω resistor to prevent it discharging during the off-time. The reason we use the separate PWM2 output to drive Q3 has to do with the case when the motor is off. In this case, the PWM1 output has a duty cycle of 0% (ie, it’s held low), but PWM2 is programmed to produce a 60μs pulse every 13.4s. This switches Q3 on momentarily, discharging the 100μF capacitor via the 0.01Ω resistor. This on-duration is extended if the capacitor needs to be discharged from a higher voltage, especially when the motor is turned off by reducing the speed control. Without this, the 100μF capacitor slowly charges via leakage current from amplifier IC2, causing the motor to start rather abruptly. IC2 is an instrumentation amplifier and provides amplification of the small voltage across the shunt for current measurement. Its gain can be adjusted from between 611, when trimpot VR6 is at minimum resistance, and about nine when the trimpot is at its maximum of 50kΩ. This caters for the wide range of motors that could be used, ranging from those drawing less than 1A up to 20A. The output from IC2 is monitored by the AN9 analog input (pin 9) of microcontroller IC1, which uses its internal analogue-to-digital converter (ADC) to convert the voltage from IC2 into a 10-bit digital value (0 to 1023). Speed control Potentiometer VR1 is the main speed control. The voltage at its wiper varies with its rotation, and is fed to analog input AN5 (pin 15) of IC1. This is converted to a 10-bit digital value, indirectly controlling the PWM duty cycle applied to the MOSFETs. Motor load compensation is performed by increasing the duty cycle of the PWM signal depending on the motor load, based on the motor current. The amount of feedback applied is adjusted by setting the gain for IC2, as described above. Supply voltage monitoring The motor supply voltage is monitored at analog input AN10 (pin 13) of IC1. The supply voltage is reduced to one-sixth (1/6) of its full value by a 10kΩ/2kΩ voltage divider. So for a 0-30V motor supply, the voltage at AN10 is in the range 0-5V. This voltage is filtered using a 100nF capacitor to prevent noise from altering the result of the ADC conversion. Setting adjustments This voltage is compared with the under-voltage threshold setting voltage at the AN7 input (pin 7) set by trimpot VR4. This trimpot is connected across the 5V supply, allowing a voltage range adjustment from 0-5V. Test point TP4 is included so the set threshold can be measured. To make setting up easier, the voltage at TP4 is one-tenth the undervoltage threshold. So if you want the under-voltage threshold to be 11.5V, set the voltage at TP4 to 1.15V. The voltage at the AN7 input is converted to a digital value and multiplied by 1.6666, so the scale matches the dividedby-six motor voltage. The motor supply has to drop below this threshold for 10 seconds before the drive to the motor is switched off. When this happens, LED1 flashes momentarily each second. Typically, a battery will recover a little when the motor drive is switched off; the battery voltage will rise once there is no load. To prevent the motor from switching on again due to this effect, we add hysteresis. The motor supply will need to go above the low voltage threshold plus the hysteresis voltage before the motor drive will be re-enabled. In practice, the battery needs to be charged before the motor can run again. This hysteresis is set using trimpot VR5, monitored at TP5. The TP5 reading is the full hysteresis voltage (not 1/10th as for the threshold measurement at TP4). So if you want a 1V hysteresis, adjust VR5 until TP5 reads 1V. Practical Electronics | September | 2022 20A DC Motor Speed Controller Fig.1: microcontroller IC1 monitors the positions of speed pot VR1 and trimpots VR2-VR5 via five analogue input pins. It also reads the position of BCD switch S1 (used to set the PWM frequency) using four digital inputs. A PWM waveform is produced at pin 5, which drives MOSFETs Q1 and Q2 via driver IC3; those MOSFETs switch current through the motor. The motor current is converted to a voltage using a 10mΩ shunt; this voltage is amplified by IC2 and measured at pin 9 of IC1. The soft-start period adjustment is with VR2, measured at TP2. This voltage is monitored at the AN6 input, and sets the maximum rate at which the motor speed increases. The maximum time to reach 100% duty cycle from zero is two seconds, with 5V at TP2. A 2.5V setting will give a one-second soft-start period, and so on. VR3 is the speed curve adjustment trimpot, with corresponding test point TP3. This is monitored at the AN4 input of IC1, pin 16. This allows the speed pot to be used over its entire range when the PWM frequency is set relatively high, and can also compensate for the fact that motors can require Practical Electronics | September | 2022 a duty cycle well above 0% before they start spinning. As described in the separate panel labelled, PWM motor driving pitfalls at higher frequencies, in some cases, driving a motor with a high PWM frequency can mean that the motor will not start until the duty cycle is at 20%, or even higher. The curve adjustment sets the initial duty cycle when the speed potentiometer is rotated just clockwise from fully-anticlockwise. This adjustment removes the dead zone from the speed pot. The curve adjustment range is from almost zero to a 33% initial duty cycle. Whenever the curve setting is nonzero, the software within IC1 expands the speed control range so that the maximum duty cycle is still achieved when VR1 is fully clockwise. Operation at low frequencies can also be optimised using the curve adjustment, with jumper JP1 inserted to pull the normally high RA5 digital input low (pin 2). Without the jumper inserted, the RA5 input is pulled high via an internal pull-up current. The curve adjustment when JP1 is inserted allows for better feedback control at very low duty cycles. The adjustment reduces the motor snap-on effect, where the feedback voltage suddenly rises with an increase of the PWM duty just off from zero. This adjustment sets a feedback offset value 33 PWM motor driving pitfalls at higher frequencies When using PWM to drive a DC motor, the average motor winding current varies depending upon the duty cycle. Since torque is proportional to the winding current, the motor speed can be easily controlled. In theory, the motor speed is not affected by the frequency; it is only the duty cycle that matters because that sets the average current through the motor windings. Higher PWM frequencies will result in less ripple in the motor current, but will not affect the a era e si ni cantl But there are cases where higher frequencies can affect the current at lower duty cycles, to the point that the motor will refuse to turn at all with lower duty cycles. There is much confusion over the reasons for this and what to do about it. e trawle the internet tr in to n a good explanation of this phenomenon, and most of the information we came up with was misleading or incorrect. So we performed several experients to n out for oursel es We found: if you are using a halfbridge or full-bridge to drive a DC motor, it will behave pretty much as theory predicts. The motor current varies almost exactly linearly with the PWM duty cycle, regardless of frequency. That is what you would expect if you model the motor as an inductance in series with a resistance. If the inductance is L and the series resistance is R, the motor winding impedance is then f he a nitu e of the current for a sinewave at any given fre2 f 2 uenc f is then A PWM signal comprises a DC component the a era e le el ut c cle plus co ponents at the switching frequency f, and its squarewave harmonics at 3f, 5f, 7f... The exact mix of harmonics varies with the duty cycle. As the current decreases with increasing frequency, the winding inductance attenuates the AC components of the PWM signal. The motor windings act to smooth out these ripples, but the inductance has no effect on the direct current level; it is solely determined by the supply voltage, duty cycle and motor winding resistance. Our tests bear this out. But like many simpler designs, our motor speed controller does not use a halfbridge or full-bridge design and therefore does not produce a square wave across the motor windings. The motor’s positive terminal is connected to V+, and the negative end is periodically pulled down to 0V when MOSFETs Q1 and Q2 switch on. Some of the time, we have V+ across the motor. But the rest of the time, when MOSFETs Q1 and Q2 are off, the winding inductance and backEMF pull the motor’s negative terminal above the positive terminal. The voltage is clamped by diode D1 to around 0.5V above the positive voltage. So there is a negative voltage across the motor when the MOSFETs are off, rather than 0V, and a si ni cant recirculatin current ows through diode D1. This causes the motor winding current to decay signi cantl faster than in the half-bri e or full-bridge case described above. You can see this if you compare Scopes 3 and 4. These show the same unloaded DC motor being driven at the sa e M fre uenc k an sa e ut c cle 0 but with half-bridge drive in Scope 3 and single-ended drive in Scope 4. The yellow trace shows the applied voltage, while the green trace shows the current through the motor windings. The rate of current rise and peak current are similar between the two. But when the high-side MOSFETs switch off and the low-side MOSFETs switch on in Scope 3, you can see an exponential decay in the motor win in current he current ows throughout the whole cycle until it starts rising again on the next cycle. In Scope 4, with the current recirculating through the diode during the off-ti e it eca s e ponentiall but faster then linearl reachin ero before the next cycle. Therefore, the average current is much lower, around half a rea in of 00 s 800 despite the duty cycle being the same. Scope 5 shows the same half-bridge drive scheme used in Scope 3, again with a 0 ut c cle but at a uch hi her M fre uenc of k The average current is only a little bit lower, reading about 750mV compared to aroun 800 ue to the M SFE ‘ ea ti e’ bein ore si ni cant at this higher switching frequency. Scope 6 shows the same singleended drive scheme as in Scope 4, but this ti e at k he current disparity has increased further – the average winding current is now onl 8 So the effect of the single-ended drive scheme on motor current is worse at higher frequencies. With the single-ended drive scheme, the average motor current for low duty cycles is less than expected, and this effect increases at higher frequencies. So it is a good idea to increase the minimum duty cycle at higher PWM frequencies to compensate, which is the reason for trimpot VR3 in this design. The magnitude of this effect can vary with the motor, too. Larger motors with a higher inductance will tend to suffer more from reduced current an tor ue at low ut c cles with higher PWM frequencies. In practice, the easiest way to compensate for this effect is to tune the ini u ut c cle settin b a ustin until ou et satisfactory speed control at the lower end of speed pot VR1’s range. If this cannot be achieved for a given motor, try a lower PWM frequency. so that feedback is ignored below the specified speed setting. Trimpot VR3 is also used to enable or disable motor disconnection detection. This is done by splitting VR3’s range into two halves, 0-2.5V and 2.55V. From 0V to 2.5V, motor disconnection checking is disabled. Above 2.5V, motor disconnect detection is enabled and the curve adjustment is reversed, with fully clockwise giving the same effect as fully anti-clockwise. When the motor current feedback is below a set value for more than about 200ms, the motor is determined as being 34 Practical Electronics | September | 2022 Scope 3: the voltage across the motor (yellow) and current (green) with a half-bridge at 10% duty cycle. The motor inductance limits the current rise and fall times. The current does not fall back to zero before the next pulse, despite the relatively low duty cycle; the winding inductance sustains it. disconnected. In this case, the PWM duty cycle is set to zero and the LED flashes at 2Hz. The motor will only start again after it is reconnected, and the speed pot is wound fully anti-clockwise. This prevents erratic operation due to, for example, loose wires. Motor disconnect detection is optional, because unless the motor is set up correctly when used at high frequencies, false disconnection events can cause nuisance shutdowns. This can occur if the curve is not adjusted correctly, with a sufficiently high duty cycle at the start of the speed pot rotation. PWM frequency options Switch S1 is used to select the frequency of the PWM drive for the motor. This is a 16-position rotary BCD (binary-coded decimal) switch. There are four switch terminals labelled 8, 4, 2 and 1, plus a common connection, which we have connected to ground. The other switch terminals connect to the RA1, RB6, RB7 and RB5 digital inputs of IC1, respectively. All of these pins except for RA1 are configured in IC1 to provide a pull-up current. The RA1 input does not have such an option, so an external 10kΩ pull-up resistor connects to 5V. These pull-ups hold the inputs high (at 5V) whenever the switch does not connect that terminal to ground. The 16 possible combinations are decoded in IC1, and the required PWM frequency is selected (see Table 1). Power supply Controller power is supplied via CON1’s terminals between GND and the controller supply positive input. The supply current passes through zener diode ZD1, and the input of regulator REG1 is bypassed with a 470nF capacitor. Scope 5: switching back to half-bridge driving but bumping up the frequency to 31.4kHz, you can see that the average current value is hardly affected. The current level averages higher during the off-time due to the shorter off period. Practical Electronics | September | 2022 Scope 4: like Scope 3, but we have switched from a halfbridge driver to a single MOSFET with a recirculating diode, as used in this (and many other) speed controllers. This dramatically affects how the current tapers off at the end of each pulse, so the motor current is much lower with low duty cycles. REG1 is a low-dropout automotive 5V regulator. It is capable of withstanding a reverse polarity voltage, so it provides the circuit with reversed-supply protection. The maximum recommended operating voltage at the input of REG1 is 26V. So for use at up to 30V, ZD1 drops the voltage at the input by around 4.7V. The dropout voltage for REG1 is typically 0.5V. That means it needs 5.5V at the input to ensure that the output is regulated. The addition of ZD1 means that the minimum recommended voltage for the controller is 5.5V + 4.7V = 10.2V. We round this up to 10.5V to be safe. Note that the controller and motor positive supply connections are separate, so the motor can be run at a different voltage if required. That means the motor supply could be outside the controller’s range, and the circuit will still work as long as an appropriate controller supply voltage is applied. The two supply inputs can Scope 6: the single-ended drive with the higher frequency suffers from the same rapid decay in current as shown in Scope 4, except this time the average current is even lower as it has less time to build during the shorter on-pulses. 35 Reproduced by arrangement with SILICON CHIP magazine 2022. www.siliconchip.com.au The DC Motor Speed Controller with speed control potentiometer VR1 attached for testing. also be tied together when the motor supply voltage is within the controller’s suitable range. Construction The DC Motor Speed Controller is built using a double-sided, plated- through PCB coded 11006211, measuring 122 x 58mm and available from the PE PCB Service. Fig.2 shows the assembly details. Start by installing the two 10Ω surface-mount resistors and the two 0.01Ω resistors, all near Q1 and Q2. Now fit Parts List – 20A DC Motor Speed Controller 1 double-sided, plated-through PCB coded 11006211, 122 x 58mm, available from the PE PCB Service 1 UB3 Jiffy box (optional) [Jaycar HB6013, HB6023, Altronics H0203] 1 6-way 20A* PCB mount barrier screw terminals, 8.25mm pitch (CON1) [Altronics P2106] 1 3-way screw terminal with 5.08mm spacing (CON2) 1 10kΩ linear potentiometer (VR1) 1 knob to suit VR1 1 two-pin header, 2.54mm pitch, plus shorting block/jumper (JP1) 3 TO-220 silicone insulating washers and bushes 1 20-pin DIL IC socket for IC1 1 8-pin DIL IC socket for IC2 (optional) 3 TO-220 PCB-mounting heatsinks [Jaycar HH8516, Altronics H0650] 1 4-bit BCD switch (S1) [Jaycar SR1220, Altronics S3001A] 1 20A blade fuse holder (F1) [Altronics S6040] 1 blade fuse to suit motor (up to 20A) 4 M3 x 10mm panhead machine screws 1 M3 nut 4 6.3mm-long M3-tapped standoffs and 8 M3 x 6mm screws (optional; for mounting the board) 6 PC stakes (optional) * inkle speci es these as 0 -rate ltronics state Semiconductors 1 PIC16F1459-I/P microcontroller, DIP-20, programmed with 1100621A.hex (IC1) instru entation a pli er -8 [element14, RS] 1 MCP1416T-E/OT MOSFET driver, SOT-23-5 (IC3) [RS Components 668-4216] 1 LM2940CT-5.0 regulator, TO-220 (REG1) [Jaycar ZV1560, Altronics Z0592] 2 STP60NF06 N-channel MOSFETs, TO-220 (Q1,Q2) [Jaycar ZT2450] 1 2N7000 N-channel small signal MOSFET, TO-92 (Q3) [Jaycar ZT2400, Altronics Z1555] 1 3mm high-brightness LED (LED1) 1 4.7V 1W zener diode (ZD1) 1 MBR20100 dual 10A schottky diode, TO-220 (D1) [Jaycar ZR1039] Capacitors 0μF low-ES electrol tic 1 470nF 63V MKT polyester Resistors all etal l 00μF electrol tic 9 100nF 63V MKT polyester a ial unless otherwise state 1 100kΩ 3 10kΩ 1 2kΩ 1 1kΩ 1 330Ω 2 10Ω M3216/1206 surface mount 2 0.01Ω M6432/2512 3W surface mount [RS Components Cat 188-0753, Vishay WFMA25120100FEA or equivalent] 4 10kΩ top adjust multiturn trimpots (3296W style) (VR2-VR5) 1 50kΩ top adjust multiturn trimpot (3296W style) (VR6) 36 IC3, the surface-mount MOSFET gate driver. Take care when soldering this; you may need a magnifying glass and separate work light. Solder pin 1 first and check that the remaining pins are aligned correctly before soldering them. Zener diode ZD1 can now be installed, taking care with its orientation. Follow with the seven throughhole resistors – check each one using a digital multimeter (DMM) before mounting it. Once these parts are in place, install the socket for IC1. IC2 can be mounted using a socket, or you can solder it directly to the board. Make sure each is oriented correctly. Now is a good time to fit MOSFET Q3, the LED and the two-way header for jumper JP1. Make sure LED1’s longer lead (anode) goes into the hole at the left, marked with an ‘A’. You could mount a two-pin header there instead, or solder a twin-lead cable to the board so that the LED can be chassis-mounted. The polyester capacitors can then be inserted; it’s easiest to install the electrolytic types after all the semiconductors. Follow with the trimpots, which are all multi-turn types. Orient them with the adjustment screws positioned as shown. BCD switch S1 can now be installed, with the orientation dot at the lower right. The 3-way screw terminal block (CON2) is next on the list. Make sure it is correctly seated against the board and that its openings face outwards before soldering its pins. CON1, the 6-way screw terminal barrier block, can then go in. Note that Altronics state these are 15A rated; however, the Dinkle data for these DT-35-B07W-XX terminals rates Table 1: PWM frequency options BCD switch setting (S1) PWM frequency 0 30.6Hz 1 61.3Hz 2 122.5Hz 3 245Hz 4 367.6Hz 5 490Hz 6 980Hz 7 1.96kHz 8 2.97kHz 9 3.92kHz A 5.88kHz B 7.84kHz C 11.8kHz D 15.7kHz E 23.5kHz F 32.4kHz Practical Electronics | September | 2022 them at 20A, so they are suitable for this 20A controller. The fuse holder is next. You can fit a monolithic holder or two separate fuse holder clips. If using individual clips, it might be a good idea to insert a fuse before soldering to ensure they are lined up correctly. You can install PC stakes at test points TP1-TP5 and TP GND, or leave them off and probe the PCB pads directly with multimeter probes. Installing the semiconductors Regulator REG1 is mounted horizontally on the board. It is installed by first bending the leads to pass through their mounting holes. REG1’s tab is then secured to the PCB using an M3 x 6mm machine screw and nut, after which the leads are soldered. MOSFETs Q1 and Q2 and schottky diode D1 are mounted vertically and fastened to separate small heatsinks. The three heatsinks must be installed first, by soldering their locating pins to the relevant PCB pads. Make sure that the heatsinks are properly seated against the PCB before soldering them in place. Then slide Q1 and Q2 into their mounting holes and, using silicone washers and insulating bushes (see Fig.3) to isolate each from the heatsink, fasten them using M3 x 10mm machine screws into the tapped holes on the heatsinks. Tighten the screws firmly, then solder their leads. Diode D1 is mounted similarly. Now install the leftover electrolytic capacitors, taking care to orient them correctly. Finally, use your multimeter to confirm that the metal tabs of D1, Q1 and Q2 are isolated from their heatsinks. Next, wind the curve adjustment trimpot VR3 fully anti-clockwise. You can find this position by winding at least 20 turns anti-clockwise or until a faint clicking sound is heard. When the circuit is powered, the voltage reading between TP3 and GND should be very close to 0V. Low-voltage cut-out testing When power is applied, the LED will flash at 1Hz because there is no power connected to the motor supply. Trimpot VR4 sets the low-voltage cut-out. With a multimeter connected between TP4 and TP GND, adjust VR4 for one-tenth of the desired low cut-out voltage. So for a low voltage cut-out at 11.5V (a safe level for most 12V leadacid batteries), adjust TP4 until you get a reading of 1.15V. Adjusting the hysteresis is similar, using trimpot VR5 and measuring at TP5. The hysteresis is the voltage measured at TP5 (not 1/10th as before). So for a 1V hysteresis, set TP5 to 1V. Hysteresis can be set for up to 5V, but 1V is a reasonable starting point. With the recommended 11.5V cut-out voltage, that means the battery voltage needs to rise above 12.5V (about half-charge) before operation resumes. If you have an adjustable power supply, the low-battery cut-out can be tested. Connect this supply between the motor supply positive and 0V, and rotate VR1 fully clockwise. The LED will light up when the supply voltage is in the operating range and flash when a low voltage is detected. Set the supply to more than the low voltage cut-out setting plus the hysteresis setting, so the low-voltage cut-out will not initially activate. Then reduce the voltage to the cut-out voltage. Note that the low-voltage protection will take about 10s to occur once the supply is below the threshold. LED1 should then flash at 1Hz. Slowly increase the supply to just over the threshold plus the hysteresis setting value (12.5V in our example), and LED1 should light fully. If necessary, adjust VR4 and VR5 to get it to cut out and in at precisely the voltages you require. Soft-start setting Adjust VR2 for the required soft-start rate. Typically, 5V at TP2 is suitable, giving a maximum two-second softstart period. You can reduce this for faster starting, or disable soft starting with 0V measured at TP2. Testing Before inserting IC1 into its socket, check the regulator operation by applying 10.5-30V between the 0V and the controller positive supply terminals on CON1. Measure the voltage between REG1’s metal tab and its right-most lead. You should get a reading close to 5V (4.75 to 5.25V). If not, check that the input voltage at the left lead of REG1 is at least 5.5V. If this reading is correct, switch off the power and install IC1, making sure it is oriented correctly, and none of its leads fold under the body. If you used a socket for IC2, plug it in now. At this stage, it is a good idea to wire potentiometer VR1 to CON2. You will also need to insert the fuse to continue testing. The fuse should be rated to suit the motor; if it is a 1A-rated motor, install a 1A fuse; for a 20A motor, use a 20A fuse... and so on. Fig.2: the Speed Controller PCB is relatively compact and uses just five SMD parts: four resistors and MOSFET driver IC3. MOSFETs Q1 and Q2 and diode D1 attach to PCB-mounting heatsinks for cooling. During assembly, watch the polarity of the three ICs, diode ZD1, the electrolytic capacitors and BCD switch S1. Practical Electronics | September | 2022 37 The disadvantage of back-EMF-based speed feedback Typically, a DC motor acts as a generator when the power is switched off. When using PWM drive, this generated voltage or back EMF (Electromotive Force) occurs repetitively when the driving MOSFETs are switched off. But the induced voltage is not developed immediately after switch-off; it does not happen until the stored charge in the inductance of the motor windings dissipates. In many speed controllers, the back EMF voltage is used to stabilise the speed with varying load. As the motor is loaded, the speed and back EMF reduce, and this change is used to provide feedback that increases the PWM duty cycle to maintain speed under load. However, with higher PWM frequencies, the back EMF voltage appears much later in the PWM cycle; sometimes, it is not developed until after the MOSFETs are switched on again, so it is impossible to sense the back EMF. Compare scope grabs Scope 7 and Scope 8. They are the same except that the PWM frequency is just under 3kHz in Scope 7 and nearly 12kHz in Scope 8. You can see the back EMF ‘shelf’ appear about 80μs after switch-off in Scope 7, but it is barely visible in Scope 8 and would not be present at all with a higher switching frequency. The lack of back-EMF at high PWM frequencies means that we need to use a different way of detecting motor load. The easiest alternative is to measure the motor current. We only do this while the motor is driven by amplifying the voltage across a low-value shunt resistor in series with the motor. Using feedback control based on measuring current, the PWM duty cycle can be increased whenever the motor is loaded. This tends to overcome the shortcomings of low torque at high frequencies and lower duty cycles, to some extent at least. Curve adjustments VR3 sets the curve adjustment. This is off when VR3 is wound fully anti-clockwise, with 0V at TP3. Rotating VR3 clockwise will increase the curve adjustment. For settings above 2.5V, see the optional motor disconnection detection section below. As mentioned earlier, the curve setting provides high-frequency operation improvements when JP1 is out of circuit or low-frequency operation improvements with JP1 inserted. With JP1 out, VR3 increases the minimum duty cycle for low settings of VR1. To make the adjustment, rotate speed potentiometer VR1 slightly clockwise from fully anticlockwise, giving a reading of just over 20mV at TP1. Then adjust VR3 clockwise until the motor just starts to run. Adjust the gain control (VR6) for best motor control for maintaining motor speed under load. Clockwise will give more gain, and anti-clockwise will set a lower gain. Setting the gain too high can cause the motor speed to become unstable. Set the PWM frequency to a value that you find best for the motor. This will be a compromise between motor control performance and the amount of PWM noise made by the motor. Very low frequencies can cause the motor Scope 7: with a PWM frequency just under 3kHz, there is sufficient time for back-EMF sensing. The motor voltage shoots up immediately after the MOSFETs switch off, then falls back to a lower plateau once the magnetic field has decayed and back-EMF starts to become dominant. 38 Fig.3: this side view shows how the TO-220 package devices are mounted to the heatsinks. The hole in the heatsink is pre-tapped. The heatsinks are connected to ground via the PCB and mounting pins, so you do need the insulating washers and bushes. to run coarsely. Very high frequencies will improve smoothness, but can reduce torque at lower settings unless the feedback control is adjusted to give better performance under load. Adjust the response trim pot (VR3) to give the best speed control range for VR1. When the PWM frequency is low, you might find that the motor speed can increase sharply when winding VR1 up from zero, especially when there is high feedback gain. Adjusting the response using VR3 with JP1 inserted can reduce this snap-on effect. Start from 0V (at TP3) and adjust VR3 until the motor runs well at low duty cycles, without the snap-on effect. Motor disconnection detection If you want this option, the curve adjustment trimpot (VR3) is set in the opposite manner. There is no curve adjustment when VR3 is fully clockwise (5V at TP3), and the curve adjustment increases as VR3 is wound further anti-clockwise. It is usable down to 2.5V at TP3. Scope 8: with a PWM frequency of nearly 12kHz – the back-EMF voltage is barely visible just before the start of the next pulse. It would be impractical to sample the back-EMF voltage at this frequency for this motor, and impossible at higher frequencies. Practical Electronics | September | 2022