Atmega328 keeps resetting itself if I start PWM

Thread Starter

sumeryamaner

Joined May 29, 2017
114
An update after a short break...

Now I am almost sure that there is a problem with my circuit and/or PCB setup.

I made a new prototype PCB. I replaced the IRFZ44 MOSFETs with IRLZ44 logic level counterparts. I used 75 ohm gate resistors and 47 k resistors from the gate to GND. Just for testing purposes I used a small electric motor which draws about 100 - 150 mA. This motor has 100 nF caps between the terminals and the case.
I wrote a short code which reads a rotary encoder and sets the PWM output to the motor from 0 to 255. The motor starts turning at about 15 - 20 PWM and as soon as the motor starts turning the MPU resets or hangs.
Then I grabbed an Arduino Uno and built the same setup on a breadboard. That means the same PWM pin (Arduino 6), 75 ohms gate resistor, 47 k GND resistor, IRLZ44 MOSFET, a similar rotary encoder and the same motor. Uploaded the same code and it works without any problems!!!
You can see my board and the motor on the photo (the two Schottky diodes are under the PCB. Don't bother for the two thin wire bridges. They will be replaced by thicker ones in the final product.).
This motor is a very low power mtor and even if it would be short circuited, it is impossible for the power supply to collapse.
You can see the PCB layout on the other photo.2019-06-04 11.22.55.jpg AAC.jpg

I am really confused. This is not my first project using an AVR directly instead of an Arduino board. Actually I have more than 25 projects using Atmega328 or Attiny85 and they are working in my RC aricraft for years now without any problems. But now I really need help...
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
Update to the update: :)

As the 16 MHz crystal is in the vicinity of the two MOSFETs (one for the glow plug and one for the starter motor) I thought there might be an interference to the crystal. So I reprogrammed the chip for internal 8 MHz operation leaving the crystal out of the game. Nothing changed.
 

danadak

Joined Mar 10, 2018
4,057
I cannot remember if you answered this, do you have a DSO capable
of one shot triggering. Basically you set up for level triggering, ~ 1
diode drop outside each rail, and look at pins one at a time after
initiating PWM activity. Maybe use code and button push to initiate
this. This will capture any transient outside rails and will ID pin this is
occurring on.

Regards, Dana.
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
I cannot remember if you answered this, do you have a DSO capable
of one shot triggering. Basically you set up for level triggering, ~ 1
diode drop outside each rail, and look at pins one at a time after
initiating PWM activity. Maybe use code and button push to initiate
this. This will capture any transient outside rails and will ID pin this is
occurring on.

Regards, Dana.
I will try this. In the meantime I tried something else. I put two 1000 uF capacitors between V+ and GND near the MOSFETs. Now there is no problem with motors. As all of my glow plugs are burnt out now, I couldn't try it with a glow plug but instead I shorted the glow plug leads and activated PWM (for a short time). There was no problem! :)
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
Did you get round to trying the series inductor as Bob suggested in post #54?
Not yet. The series inductor was meant for the glow plug driver. I don't have a functional plug at hand right now and I don't have an appropriate inductor (these days we are in a religious holiday in Turkey) so I will do it later.
 

danadak

Joined Mar 10, 2018
4,057
Keep in mind C effectiveness one technology to another significant
in terms of ESR performance. So you might be able to use polymer
tants or MLCC and with a lot less C get the job done.



You can see polymer tant, for same C value, is ~ 2 orders of magnitude
better than wet aluminum, MLCC ~ 3 orders of magnitude better.


Regards, Dana.
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
Keep in mind C effectiveness one technology to another significant
in terms of ESR performance. So you might be able to use polymer
tants or MLCC and with a lot less C get the job done.



You can see polymer tant, for same C value, is ~ 2 orders of magnitude
better than wet aluminum, MLCC ~ 3 orders of magnitude better.


Regards, Dana.
I will keep that in mind. Thank you very much.
 

cmartinez

