Author Topic: DC Motor crashing uController  (Read 4642 times)

0 Members and 1 Guest are viewing this topic.

Offline elkayemTopic starter

  • Contributor
  • Posts: 12
  • Country: us
DC Motor crashing uController
« on: February 18, 2018, 02:46:54 am »
I have a fairly simple circuit, and what I'm sure is a common problem.  I am using a MOSFET to drive a DC motor, and using a 10 kHz PWM output of an STM32F103 microcontroller to control the speed.  Both are running off of the same 20V, 3.5A power supply.  The microcontroller is powered using a 7805 using the recommended capacitors.

I am able to run just fine with a 50% duty cycle (1A through motor).  When I start stepping up, the microcontroller crashes when I get above 70 or 80%.

I have noticed that if I connect to the motor using a long pair of parallel wires (~3 feet), the problem seems to almost completely go away.  I can run for minutes at a time at 100%, though occasionally I do get a reset.  It makes me wonder whether the extra resistance or capacitance in the wires is suppressing this issue.  I do have a scope, and have looked at the 5V power going into the microcontroller.  It does have a fair amount of high frequency hash (> 50 MHz) that can peak at a few volts. 

I have included a schematic showing all of the parts I am using.  The motor draws about 2A at 20V. 

Any tips or best practices?  Any thing I should look at to troubleshoot?  I'm sure I could drive the microcontroller with a different power supply, though would prefer not to and anyway they will share the same ground.


 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11228
  • Country: us
    • Personal site
Re: DC Motor crashing uController
« Reply #1 on: February 18, 2018, 03:08:56 am »
Is 100nF at the output of 7805 the only capacitor on the MCU supply?  Or do you have proper decoupling at the MCU?
Alex
 

Offline elkayemTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: DC Motor crashing uController
« Reply #2 on: February 18, 2018, 03:31:50 am »
You're right, I should have included that detail as well.

I am using the "Blue Pill" board, schematic here: http://wiki.stm32duino.com/images/c/c1/Vcc-gnd.com-STM32F103C8-schematic.pdf.  It is powered off of its own 3.3V regulator, with a 0.1 uF and 1 uF on the 5V side, and a 0.1 uF and 10 uF on the 3.3V side. 
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8110
  • Country: fi
Re: DC Motor crashing uController
« Reply #3 on: February 18, 2018, 10:56:59 am »
Minimize the loop area of the motor mosfet source node (GND) and the +20V motor supply node. Then, add a combination of a big electrolytic cap (say, 470-1000uF 30V) and smaller ceramic caps (say, a few 1 uF 35V) between those nodes, physically as close as possible.

Note that while the motor may be further away, D1 should be in the tight loop, right next to the MOSFET and the capacitors. Although I understand that schematic is not a layout picture, the schematic shows the diode in the "wrong place", suggesting a possible layout issue here.

The small ceramic caps provide path for high-frequency pulse currents quickly, so that the currents don't need to flow through long parasitic inductances. The big electrolytic cap damps oscillations by providing enough capacitance (Celectrolytic >> Cceramic) so that parasitically stored energy cannot much change its voltage, but high enough ESR so that it doesn't contribute to back-and-forth oscillating currents, but instead eats them.

Doing the motor power stage layout right with the right caps will solve the problem 99% surely.

An additional elcap (such as 47uF) at the 7805 input would be a plus.
« Last Edit: February 18, 2018, 11:01:46 am by Siwastaja »
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5840
  • Country: de
Re: DC Motor crashing uController
« Reply #4 on: February 18, 2018, 11:21:27 am »
I'm missing caps for brush suppression at the motor. Try with 22 nF across the motor and 2 x 10 nF from each terminal to the motor casing. They should be mounted directly at the motor.

Edit: or mount something like this: https://www.conrad.de/de/entstoerfilter-passend-fuer-modellbau-motor-500-600er-234559.html
« Last Edit: February 18, 2018, 11:29:22 am by Benta »
 

Offline elkayemTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: DC Motor crashing uController
« Reply #5 on: February 18, 2018, 05:17:41 pm »
Benta and Siwastaja, you guys are awesome!

