I'm running series of experiments using a 6V DC motor. I'm using desktop DC power supply to power the motor and regulate its speed and everything works just fine, the setup has been running for months.

Now I need to use Arduino motor shield to power the motor and run a particular control sequence (involving motor speed, direction, brake). Arduino is powered by 9V DC supply brick (from an 110V outlet), and delivers approx. 8.5V on its outlet power pins. Once I connect the motor the voltage I read on the pins is approx. 6.8V using my multi-meter. I cannot measure the current, once I connect the multi-meter the RPM drops dramatically, I guess I'm affecting the circuit somehow.

So far i have been using Arduino's PWM control successfully but only for motors rated for voltage equal or greater than that of the power supply. This time I'm conscious of the max. voltage/current on/through the motor. I understand that PWM will reduce the average voltage but my understanding is that the motor will see the full voltage only at shorter intervals. Will this damage the motor? Playing with different PWM values I was able to get the same voltage as previously from bench DC power supply (say, 3V) but the motor noise is quite different. Motor is much louder and it sound as if it's struggling to work. I'm still measuring the same average voltage of 3V on the motor's power pins. I'm afraid this will reduce motor life or burn it completely if I continue letting 6.8V (8.5V?) directly onto it. How safe is to continue this operation?

I also saw a good discussion on regulators here on StackExchange. If PWM is not suitable, should I try a voltage regulator? Ultimately, what I'm trying to achieve is for motor to change the speed/RPM but also the direction - not sure if I can pull this off with the regulators. What would be your advice for this application?

Please don't mind if I used inappropriate terminology - I'm just a daft mechanical guy trying to figure the electrical part of how I can run this safely. I'd appreciate any input. Thanks.

EDIT: This is to provide info on PWM frequencies/mark/space ratios. I hope a chart is OK, it might be easier to explain.

The way Arduino works is you set PWM via a byte, so sending a value between 0 and 255. 0 will let no marks through, 255 will have no spaces.

I plotted here the voltage measurements across motor contacts when: a) no motor is connected, b) when motor was connected and rotation was set to CW, and c) when motor was connected and rotating CCW. CCW rotation voltage should have "-" sign in front but I plotted it this way to be easier to read and compare. Motor had no mechanical load on it.

For the motor, I stopped plotting PWM at point when I almost reached the rated voltage. I'd like to run the motor at minimum of 2.5V, and I'm interested to know how high I can go. Also if this minimum is OK or not (so far it worked just fine off of a bench DC supply).

I hope this makes sense and please let me know if there's anything else I should check and provide.

  • 2
    \$\begingroup\$ A warm welcome to the site. Please can you edit your question and add PWM frequencies and some mark/space ratios you've been using as that essential data's missing. \$\endgroup\$
    – TonyM
    Commented Jul 16, 2020 at 19:46
  • 1
    \$\begingroup\$ There is a lot to read up on with respect to bucking and pwm for driving motors. Not all of it is software, either. \$\endgroup\$
    – jonk
    Commented Jul 16, 2020 at 21:46
  • 1
    \$\begingroup\$ Thank you TonyM, jonk for replies and the greeting. I have updated the original message to provide more info on PWM. I understand that there is lot more to this, I hope I can figure some of it here. \$\endgroup\$
    – mk1138
    Commented Jul 17, 2020 at 1:49
  • \$\begingroup\$ Hi @mk1138, Welcome and nice to meet you. Ah, let me see. Your question is basically on DC motor speed (and direction) control, using PWM or "regulator". Let me introduce myself. Ages ago I studied in a trade school, and later worked in mechanical workshops as a technician for a couple of years. I also have a very rusty diploma in electronic engineering and then worked in electronic factories for another couple of years. Fast forward a bit, I have 5 hobbyist years in Arduino, and another 5 years in Raspberry Pi. I have 100+ hours playing with DC motors, sometimes using PWM, / to continue, ... \$\endgroup\$
    – tlfong01
    Commented Jul 17, 2020 at 4:38
  • \$\begingroup\$ Your question asks about DC motor speed control using two methods: (1) PWM, (2) Regulator. You also ask about direction control which I know needs to switch voltage power polarity using switches like double pole double throw relay, or motor drivers like H-Bridge which are basically also switches of motor voltage polarity. / to continue, ... \$\endgroup\$
    – tlfong01
    Commented Jul 17, 2020 at 4:44

