Uncategorized

n20 motor speed vs duty cycle

Help with choice of DC motor speed control – PWM vs. Regulator

Ask QuestionAsked 9 days agoActive todayViewed 222 times41

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.pwmdc-motorshareedit  follow  flagedited Jul 17 at 1:48asked Jul 16 at 18:33mk11384355 bronze badges

  • 2A 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. – TonyM Jul 16 at 19:46
  • 1There is a lot to read up on with respect to bucking and pwm for driving motors. Not all of it is software, either. – jonk Jul 16 at 21:46
  • 1Thank 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. – mk1138 Jul 17 at 1:49
  • 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, … – tlfong01 Jul 17 at 4:38   
  • 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, … – tlfong01 Jul 17 at 4:44   

add a comment  |  show 1 more commentstart a bounty

2 Answers

ActiveOldestVotes4

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.shareedit  follow  flag answered Jul 16 at 21:03mr_js64133 silver badges99 bronze badges

  • 1Thanks 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. – mk1138 Jul 17 at 1:54
  • 1@mk1138 for that type of motor (iron-cored armature with many turns) anything above ~3kHz should be high enough. electronics.stackexchange.com/questions/287046/… – Bruce Abbott Jul 17 at 4:16
  • 1Thank 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. – mk1138 Jul 17 at 12:26 
  • @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. – mr_js Jul 18 at 9:47
  • I don’t have any but I will try and get it from someone and check the current that way. Thanks. – mk1138 Jul 18 at 15:25

add a comment3

Question

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.


ga12-n20

Answer

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 Zenor 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, …


References

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


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


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, …


Appendices

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 Effecct 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

btn7971b

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

/ to continue, …


End of Long Answershareeditdeleteflagedited just nowanswered Jul 17 at 5:11tlfong0131211 silver badge55 bronze badges

  • 1Dear 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. – mk1138 Jul 17 at 12:26
  • 1Also, 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. – mk1138 Jul 17 at 12:26 
  • @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, .. – tlfong01 Jul 17 at 14:32    
  • I have been playing with toy motors TT130 and GB37. Your NA20 motor is too small for my big hands to handle. I remember I once carelessly fried two NA20 motors, by wrongly using too long screws, crashing the gear box, and too heavy loading sticking things. Perhaps I can search my junk box for any NA20 motors left over and tried it again. Ah, bed time. I call it a day. So see you on Sunday or Monday. Cheers. – tlfong01 Jul 17 at 14:32    
  • Oh, I see what you mean – if I understood correctly, you are saying to use the magnetic rotary encoder (my motors have them) signal to monitor the RPM and control the PWM based on that? I haven’t thought of it. Perhaps because voltage regulation was so readily available. Good thing I asked! Do you have any recommendation on calibration procedure? What I mean, I don’t understand the part of keeping the voltage fixed at 3V and RPM change via PWM – on Arduino voltage changes as I change the PWM value… Also, how do I keep tabs on excessive voltage? Enjoy your weekend and thanks again! – mk1138 Jul 17 at 19:48
  • P.S. My actual motor, my actual magnetic encoder. I tested encoder just briefly a couple of times when I got the motor but I was getting some nonsensical readings. So I moved to capturing the RPM via high-speed camera. I need to revisit the encoder readings and try to pair it with the actual RPMs I observed. – mk1138 Jul 17 at 19:53
  • Yes, the magnetic/Hall effect encoder is very useful to measure both speed and position. You can use Arduino GPIO pin to detect the A, B signals to deduce speed, direction, and distance. There is some confusion about motor power supply, eg 6V, and PWM power. For example, if you are using the L298N motor driver, the L298N power supply Vcc is 6V, but if you set PWM duty cycle to 50%, say, then the “average” voltage is 50% of 6V, ie 3V. But the “rms” voltage is higher than that. / to continue, … – tlfong01 Jul 19 at 1:12   
  • Yes, the magnetic/Hall effect encoder is very useful to measure both speed and position. You can use Arduino GPIO pin to detect the A, B signals to deduce speed, direction, and distance. There is some confusion about motor power supply, eg 6V, and PWM power. For example, if you are using the L298N motor driver, the L298N power supply Vcc is 6V, but if you set PWM duty cycle to 50%, say, then the “average” voltage is 50% of 6V, ie 3V. But the “rms” voltage is higher than that. / to continue, … – tlfong01 Jul 19 at 1:12   
  • I would suggest you to google/wiki for the term “rms” Your Pololu motor seem of the same model as mine. I need to read the product sheet to make sure. I will be doing some N20 motor calibration this afternoon. You might like to sit back and watch what I will be messing around. Cheers. – tlfong01 Jul 19 at 1:13   
  • 1Ha ha, will do and in the meantime I’ll try to familiarize myself with root mean square. – mk1138 Jul 19 at 1:19
  • 2Do 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. – Chris Stratton Jul 19 at 10:01 
  • @Chris Stratton, Oh my goodness,your warning arrives just in time, because I was just about setting up the L298N to do the rotary encoder and PWM testing. On second thought, I better, as you advised, try a FET H-bridge first. Thank your very much. Cheers. – tlfong01 Jul 19 at 12:37   

add a comment

.END

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.