I followed your tips methodically, and the problem is fixed.  Just for your interest (and that of others struggling with the same problem, I'll show a few before and after shots.  Here is the original noise on the 5V input to the uC.  This plot is centered on the 5V power, with 1V grid.  You can see nearly 7V p-p!
 


Siwastaja, you suggested:
Quote
Minimize the loop area of the motor mosfet source node (GND) and the +20V motor supply node. Then, add a combination of a big electrolytic cap (say, 470-1000uF 30V) and smaller ceramic caps (say, a few 1 uF 35V) between those nodes, physically as close as possible.

Note that while the motor may be further away, D1 should be in the tight loop, right next to the MOSFET and the capacitors. Although I understand that schematic is not a layout picture, the schematic shows the diode in the "wrong place", suggesting a possible layout issue here.

You are correct that the schematic didn't accurately represent the layout.  The diode and MOSFET, 20V and ground were in a fairly tight arrangement, and the motor about 10 inches away.  I took your suggestion to add some additional capacitors as close to the MOSFET and diodes as possible.  I put a giant 3300 uF capacitor and the largest ceramic I had on hand, a 0.1 uF.  The result on the 5V noise is shown below.    This still shows around 6V p-p, a slight improvement, though the uC still crashed. 



Quote
An additional elcap (such as 47uF) at the 7805 input would be a plus.

Before embarking on this morning's debugging, I had already placed a 100 uF on the 7805 input, so the above results include this capacitor.

Benta, you suggested:
Quote
Try with 22 nF across the motor and 2 x 10 nF from each terminal to the motor casing. They should be mounted directly at the motor.

This made a dramatic improvement.  The largest noise transients on the 5V supply that I could find were about 2V p-p.  I let the motor run for 10 minutes at 100% and the uC never crashed. 



Thank you both!  I've updated the schematic to show the changes I made.  This now shows the motor as separate from the diode and MOSFET. 

 
The following users thanked this post: BillyD

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5840
  • Country: de
Re: DC Motor crashing uController
« Reply #6 on: February 18, 2018, 07:31:03 pm »
Yeah, brush arcing makes much more trouble than you think.
Glad you got it working.

 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16272
  • Country: za
Re: DC Motor crashing uController
« Reply #7 on: February 18, 2018, 07:38:03 pm »
I would also add a low value resistor in series with the feed to the regulator, so that at max current draw from the controller you drop around 2v across it, so that there is better isolation of the motor transient current from the digital power supply. As the current drawn is probably under 200mA I would suggest 10R 0.5W as a ballpark start value. Should get the power rails a lot more stable.
 

Offline elkayemTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: DC Motor crashing uController
« Reply #8 on: February 20, 2018, 05:08:33 pm »
Thanks Sean, another great suggestion!  I followed your advice.  The 7805 current draw is closer to 100 ma, so I bumped up the resistance a bit to 15 ohms for a 1.5V drop.  It also helps offload a little bit of the power from the 7805, which is getting a little toasty at just under 100C.  (I'm thinking a heat sink is needed, but that is another question...)  Anyway, the measured transients on the 5V line are still around 1V p-p, but anything I can do to make the design more robust is great.
 

Offline CopperCone

  • Super Contributor
  • ***
  • Posts: 1415
  • Country: us
  • *knock knock*
Re: DC Motor crashing uController
« Reply #9 on: February 20, 2018, 05:24:19 pm »
Another option may be to use a modern voltage regulator with better high frequency rejection. Also it may help. To drive the transistor with a schmitt trigger or buffer to help isolate the drive signal some.


Im not sure about this but you can possibly determine the bandwith of the mosfet drive signal.and put a filter on it to shunt away energy higher then you drive signal (harmonics depend on frequency and rise time) to possibly prevent high frequency energy from being conducted into the mcu through the gate of thr transistor... Though this is probovly rather low and you should focus on the power supply selection.

You can also add a rlc filter to your voltage regulator to improve its high frequency rejection capability. They typically perform poorly in the megahertz area where you are having a problem. Since its in the 50MHz region you will want to design a rlc filter that uses inductors with a high self resonant frequency.

Ideally you would use a spectrum analyzer on the power rail to see the frequency spectrum of the interference to design a filter that provides appropriate attenuation.


Basically there is a relationship between the probability of soft error in the microcontroller and the noise present within it. These details are not well known and complicated and probobly subject to change as the transistors age. Furthermore a high noise level present in a system that seems to operate fine may increase suceptibility to external noise in some caeses due to mixing inside of the circuit and timing coincidences.  The probability of hard error from interference is not known to me but i can imagine that it is low by design of the chip and it would really require the perfect storm. This is also dependant on what the chip is doing at the time and how the program is structured. Look at the so called "rowhammer" attack to get some insight on how noise can effect a complex digital system with constantly changing rf impedances.

The 7805 is old. There are definatly better parts and i recall some regulators meant for rf use to have very good hf psrr. Nothing but cost prevents you from using them.
« Last Edit: February 20, 2018, 05:41:05 pm by CopperCone »
 

Offline elkayemTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Re: DC Motor crashing uController
« Reply #10 on: February 21, 2018, 06:21:04 am »
Great suggestions CopperCone!  Can you suggest a "modern" voltage regulator that I should be using?  I have a drawer full of 1.5A 7805s that I have been working my way through, but will need to replace them at some point, and might as well bring myself to the 21st century. 
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: DC Motor crashing uController
« Reply #11 on: February 21, 2018, 09:13:43 am »
I have a drawer full of 1.5A 7805s that I have been working my way through, but will need to replace them at some point, and might as well bring myself to the 21st century.

Those are not "bad" regulators, you just have to know what they can do or can't. Those will leak all the hi-frequency noise through w/o filtering/regulation. -
 So you must filter high frequencies before regulator. Notice in your waveforms ringing frequency, it's very high. Then check PSRR specs of your regulator and you will see your problem - that your regulator can't regulate/filter such a high frequency noise! Actually even modern LDO's can't ;)

Solution: Do you happen to have some 10uH inductor capable of currents that are needed for 5V rail? Supposedly 100mA for that blue pill shall be more than needed. Put one such inductor and 10 Ohm resistor in series before C2/C7. if no inductor, then just use resistor alone. It together with following caps will do some of filtering job as well.

High frequency 2vpp pulsations on 5V bus is still *very* bad. You have to get them down to 100mVpp or so.
« Last Edit: February 21, 2018, 09:26:04 am by ogden »
 

Offline ZomBiE80

  • Contributor
  • Posts: 39
  • Country: fi
Re: DC Motor crashing uController
« Reply #12 on: February 21, 2018, 10:39:31 am »
Just put a 10nF cap between motor poles.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5840
  • Country: de
Re: DC Motor crashing uController
« Reply #13 on: February 21, 2018, 10:57:31 am »
Just put a 10nF cap between motor poles.

If you read the previous posts, you'll see that this has already been addressed.

 

Offline ZomBiE80

  • Contributor
  • Posts: 39
  • Country: fi
Re: DC Motor crashing uController
« Reply #14 on: February 21, 2018, 11:10:28 am »
Just put a 10nF cap between motor poles.

If you read the previous posts, you'll see that this has already been addressed.



You mean this?:
Quote
I'm missing caps for brush suppression at the motor. Try with 22 nF across the motor and 2 x 10 nF from each terminal to the motor casing. They should be mounted directly at the motor.

Edit: or mount something like this: https://www.conrad.de/de/entstoerfilter-passend-fuer-modellbau-motor-500-600er-234559.html

Too much capacitance. 2.2nF and 1nF would be better.
« Last Edit: February 21, 2018, 11:14:17 am by ZomBiE80 »
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: DC Motor crashing uController
« Reply #15 on: February 21, 2018, 12:19:52 pm »
Look at cap datasheets carefully, not all caps are equal for same
sized cap in terms of ESR. Polymer caps for bulk have ~ 10x better
F vs Z curves than regular tantalums.



Also V vs C curves, especially MLCC -


https://www.niccomp.com/resource/files/ceramic/VoltageCoefficientofCapacitors-032012-R1.pdf


Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5840
  • Country: de
Re: DC Motor crashing uController
« Reply #16 on: February 21, 2018, 12:37:14 pm »
Quote
Too much capacitance. 2.2nF and 1nF would be better.

So why do you suggest 10 nF?  :palm:

I've lost count of the number of PMDC motors I've used for RC models, the normal cap value is 47 nF and 2 x 22 nF for brush suppression. Mind you, this is for switching frequencies around 3...4 kHz. In this case it's 10 kHz, so 22 and 2 x 10 fit quite well.
« Last Edit: February 21, 2018, 12:40:42 pm by Benta »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8110
  • Country: fi
Re: DC Motor crashing uController
« Reply #17 on: February 21, 2018, 02:13:36 pm »
Yeah, you would fine-tune the brush suppression cap values for the specific motor.

Often, these caps are included by the motor manufacturer, which I kind of assumed, but it's not always true especially with cheap motors.

Note that excessive capacitance across the motor will cause current spikes in switching, causing more harm than good. Some designs might include high capacitor values that only apply to DC powering the motor (or linear regulation loops), but don't work with PWM supply. Nevertheless, these capacitors are subjected to high peak ripple currents; many types do not work. They are almost always ceramic.
 

Offline CopperCone

  • Super Contributor
  • ***
  • Posts: 1415
  • Country: us
  • *knock knock*
Re: DC Motor crashing uController
« Reply #18 on: February 21, 2018, 05:04:40 pm »
Check out the lt3042. It has like 60 db of psrr at 10MHz, this is nothing to scoff at. Combined with a rlc filter it will be pretty good, but yes i believe that ogden has a point that 50MHz is a bit high. A rlc filter is better suited for this frequency region then dc regulators but i think its still worth a try.

You can design some simple rlc filters in a simulator such as the japanese online one to see how much attenuation you will get depending on where the 3db point of the filter is. Pay attention to self resonant frequency of the inductor, you will want it ahead of your target frequency

How time and temperature stable are the noise profiles generated by brushed dc motors?

Getting some kind of network analyzer capability would be useful here to see the impedance of your power structure.

For the sake of redundance and the fact that the motor caps are basically mounted to a vibrating structure that may temp cycle and stuff i would design the circuit to work without them if you can afford to do so. The motor housing does not seem like the most friendly location for electronic components.

Can someone elaborate on the procesure for tuning the x/y capacitors on a motor? Can the inductance of it be measured to give some starting values? I am not very familiar with electromechanical devices. There seems to be alot of contention and no procedure regarding capacitor choice here.
« Last Edit: February 21, 2018, 05:22:27 pm by CopperCone »
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: DC Motor crashing uController
« Reply #19 on: February 21, 2018, 05:58:00 pm »
Check out the lt3042. It has like 60 db of psrr at 10MHz, this is nothing to scoff at. Combined with a rlc filter it will be pretty good, but yes i believe that ogden has a point that 50MHz is a bit high.

No need to look for another regulator just because there's no filter.  In circuits with hi-freq noise sources it is must to do extra power supply filtering using (LC) filter. Even lt3042 will need filter so better just add proper filter for existing reg and that's it.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8110
  • Country: fi
Re: DC Motor crashing uController
« Reply #20 on: February 21, 2018, 06:18:23 pm »
Note that simply adding an LC filter to the power supply can and often will amplify the input oscillations/noise.

LC filter needs to be designed to be properly damped. Two typical ways to dampen are:
1) Parallel resistance to the inductor (either an actual parallel resistor, or high-frequency resistive inductor core material. The idea of ferrite beads is that they are often lossy, but make sure they don't saturate)
2) Series resistance to the capacitor (either an actual resistor, or using a high-ESR capacitor, such as your typical cheap electrolytic)