2 Answers 2


You can use PWM control under the following two conditions:

  • The average voltage applied does not exceed the rated voltage of the motor. This ensures that the average power rating of the motor is not exceeded.
  • The duration of the PWM pulse does not cause the winding current to saturate. The rotor windings act like an inductor, which smooths the current, but if the PWM frequency is too low, you won't get a smooth current but rather high current pulses during each PWM pulse.

To do a quick and dirty test, just set the PWM frequency to 20kHz, and set the duty cycle so that the effective voltage applied to the motor, d*Vin, = Vrated.

  • 1
    \$\begingroup\$ Thanks for the reply mr_js. Regarding your second point, is there a rule of thumb for minimum frequency that would cause current pulses that are too high? I'm using a simple micro gear motor and I've been running it for months now at 2.5V with no issues. How can I check if this average voltage via PWM control would damage it? Also, I updated my originating post with more information on how PWM control works with this particular controller, and some measurements. \$\endgroup\$
    – mk1138
    Commented Jul 17, 2020 at 1:54
  • 1
    \$\begingroup\$ @mk1138 for that type of motor (iron-cored armature with many turns) anything above ~3kHz should be high enough. electronics.stackexchange.com/questions/287046/… \$\endgroup\$ Commented Jul 17, 2020 at 4:16
  • 1
    \$\begingroup\$ Thank you very much Bruce. I will look into it. There is an Arduino tutorial page discussing the frequency in context of PWM so I'll try to figure it out from there. Motor also comes with an encoder, but without a data sheet and it's giving some non-sensical values. So I'll try to figure it out in a different way. \$\endgroup\$
    – mk1138
    Commented Jul 17, 2020 at 12:26
  • \$\begingroup\$ @mk1138 If you have an oscilloscope you can measure the current flowing into the DC motor. As a rough rule, tune the PWM frequency so that the ripple is small, e.g. +-5% of the mean value. Keep in mind that if the PWM frequency is less that 20kHz, you may hear it, it will sound like an annoying squeal. \$\endgroup\$
    – mr_js
    Commented Jul 18, 2020 at 9:47
  • \$\begingroup\$ I don't have any but I will try and get it from someone and check the current that way. Thanks. \$\endgroup\$
    – mk1138
    Commented Jul 18, 2020 at 15:25


The OP wishes to control the speed of a DC motor using PWM or regulator. He also wishes to change the direction of the motor.



This answer is in two parts: Short and Long.

The short answer is kind of an introduction to the long answer.

Short Answer

Part A - Clarifications

A.1 - AC to DC Switching Power Supply and DC-DC Step down voltage regulator

The OP's Q&A on using resistor divider or Zener diode (Ref 5, 6) is not appropriate to step down a power supply for the DC motor.

The following instead are recommended: (1) 110VAC to 12V switching power supply (Ref 4) to get 12VDC, (2) A LM2596 Voltage regulator module is then used to get 3~9VDC for the DC motor.

A.2 - The OP's Average Voltage vs PWM Measurements and Chart

v vs pwm chart

The average voltage measurement used by the OP is not very useful for controlling DC motors for many reasons: (1) DC Motor speed is not linearly proportional to input voltage or current (Appendix B). (2) The DC motor's Voltage, Current, Torque, Efficiency relationship (Appendix B) is complicated.

Part B - Suggestion to run a particular control sequence

The OP would like to run a particular control sequence, involving motor speed, direction, brake. I would suggest to first use the following offline, table top hardware setup to experiment with speed and torque etc, before doing Arduino or Raspberry Pi programming.

1.  GA12-N20 geared motor with Hall effect encoder (TT130, GB37)

2.  Manual UART XY Signal Generator (Arduino/Rpi PWM, NE555, PCA9685)  

3.  L298N H-bridge motor driver (L293D, TB6612FNG, BTN7971B)

GB37 PWM Test

xy uart sig gen