Joined Jan 17, 2007
8,253
I will try this. In the meantime I tried something else. I put two 1000 uF capacitors between V+ and GND near the MOSFETs. Now there is no problem with motors. As all of my glow plugs are burnt out now, I couldn't try it with a glow plug but instead I shorted the glow plug leads and activated PWM (for a short time). There was no problem! :)
o_O ... very, very interesting ... why does that setup sound so familiar to me? .. :rolleyes:
 

cmartinez

Joined Jan 17, 2007
8,253
Really interesting... Especially, while using separate supplies doesn't cure the problem, adding two big caps does... Now the board is full of caps...
That's because caps are capable of a much faster response time than a battery or an power supply lacking a strong enough filter. This might be a good time to reconsider what I proposed earlier. To make sure that both circuits are completely isolated, and to add a big fat cap preceded by a diode to the control circuitry's power intake.
 

BobTPH

Joined Jun 5, 2013
8,963
You are not using the star configuration for power and ground. If I am guessing the connections correctly, it looks like the path of ground to the micro is very convoluted and shares the entire path for the glow plug. I would expect this board to fail.

Also, when you substituted a motor did you use a free-wheeling diode? Omission of that is also asking for failure.

Bob
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
You are not using the star configuration for power and ground. If I am guessing the connections correctly, it looks like the path of ground to the micro is very convoluted and shares the entire path for the glow plug. I would expect this board to fail.

Also, when you substituted a motor did you use a free-wheeling diode? Omission of that is also asking for failure.

Bob
The diode is there... As I will be using a series conductor for the glow plug, there is alsa a diode.
During the earlier phases I had soldered additional thick wires which didn't cure the problem (See post # 8).
 

BobTPH

Joined Jun 5, 2013
8,963
The star ground and power with tank capacitor at the incoming power connections is standard on any board I design if there are anything but low powered devices. You should get into that practice. It will save you lot's of headaches.

Without the buck converter limiting the current, you were WAY exceeding the current capacity of the PCB tracks, the connectors, and even connecting wires to the glow plug. With the buck converter it should be limited to 3 or 4 Amps, which at least a lot better. Minimally, you should have a completely separate track for the glow plug (and any other high power devices) and a different path for the micro and other logic.

Bob
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
A short update...
Today I was at the flying field and found a working glow plug. I tested the circuit with the glow plug but without the inductor (with the Schottky diode in place). It worked fine. But I have ordered appropriate inductors and when they arrive I will solder one in place.
 

BobaMosfet

Joined Jul 1, 2009
2,113
Really interesting... Especially, while using separate supplies doesn't cure the problem, adding two big caps does... Now the board is full of caps...
This isn't rocket-science. Look at my post (#6). If you don't have an oscilloscope, get one. Learn what the relationship between voltage and current is so you know what it's telling you.
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
This isn't rocket-science. Look at my post (#6). If you don't have an oscilloscope, get one. Learn what the relationship between voltage and current is so you know what it's telling you.
Really? Is there a relationship between voltage and current?! Very interesting... Thanks a lot...
But...
The oscilloscope does not show any voltage drop. This is not related to dropping voltage in my opinion. It should be EMI which is being damped / filtered by the big caps.
 

BobTPH

Joined Jun 5, 2013
8,963
How does a glow plug create EMI? Look at the traces on your PCB. How much voltage drop is there across them when they carry 50A?

Large electrolytic capacitors are very good at fighting voltage drop, not at suppressing EMI. You need smaller low ESR caps for that.


Bob
 

BobTPH

Joined Jun 5, 2013
8,963
True, but they should be suppressed by decoupling caps on the micro.

The inductance of the wires traces also comes into play when you try to switch 50A.

I did a quick calculation based on the length and size of traces and came up with a 1.4V drop when carrying 50A from resistance alone.

I don't think the TS understands how extreme it is to be switching 50A on a PCB trace. This is why I suggested modifying it to buck topology to keep the currents reasonable.

Bob
 
Top