Both ways may be needed. It's best if both inductor and capacitor are "lossy" at high frequencies. This loss is irrelevant from the efficiency viewpoint when just filtering noise (i.e., they don't actually carry SMPS ripple currents), but is essential to make it stable.

A combination of series R (also sharing the 7805 heat dissipation), a hefty ferrite bead (not saturating at the peak currents), and a poor old aluminium elcap is often simple and effective.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: DC Motor crashing uController
« Reply #21 on: February 21, 2018, 06:21:36 pm »
Note that simply adding an LC filter to the power supply can and often will amplify the input oscillations/noise.

LC filter needs to be designed to be properly damped. Two typical ways to dampen are:
1) Parallel resistance to the inductor (either an actual parallel resistor, or high-frequency resistive inductor core material. The idea of ferrite beads is that they are often lossy, but make sure they don't saturate)
2) Series resistance to the capacitor (either an actual resistor, or using a high-ESR capacitor, such as your typical cheap electrolytic)

Indeed. I did suggest damped filter:

Put one such inductor and 10 Ohm resistor in series before C2/C7. if no inductor, then just use resistor alone.
 

Offline ez24

  • Super Contributor
  • ***
  • Posts: 3082
  • Country: us
  • L.D.A.
Re: DC Motor crashing uController
« Reply #22 on: February 21, 2018, 07:53:41 pm »
Are you using a 24v motor?  I find that 20v are rare.  On Aliexpress there are only 3, and they are rated for 6-20v.  And there are about 8,000 rated for 24v.

Are you using a laptop power supply?  My Dell puts out 19.6v.  I am just curious about the 20v since it seems odd to me.

Interesting topic - lots to learn here and someday I hope to do the same thing

thanks
YouTube and Website Electronic Resources ------>  https://www.eevblog.com/forum/other-blog-specific/a/msg1341166/#msg1341166
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5840
  • Country: de
Re: DC Motor crashing uController
« Reply #23 on: February 21, 2018, 08:23:33 pm »
Are you using a 24v motor?  I find that 20v are rare.

Doesn't matter. A 24 V PMDC motor will run perfectly on 20 V, just slower. Or on 12 V at half speed. Won't deliver full power, of course.
 
The following users thanked this post: ez24

Online Circlotron

  • Super Contributor
  • ***
  • Posts: 3168
  • Country: au
Re: DC Motor crashing uController
« Reply #24 on: February 21, 2018, 08:47:44 pm »
Those caps across the motor are going to pull a bit of current every time the mosfet turns on, as someone already mentioned. Maybe put 10 ohms in series with each of those caps? Also perhaps increase the mosfet gate resistor to slow down the switching transition, but not so much that the mosfet gets warm.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf