Atmega328 keeps resetting itself if I start PWM

BobTPH

Joined Jun 5, 2013
11,557
So, even if you draw 51 or 151 Amps from the battery No:2 this cannot influence the battery No:1. Am I wrong?
If the battery can supply that current without dropping much yes. But I seriously doubt that is the case. You said before that the battery could supply 50A. Battery packs of this kind are highly likely to have an overcurrent protection circuit. If your battery has a limit of 50A you could easily be tripping the protection circuit. I suspect that is exactly what is happening.

The other problem is that drawing large currents from a battery WILL drop the voltage. What kind of a 5V regulator do you have? If it is a standard 7805 type regulator, it needs 7V to regulate. So, you are right on the edge of supplying enough voltage to the regulator with your 7.4V battery. Drawing 50A would certainly drop the voltage to the regulator enough to stop it regulating. You might get away with it with sufficient capacitance, but this is not a robust design.

Bob
 

Thread Starter

sumeryamaner

Joined May 29, 2017
117
If the battery can supply that current without dropping much yes. But I seriously doubt that is the case. You said before that the battery could supply 50A. Battery packs of this kind are highly likely to have an overcurrent protection circuit. If your battery has a limit of 50A you could easily be tripping the protection circuit. I suspect that is exactly what is happening.

The other problem is that drawing large currents from a battery WILL drop the voltage. What kind of a 5V regulator do you have? If it is a standard 7805 type regulator, it needs 7V to regulate. So, you are right on the edge of supplying enough voltage to the regulator with your 7.4V battery. Drawing 50A would certainly drop the voltage to the regulator enough to stop it regulating. You might get away with it with sufficient capacitance, but this is not a robust design.

Bob
OK, a last attempt... :)

Please look at the circuit below.

Is it possible, to collapse the voltage of the Battery 1 by drawing a high current from the Battery 2?

Thank you...

P.S.: The usual RC batteries do not have a protection circuitry in them and it is of course true that the battery voltage will drop to a certain amount if you draw a too high current.
 

Attachments

cmartinez

Joined Jan 17, 2007
8,786
OK, a last attempt... :)

Please look at the circuit below.

Is it possible, to collapse the voltage of the Battery 1 by drawing a high current from the Battery 2?

Thank you...

P.S.: The usual RC batteries do not have a protection circuitry in them and it is of course true that the battery voltage will drop to a certain amount if you draw a too high current.
The batteries are sharing grounds ... inevitably any EMI produced by one circuit will travel to the other one. What I do is use a DC to DC converter so as to split those grounds, and then use an opto to trigger the mosfet's driver (I don't see one in your schematic).
 

BobTPH

Joined Jun 5, 2013
11,557
Okay, I missed that fact that you had separated the batteries. In that case, it is most likely EMI caused by switching these huge currents. In which case, using a switching regulator to lower the voltage to the glow plug instead of using PWM would still fix the problem. For that matter, putting a properly sized inductor in the path the glow plug would make it a switching regulator and probably also fix the problem.

What is your PWM frequency? With that I could model the circuit to come up with the value of the inductor.

Bob
 

Thread Starter

sumeryamaner

Joined May 29, 2017
117
The batteries are sharing grounds ... inevitably any EMI produced by one circuit will travel to the other one. What I do is use a DC to DC converter so as to split those grounds, and then use an opto to trigger the mosfet's driver (I don't see one in your schematic).
We are discussing something else right now. :) Not the EMI. Voltage drop to the MCU. Is it possible? We will talk about EMI later. Thank you...
 

Thread Starter

sumeryamaner

Joined May 29, 2017
117
Okay, I missed that fact that you had separated the batteries. In that case, it is most likely EMI caused by switching these huge currents. In which case, using a switching regulator to lower the voltage to the glow plug instead of using PWM would still fix the problem. For that matter, putting a properly sized inductor in the path the glow plug would make it a switching regulator and probably also fix the problem.

What is your PWM frequency? With that I could model the circuit to come up with the value of the inductor.

Bob
The PWM frequency is 980 Hz. The same circuit is working in my portable and onboard glow drivers witohut any problems for a couple of years. They use an Attiny85 as the MCU. I really would like to try it with an inductor because the problem seems not to be a voltage collapse problem but an EMI problem due to fast switching of a high current.
 

cmartinez

Joined Jan 17, 2007
8,786
We are discussing something else right now. :) Not the EMI. Voltage drop to the MCU. Is it possible? We will talk about EMI later. Thank you...
ooooookey... I'll just stand here by the sideline and wait how this whole thing develops ... I too, am interested on seeing how you solve this ... good luck!
 

Thread Starter

sumeryamaner

Joined May 29, 2017
117
ooooookey... I'll just stand here by the sideline and wait how this whole thing develops ... I too, am interested on seeing how you solve this ... good luck!
I have already solved (?) it using 1k gate resistors and the system works OK for now. I have written a great (! :) ) piece of code too. But I have to confess that I am interested too. :)
 
@sumeryamaner I appreciate you giving the update. It's frequently the case that you get newcomers to the thread and so on where you have to restate some things. That's to be expected and yeah, you have to go along with it because, well, because you are the one with the project...your English is fine.

I do hope this keeps going as I enjoy the thread as an excellent learning opportunity. As noted earlier, I participated in a couple of your early threads (to this day I can't duplicate that first read A2D error).

You will get it working.
 

Thread Starter

sumeryamaner

Joined May 29, 2017
117
@sumeryamaner I appreciate you giving the update. It's frequently the case that you get newcomers to the thread and so on where you have to restate some things. That's to be expected and yeah, you have to go along with it because, well, because you are the one with the project...your English is fine.

I do hope this keeps going as I enjoy the thread as an excellent learning opportunity. As noted earlier, I participated in a couple of your early threads (to this day I can't duplicate that first read A2D error).

You will get it working.
Thank you for your kindness... But I am waiting for the inductor suggestion... :)
 

cmartinez

Joined Jan 17, 2007
8,786
I have already solved (?) it using 1k gate resistors and the system works OK for now. I have written a great (! :) ) piece of code too. But I have to confess that I am interested too. :)
And I too, thought I had solved my problem using 1.5k resistors at the gate... only to find that the problem had been diminished, but not completely gone
 

BobTPH

Joined Jun 5, 2013
11,557
Here you go. To make it a buck converter, you need to add an inductor and a Shottky diode rated at 5A.
1mH is a fairly large inductor due to your low PWM frequency, and it still has a ripple of about an Amp, which is not a problem for the glow plug.

Note that this circuit reduces the max draw from the battery to about 4A, a far sight better than 50.

Note also, that this simulation gets an average current of about 3.2A assuming as resistance of 0.3 Ohms for the glow plug, which corresponds to the voltage and current you mentioned before.

Third note, the duty cycle has been set at 200u / 1020u or 0.19 or 50 / 255 to get the approximate current you want.

upload_2019-5-30_16-9-38.png
 
Last edited:

MrSoftware

Joined Oct 29, 2013
2,273
If you don't have a scope, but like projects like this, a scope might not be a bad investment. You could scope the gate pins and other pins on the processor to see if you're getting any spikes, perhaps caused by EMI. Just be careful about using the half circle probe clips as they can be great antennas for EMI and spikes you see might actually be caused by those clips picking up the EMI. The pointy end of the probe is better in cases where EMI can be an issue. Great project by the way, I'm pulling for you. :)
 

Thread Starter

sumeryamaner

Joined May 29, 2017
117
If you don't have a scope, but like projects like this, a scope might not be a bad investment. You could scope the gate pins and other pins on the processor to see if you're getting any spikes, perhaps caused by EMI. Just be careful about using the half circle probe clips as they can be great antennas for EMI and spikes you see might actually be caused by those clips picking up the EMI. The pointy end of the probe is better in cases where EMI can be an issue. Great project by the way, I'm pulling for you. :)
Thank you very much. I already have a scope (of course not a professional one) but I have been too lazy to connect it to the circuit (because I doubt that it would show eventual spikes :) ). I will try it.
 

Thread Starter

sumeryamaner

Joined May 29, 2017
117
Here you go. To make it a buck converter, you need to add an inductor and a Shottky diode rated at 5A.
1mH is a fairly large inductor due to your low PWM frequency, and it still has a ripple of about an Amp, which is not a problem for the glow plug.

Note that this circuit reduces the max draw from the battery to about 4A, a far sight better than 50.

Note also, that this simulation gets an average current of about 3.2A assuming as resistance of 0.3 Ohms for the glow plug, which corresponds to the voltage and current you mentioned before.

Third note, the duty cycle has been set at 200u / 1020u or 0.19 or 50 / 255 to get the approximate current you want.

View attachment 178578
Thank you very much. I have added a series inductor of about 1.5 mH to the glow plug. As I didn't have a Schottky diode at hand I used a 1N4001. I tried to test this setup using a 75 ohm gate resistor but I immediately burnt out the glow plug (the PWM value was set too high). I didn't have time to repeat the test with a new glow plug and I reverted to the 1k gate resistor because today was our test day. My friend who built the turbine came from a very long way (about 150 miles) just for testing.
Good news: The tests were satisfactory. :)

Now a question: This schematic with the series inductor and the Schottky diode is actually a buck converter right? So... If we connect a DC motor instead of the glow plug which has a significant inductance, do we need the series inductance? (This can be a stupid question,so please appologize).
 

BobTPH

Joined Jun 5, 2013
11,557
It is indeed a buck converter.

A motor will probably be fine with just PWM, that is how they are normally run.

The problen with the glow plug, I think, is the huge current it drew during the on period to get the desired average current 17 times smaller than it would get directly from the battery.

Bob
 

Thread Starter

sumeryamaner

Joined May 29, 2017
117
It is indeed a buck converter.

A motor will probably be fine with just PWM, that is how they are normally run.

The problen with the glow plug, I think, is the huge current it drew during the on period to get the desired average current 17 times smaller than it would get directly from the battery.

Bob
And the series inductor is supposed to limit the large inrush current. Right?
 

BobTPH

Joined Jun 5, 2013
11,557
Yes, that is one way to look at it.

Each time the PWM turns on, the current rises. When the PWM turns off, the current continues to flow though the diode and it falls off.

Note that the diode needs to carry all of the current. You need a 5A diode there.

Bob
 
Top