/ to continue, ...

Part C - Discussion, Conclusion, and Recommendation to Newbies

/ to continue, ...

Long Answer

1. Scope

This answer is in general applicable to 6~12V DC motors, using the L298N H-bridge motor driver, and Arduino C++ or Raspberry Pi python programming.

2. Focus

The focus will be on PWM speed control on DC geared motor, using a power MOSFET and a PWM signal generator.

Once speed control problems are solved, direction control is relatively easy, by just using a H-bridge motor driver, such as L298N to switch power polarity and thus direction. The Arduino or Raspberry Pi programming part is also relatively easy.

So, as recommended by EE StackExchange, we will focus on only one topic:

DC Motor speed control using PWM

/ to continue, ...


Part A - Switching Power Supply and Voltage Regulator

(1) AliExpress 110/220VAC to 5/12/24/48VDC, 2/5/10/15/20/30 A Power Supply

(2) MeanWell NES-350 series 350W Single Output Switching Power Supply

(3) AliExpress LM2596 voltage regulator module

(4) AliExpress LM2596 DC-DC 12V/24V Step-down to adjustable 9V/6V/5V/3V 3A Power Supply Module (Actually 40V down to 1.25V)

(5) Stepping down voltage by a resistor divider - EE StackExchange, Asked 5 years ago, Viewed 234k times

(6) Stepping 5V power rail to 3V using a resistor or Zener diode - EE StackExchange, Asked 6 years ago, Viewed 1k times

Part B - PWM Signal Generator

(7) AliExpress UART XY-KPWM Signal generator 1Hz - 150KHz PWM - US$3.6

(8) How can Rpi4B python UART talk to XY PWM Signal Generators?

(9) AliExpress NE555 Square Wave PWM Module Catalog

(10) AliExpress NE555 10KHz-200KHz Square Wave Pulse Frequency Duty Cycle Adjustable Module Signal Generator - US$1

Part C - PWM H-bridge Motor Driver

(11.1) (Huge Internal Voltage Drop, Energy Wasted, and Needing Huge Heat Sink) L293, L298 and SN754410 (DRV8837, L298N) H-bridge Drivers On Low Voltage Power Supply - EE SE Forum Discussion, 2014apr30

(11.2) L298 Dual Full-bridge Driver (46V, 4A, "Low" Saturation Voltage) DataSheet - ST 2000

(11.3) AliExpress L298N DC/Stepper Motor Driver Module/Board module - US$1

(11.4) AliExpress RonZi Tech BTN7971B H-Bridge Drive Module - US$17

(11.5) BTN7971B High Current PN Half Bridge NovalithIC - Infineon 2008 June

(11.6) BTN7971B Module User Guide - ZonRi Tech 2018jan19

(11.7) AliExpress TB6612FNG H-Bridge DC Mother Driver (0.5 Ohm on resistance) - US5

(11.8) TB6612FNG MOS H-bridge Driver Datasheet - Toshiba

(11.9) DRV8871 3.6A PWM Control DC Motor Driver With Internal Current Sense - TI

(11.10) DRV8874-Q1 H-Bridge Motor Driver With Integrated Current Sense and Regulation - TI

(11.11) AliExpress H-bridge Driver Module Catalog

(11.12) AliExpress DRV8871 MOSFET H-Bridge Motor Driver Board 3.6A Max Internal Current Sense - US$2.7

(11.13) AliExpress BTS7960 43A H-Bridge Motor Driver Module - US$3 https://nl.aliexpress.com/item/32820492945.html?

(12) Instructable (Text) on How to Use L298n to Control DC Motor With Arduino - AYassine Lebouiha 2018jan04

(13) Instructable (YouTube) on How to control DC motor using L298n + Arduino - AYassine Lebouiha 2018jan04

(13.1) Controlling DC Motors with the L298N Dual H-Bridge and an Arduino (Web Page) - DroneBot WorkShop

(13.2) Controlling DC Motors with the L298N Dual H-Bridge and an Arduino (PDF) - DroneBot WorkShop

(13.3) L298N rpi.stackexchange discussion 1 (13.4) L298N rpi.stackexchange discussion 2 (13.5) L298N rpi.stackexchange discussion 3 (13.6) L298N rpi.stackexchange discussion 4 (13.7) L298N rpi.stackexchange discussion 5 (13.8) L298N rpi.stackexchange discussion 6 (13.9) L298N rpi.stackexchange discussion 7 (13.10) L298N rpi.stackexchange discussion 8 (13.11) L298N rpi.stackexchange discussion 9 (13.12) L298N rpi.stackexchange discussion 10 (13.13) L298N rpi.stackexchange discussion 11

(13.14) TaoBao DRV8837 DC Motor Driver Module 1.8A Dual Half Bridge - ¥8

(13.15) TaoBao DRV8833 DC Motor Driver (Replacing TB6612FNG) - ¥9

(13.16) AliEXpresss DRV8837 DC Motor Module Dual 1.8A - US$15

(13.17) Adafruit DRV8871 (45V 3.6A) DC Motor Driver Breakout

(14) MX1508 vs L9110S vs TB6612 vs L293D Motordriver board, ArduinoDiy

(15) MX1508 DC/Stepper PWM Dual Bridge Motor Driver - Amazon US$14

(16) L9110 Single DC Motor Driver with built in clamp diode Datasheet

Part D - DC Motor Characteristics

(14) How to read the characteristics of a DC motor? - Rotero Electrical Motion and Control 2018feb26

(15) AdaFruit 3V-6V DC 200rpm TT Gearbox Motor - $2.95

(16) YouTube AdaFruit 3V-6V DC 200rpm TT Gearbox Motor

(17) AliExpress Yellow DC 3V-6V Dual Axis Gearmotor TT Motor US$1.52

(18) TaoBao DC3V-6V Gear Motor TT Anti EMI 4WD - CN¥3

(19) Amazon DC3V/6V/12V RPM 7.5A 6000 Micro Gear Motor with metal gear

(20) TaoBao GA12-N20 Gear DC Motor with Hall Effect Encoder - ¥30

(20.1) TaoBao GA12 Motor 12MM Gear Box - ¥11

(20.2) TaoBao DC Gear Motor Catalog

(20.3) TaoBao JA12 N30 3~12C metal gear motor - ¥18

(21) Pololu 1000:1 Micro Metal Gearmotor HP 6V 31rpm, 70mA, 12kgcm, stall 1.6A - US$24

(22) Pololu Micro Metal GearMotor Catalog

(23) Pololu 6V Micro Metal GearMotor Catalog

(24) Pololu Encoders for Micro Metal Gearmotors

(25) Pololu Encoders for Micro Metal Gearmotors Catalog

(26) TTM1 1:120 gear DC motor with AB encoder (6V, 200rpm, 3.2kgfcm, 960 pulses) - MiaowLabs ¥30

Part D - Automation, Control, and Robotics Newbie Reading List

(26) Rotary Encoder (Hall Effect Quadrature Encoder) - Wikipedia https://en.wikipedia.org/wiki/Rotary_encoder

(27) Hall Effect - Wikipedia https://en.wikipedia.org/wiki/Hall_effect

(28) PID Controller - Wikipedia https://en.wikipedia.org/wiki/PID_controller

(29) Root Mean Square - Wikipedia https://en.wikipedia.org/wiki/Root_mean_square

/ to continue, ...


Appendix A - L298N Schematic and Operation

l298n 1

l298n 2

l298n 3

Appendix B - PWM Controlling Speed of JB37 Geared Motor

motor test 1

motor test 2

motor test 3

Appendix C - GA12 N20 Gear Motor with Hall Effect Encoder Specification

(20) TaoBao GA12-N20 Gear DC Motor with Hall Effect Encoder - ¥30

n20 motor spec

n20 motor spec

n20 wiring

ga12 na20 order

Appendix D - GA12 N20 Gear Motor Spec

ga12 n20 1

ga12 n20 2

ga12 n20 3

Appendix D - Pololu Hall Effect Encoder

Hall effect encoder

Appendix E - BTN7971B Datasheet Summary

btn7971b 1

btn7971b 2

Appendix F - BTN7971B Module


