Destroyed 2 arduinos trying to drive high current motor with mosfets. - Page 1
Forum section: electronics / beginners

author: Fresser2
author_rank: Newbie
timestamp: November 30, 2016, 08:32:16 pm
content: I have a dumb question, maybe.I am trying to drive an high current motor (14V,12A) with an mosfet H-bridge and an arduino (Yes i'm such a newbie using arduinoes tsk tsk). I have just roasted two arduinos in a row (CPU getting very hot, and unable to pull digitalpins low (1,8V ish)The N-channel mosfet is connected directly between the digital pins of the arduino to the gate of the mosfet, and the P-channel is driven through an NPN transistor (pulling to ground when turned on) and a pull up resistor. The mosfet bridge is working fine, when i try to control it "manually" with 5v supply, but the arduino keeps getting roasted.I am suspecting some kind of surge (over 5 volts? or under 0?) when turning the mosfets off, due to the capacitance of the gate, but i don't know, and a google search gives me 10 different answer. Some suggest 10k resistors to "isolate" the arduino digitalpins from the gate, but this will result in the arduino being unable to drive the mosfet with PWM right?I am thinking attaching zener diodes to clamp the voltage to 5.1 volts, would that work?I have just purchased my first oscilloscope, but it has yet to arrive, but maybe you guys would have a clue about this without a recording on a scope?If neccessary, i can find a circuit diagram, right now it is just on my other computer which i can't get to right now.

author: linux-works
author_rank: Super Contributor
timestamp: November 30, 2016, 08:36:14 pm
content: do you have a series R from the arduino to the mosfet? you should.

author: Fresser2
author_rank: Newbie
timestamp: November 30, 2016, 08:40:28 pm
content: I should?What value would that be, if i still want to be able to PWM at 500hz?I just suspect that putting a 10k (as a google search suggested?) in series, will limit the current so much, that the mosfet will not charge up before getting turned off again?

author: suicidaleggroll
author_rank: Super Contributor
timestamp: November 30, 2016, 08:53:56 pm
content: 10k is too high. 50-100 ohms would probably be fine, MCUs just don't like driving into dead shorts (which the gate of a discharged mosfet is, at least initially).Also, do you have the necessary freewheel diodes to prevent back-EMF from wreaking havoc on your controller?

author: Fresser2
author_rank: Newbie
timestamp: November 30, 2016, 09:04:47 pm
content: Quote from: suicidaleggroll on November 30, 2016, 08:53:56 pmHmn, that sounds logical.About the diodes, are you thinking about a diode over the motor? Because the mosfets i am using have zener diodes built in, and should protect themselves right?The mosfets i am using is:http://www.infineon.com/dgdl/irf540n.pdf?fileId=5546d462533600a4015355e396cb199fandhttp://www.infineon.com/dgdl/irf5210.pdf?fileId=5546d462533600a4015355e34f331989

author: rstofer
author_rank: Super Contributor
timestamp: November 30, 2016, 09:34:45 pm
content: Have you looked at the requirement for Vgs vs Id (Figure 3 in you first datasheet)?That nonsense earlier in the datasheet about Vgs less than 4.0V only applies when the load is a mere 250 MICROamps!At a minimum, you need a good solid 5V on the gate of the lower MOSFET.It's pretty had to provide any kind of help without a schematic. We're just guessing...

author: Fresser2
author_rank: Newbie
timestamp: November 30, 2016, 09:45:31 pm
content: Quote from: rstofer on November 30, 2016, 09:34:45 pmI must admit that i only looked at the first figure in the datasheet. But the mosfets are working just fine. The arduino can turn them on and off without any trouble. The problem only occurs after a couple of cycles, the arduino fails to pull to ground (leaving 1.8 v for an n-channel mosfet, that turns on already from 1 volt) and thus short circuit the h-bridge.I have found the diagram. The mosfet mentioned in the schematic is not the ones used, but had the same package. (i used the abovementioned)

author: xtoffer
author_rank: Contributor
timestamp: November 30, 2016, 09:50:58 pm
content: I'm not so good with arduinos but I believe they use (or used) AVR MCUs. As a reference the atmega328 have an absolute maximum DC rating of 40mA per pin, and 200mA overall. Can be good to keep in mind to keep the MCU happy. Limited as previously suggested I believe this should be enough for the mosfets but otherwise additional drivers are needed.To me it looks like the body diodes should do for the back EMF buut I'm no expert.

author: bktemp
author_rank: Super Contributor
timestamp: November 30, 2016, 10:03:52 pm
content: Add a low value resistor (~100ohms) between the AVR outputs and Q3+Q4. This should limit the current during turn on/off and protect the pins from voltage transients.But more important: Add a large value (>1000uF), low ESR electrolytic capacitor between +12V and GND!Without any capacitor you will get large voltage spikes whenever you toggle the outputs.I would use a dedicated mosfet driver, because increasing the gate voltage reduces the On resistance and therefore reduces the dissipated power -> smaller heatsink possible.

author: Seekonk
author_rank: Super Contributor
timestamp: November 30, 2016, 10:05:59 pm
content: One of those four channel opto isolator boards for under $2 seems like a prudent purchase.

author: Fresser2
author_rank: Newbie
timestamp: November 30, 2016, 10:19:15 pm
content: Quote from: bktemp on November 30, 2016, 10:03:52 pmI would probably too use a driver. But this is for a school project (we learn to design pcb's and things, very basic so far). Also the motor is on for a whopping 10 seconds each run, and minutes between each run. The n-channel mosfet should be designed for logic level switching tho? So said my teacher at least.But resistors should save the arduino is what i hear? (My school buys the genuine arduinoes, and we are getting expensive hahah)I can't thank you enough for the help so far!

author: bktemp
author_rank: Super Contributor
timestamp: November 30, 2016, 10:34:20 pm
content: Quote from: Fresser2 on November 30, 2016, 10:19:15 pmYes. The threshold voltage for logic level mosfets is typically around 1-2V while the threshold for normal mosfets is somewhere around 3V. And the threshold is the voltage where the mosfets start conducting (<1mA!). For high currents you need a higher gate voltage.QuoteHard to tell without having the full schematic and a picture how you wired everything exactly and duing some measurements.It could be overcurrent, but most microcontroller IOs are fairly tolerant if you short them to GND or Vcc.Therefore my guess is, the arduinos got killed by voltage spikes entering either though the power supply (is the Arduino supplied using the 12V motor supply?) or via the gate driver output pin: When the P channel mosfet turns on, it pulls the output to 12V or even higher for a short time due to parasitic inducance of the wiring.Every mosfet has some drain-gate capacitance. This capacitance can couple the high voltage spike from drain into gate of the N channel mosfet and then into the IO pins, destroying the microcontroller. A series resistor should limit the current and reduce the risk.You can do some measurements to verify if there are voltage spikes higher than the logic levels.

author: danadak
author_rank: Super Contributor
timestamp: November 30, 2016, 11:34:22 pm
content: For test purposes add 100 ohms in series with outputs. Using a DSO,set trigger up for two cases, one Vdd + .7, the other Vss - .7, one shottrigger, and go poking around pins to see where the transients are andwhat they look like. For problem pins use diode clamps on the pins toinsure Vdd >= Vpin >= Vss.Supply pins, I/O pins, all susceptible.Sounds like you are triggering parasitic SCR in all CMOS and that in turnshorts out supply rails inside part, which at minimum will overheat part,worst case melt silicon and/or open supply bond wires inside part.Regards, Dana.

author: mjkuwp
author_rank: Unknown
timestamp: December 01, 2016, 03:11:50 am
content: Quote from: suicidaleggroll on November 30, 2016, 08:53:56 pmemphasis is mine - do you have diodes in place to allow current to continuously flow through the motor?

author: bktemp
author_rank: Super Contributor
timestamp: December 01, 2016, 06:09:45 am
content: Quote from: mjkuwp on December 01, 2016, 03:11:50 amLook at his schematic: Every mosfet has a build in parasitic diode.They may not be the fastest ones, but they will work as freewheeling diodes, clamping the voltage to GND or +12V rail.

author: Ian.M
author_rank: Super Contributor
timestamp: December 01, 2016, 06:48:23 am
content: The parasitic body diodes will do for freewheeling as long as you don't use HF PWM for motor speed control. If you want to do that, add high current Schottky diodes in parallel to each.Use a MOSFET driver - the common emitter level translator sucks and the drive to the lower MOSFETs is also inadequate. You'll probably want 10R 'gate stopper' resistors, as close to the MOSFET gate pins as possible to control the slew rate to reduce EMI, and prevent HF ringing.As mentioned above, you'll need a large decoupling cap across the H-Bridge supply.However the most critical and most likely cause of problems is poor ground layout, and large loop area of the supply wiring and H-bridge output wiring. A 12A motor probably has a stall current of the order of 100A, and that's what the H-Bridge has to switch when starting the motor from stopped. Even 0.1R of wiring resistance in the wrong place could result in enough ground bounce to transiently reverse the ATmega328P's 5V supply. The *ONLY* common connection between Arduino GND and the negative side of the 12V supply for the motor should be at the gate driver.Google: Star Grounding. N.B. the USB cable introduces a ground from the PC to the Arduino - if you need to run the motor with the Arduino connected to a PC you will need to connect the cable shield to the star ground point with the shortest possible heavy ground strap.Supply wiring should be loosely twisted with its corresponding ground return to minimise loop area, as should be the motor wiring.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: December 01, 2016, 08:41:16 am
content: Quote from: bktemp on November 30, 2016, 10:03:52 pmBest answer. Gate driver or optoisolator between AVR output pin and mosfet gate. 10-100 ohm gate resistor. Large cap across the 12V.

author: RenE3
author_rank: Newbie
timestamp: December 01, 2016, 04:54:30 pm
content: I would use an optoisolator and external protective diodes like everyone says.http://www.next.gr/uploads/5/DRIVERMOSFET.jpg

author: tatus1969
author_rank: Super Contributor
timestamp: December 01, 2016, 05:11:14 pm
content: when you toasted your arduinos, were you using the same 5v supply for both micro and motor?

author: bktemp
author_rank: Super Contributor
timestamp: December 01, 2016, 06:00:42 pm
content: Quote from: RenE3 on December 01, 2016, 04:54:30 pmDon't use this circuit, it is even more crap than the original one!If you drive N+P channel mosfets using the same gate drive signal without any dead time you generate a large current spike whenever the gate voltage is somewhere between GND and +12V. Then both mosfets will be turned on and short the +12V rail to GND! Without any capacitance at the 12V rail the parasitic inductance will generate large voltage spikes destroying anything that can't handle the high voltage after one of both mosfets has turned off again.Because the people who design those bad circuits have no idea what they are doing they simply add optocouplers to prevent the voltage spikes destroying everything instead of solving the actual problems.

author: Fresser2
author_rank: Newbie
timestamp: December 07, 2016, 11:57:18 am
content: Just wanted to add what i did to the circuit, to make it work flawlessly.I added 2 470µF capacitors on the input 12v and ground.I added 110 ohms resistor between arduino pins and n-channel gates.Although, i don't think this was the issue for the arduino getting destroyed.The motor i was driving, also had a rotation sensor built in. One of the leads of this rotation sensor was grounded to the chassis of the motor. So was one of the motors inputs. So when we tried to turn the motor in the direction, where the chassis got 12v, we essentially putted 12v into the arduino digitalpins. I think this was the main issue, and i solved that, by removing the grounding connection on the rotation sensor inside the motor. (car wiper motor)and then i got my oscilloscope after doing all this work. I listened between ground and arduino digital pin, and it was almost perfect, with 500hz pwm. Minimal over and undershoot. (which continued even if the pin was not connected to the circuit).So i think it is fixed for good now.

author: janoc
author_rank: Super Contributor
timestamp: December 07, 2016, 05:23:42 pm
content: I strongly suggest that you swap those mosfets for logic level ones or use a driver. A good driver could help you eliminate the P-channel mosfets too and let you use N-channel one for everything.The way to see whether or not a mosfet is a logic level one is toNOTlook at the threshold voltage in the datasheet but at what Vgs are the electrical characteristics specified. If they are only @10V, that is not a logic level part - you will need to drive it with ~10V on the gate to make it conduct fully.Logic level mosfets have characteristic (e.g. RDSon) specified at 4-5V as well. E.g. compare IRFZ44n (normal FET) vs IRLZ44n (logic level FET).The threshold voltage is the voltage when the part turns off, not when it is usefully conducting! If you don't open the transistor completely, it will be getting very hot very quickly and likely blow up with larger loads. Your FETs were "working" because IRF540n can pass 10A even at its threshold voltage, which was likely sufficient for the motor you had. But that is far from a good design.

author: RoGeorge
author_rank: Super Contributor
timestamp: December 07, 2016, 07:03:00 pm
content: Fresser2, you may want to read these:Byte and Switch (Part 1) and (Part 1) by Jason Sachshttps://www.embeddedrelated.com/showarticle/77.phphttps://www.embeddedrelated.com/showarticle/81.php

author: suicidaleggroll
author_rank: Super Contributor
timestamp: December 07, 2016, 07:44:40 pm
content: Quote from: janoc on December 07, 2016, 05:23:42 pmA decent rule of thumb is you need to drive the gate to at least 2x Vgs(th). The IRF540n has a nominal Vgs(th) of around 3V, max of 4V. This means you should be driving the gate with at least 8V to guarantee it'll work well, but you might be able to go lower if you hand-pick a device out of a batch that has a threshold closer to nominal or min.

author: janoc
author_rank: Super Contributor
timestamp: December 08, 2016, 09:26:51 pm
content: Quote from: suicidaleggroll on December 07, 2016, 07:44:40 pmAn even better solution is looking at the characteristics in the datasheet. The plots are fairly explicit, IMO.

author: suicidaleggroll
author_rank: Super Contributor
timestamp: December 09, 2016, 01:35:21 am
content: Sure, but you can't sort or filter the thousands of fets on a distributor's site by datasheet plots. You can filter by Vgs(th). If you know your drive voltage, cut it in half and look for fets with a Vgs(th) at or below that number.

author: RoGeorge
author_rank: Super Contributor
timestamp: December 09, 2016, 04:58:14 am
content: Quote from: suicidaleggroll on December 09, 2016, 01:35:21 amOr, just lower the transistor's Vgs(th) like this:https://hackaday.io/project/16616-your-mosfet-is-not-good-enough-then-modify-it

author: BloodyCactus
author_rank: Frequent Contributor
timestamp: December 09, 2016, 01:46:02 pm
content: If your connecting this to arduino, I'd use IRL540 instead of IRF540. IRL is logic level, can be triggered by the arduino just fine, IRF need a driver like MCP1407 (which I love using!). Arduino doesnt have the current to drive IRF properly. Get IRL540 instead.

author: janoc
author_rank: Super Contributor
timestamp: December 09, 2016, 03:03:58 pm
content: Quote from: suicidaleggroll on December 09, 2016, 01:35:21 amMost distributors permit filtering for logic FETs already. E.g. Digikey, filter by FET Feature, select Logic Level Gate, you can even choose the voltage.

author: suicidaleggroll
author_rank: Super Contributor
timestamp: December 09, 2016, 04:02:50 pm
content: Quote from: janoc on December 09, 2016, 03:03:58 pmWhich knocks out a significant number of options that are "logic level" but aren't classified as such on the distributor's site. I used that logic level filtering feature on Digikey's site all of one time, and quickly realized that using 2x Vgs(th) was a far better option for finding suitable parts.

author: tatus1969
author_rank: Super Contributor
timestamp: December 09, 2016, 04:10:06 pm
content: Quote from: janoc on December 08, 2016, 09:26:51 pmLook at the max Rdson spec in the datasheet. If that says, for example, 1mOhm max at Vgs=5V, then you can expect this as a worst case value at room temperature. Then combine this with the Rdson vs temperature graph (normally a multiplier), and you get a final value and can calculate the static power dissipation.

author: Ian.M
author_rank: Super Contributor
timestamp: December 09, 2016, 07:51:17 pm
content: While the diversion into finding logic level MOSFETs in distributors' parametric search pages is interesting, and useful to many of us, it is of little use to the O.P. and their 14V, 12A motor.Logic level MOSFETs without a proper H-bridge driver with dead-band control will make the O.P.'s problems worse as they will drastically increase the shoot-through current spikes, and if you use a H-bridge driver, from a 12 or 14V rail, you'll have plenty of gate drive for ordinary MOSFETs.

author: janoc
author_rank: Super Contributor
timestamp: December 10, 2016, 11:43:20 pm
content: Quote from: Ian.M on December 09, 2016, 07:51:17 pmEven ATMega/ATTiny timers have support for things like generating dead time for driving H bridges, if I remember right, at least on some AVRs (ATTiny85 for sure). Alternatively, you can do it in software by simply moving the output compare values a little, as described in this app note from Atmel:http://www.atmel.com/Images/doc8010.pdfSo you really don't need to use a driver only for the dead time generation.Of course, driver would be useful for making sure the FET turns on and off quickly, the MCU pin driver may not be able to source/sink sufficient current.