Appendix G - N20 DC Motor PWM and Hall Effect Quadrature Encoder Test

n20 pwm hall test 1

Appendix H - NA20 Motor PWM and Encoder Test Preparation Notes

na20 spec

Appendix I - TT130 6V Quadrature Encoder Test Results

Motor TT130 6V ~= 48 rpm

tt130 sped 1

tt130 speed test

Appendix J - N20 Quadrature Encoder Test

NA20 test 1

Appendix K - ZonRi Tech BTN7971B Module Schematic

btn module schematic

Appendix L - Calibration of PWM BTN7971B Motor Module with N20 Motor

btn7971b calibration 1

btn7971b calibration 2

btn7971b cali

speed vs duty cycle

Appendix M - BTN7971B H-bridge Motor Driver Voltage Drop Measurement

(a) I set 1kHz PWM signal to 100% duty, and also direct 6V PSU to check the motor speed. I found in both cases, the encoder output C1 is

600us, or 1000000/600 = 1666Hz, or 27rpm.

In other words, the motor driver does not seem to have any volt drop causing a reduction of motor speed.

(b) I then measure the voltage drop of the motor driver. What I did was the following.

(b.1) Use a multi-meter to measure the voltage of the power connector at the motor driver board. I found it 6.35V.

(b.2) Use the same multi-meter to measure the voltage across the motor terminals (ie, after voltage drop across the two on resistances of the two MOSFET switches conducting the current through the motor. I found it 6.13V.

(c) Total voltage of the two FET switches

So the voltage drop is 6.35V - 6.13V = 0.22V

(d) The PSU's current meter is not very accurate, shows very roughly under 20mA. So the the

Total on resistance of the two FET switches = 0.22V / 20mA ~= 0.01mΩ (Note 1).

Note 1 - My measurement are not at all precise. Perhaps I should use a L298N motor driver to compare the voltage drop and speed.

Appendix O - MT1208/MX1508 Flyback diode discussion notes

Note: the following article has a discussion on whether it is necessary to us flyback diodes on MX1508.

(14) MX1508 vs L9110S vs TB6612 vs L293D Motordriver board, ArduinoDiy


/ to continue, ...

End of Long Answer

  • 1
    \$\begingroup\$ Dear tlfong01, thank you so much for the greetings and especially for such detailed response. I appreciate it very much. I'll go through it in detail, I feel obliged after you put in the time and effort to prepare it! I'd just like to apologize if I didn't make myself clear in my OP. The question I asked is based on what is the best for the motor and my application in context of avoiding the long term damage or total failure. \$\endgroup\$
    – mk1138
    Commented Jul 17, 2020 at 12:26
  • 1
    \$\begingroup\$ Also, my final goal is to reliably control the RPM and I am using voltage to discuss the problem simply because that is what I can control and measure. I had issues with measuring the current as explained above. I understand that it is not the proper way to do it but it's the only indicator I have or know how to utilize. Given your mechanical background I hope you understand my limitations in this regard. \$\endgroup\$
    – mk1138
    Commented Jul 17, 2020 at 12:26
  • \$\begingroup\$ @mk1138, you are welcome. I appreciate your very detailed description of the project. I agree it is important to design for long term reliability and safety. One thing we need to study rigorously and experiment extensively is the motor's speed vs torque characteristics. If we are going to use PWM to control the speed, then we don't care to adjust input voltage, keeping it to 3V. We also don't care about current, because we are using the Hall encoder as feedback to control the speed using PWM (as you say, adjusting the "average voltage"). See Ref 20 and Appendix C. / to continue, .. \$\endgroup\$
    – tlfong01
    Commented Jul 17, 2020 at 14:32
  • 1
    \$\begingroup\$ Ha ha, will do and in the meantime I'll try to familiarize myself with root mean square. \$\endgroup\$
    – mk1138
    Commented Jul 19, 2020 at 1:19
  • 3
    \$\begingroup\$ Do not use the L298, like all Darlington devices it is truly horrible for low voltages with huge internal losses causing the calculations here to be quite innacurate and motor performance dissapointing. Use an FET bridge instead. \$\endgroup\$ Commented Jul 19, 2020 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.