Issues powering a motor with ATTiny and MOSFET transistor

Thread Starter

awwwt

Joined Aug 24, 2015
60
Hi everyone,

I have a question regarding my project involving an ATTiny85 and a motor. I am trying to switch a motor on and off in various patterns. I have this part working with an LED (basically the Arduino Blink sketch), however when I switch to using a motor with a MOSFET transistor, the ATTiny begins to behave strangely, switching off / on randomly, the clock slows down etc.

When the issue occurs, I have been using 2 x AA batteries (3v). The issue resolves itself when I use a 3.7v 1000mA LiPo battery, however this does not suit my project and I would like to figure out the issue, because I am pretty sure the AA batteries should work?!

The ATTiny is rated at 3v / 3.6mA and the motor is also 3v and consumes around 300mA (stall current 680 mA). There is a diode across the motor wires.

Another thing to add: The MOSFET is in the circuit being switched by the ATTiny, however I split the same power supply to be used with both the ATTiny and the MOSFET together (please see my diagram attached). I would ideally like to use the same power supply and not have two separate supplies (my project requires limited space, and I cannot use 4x AA batteries) but I am unsure whether this is a reliable way of using a MOSFET, or if there are alternatives? Is an NPN transistor a better shout? (I am not aware of the differences between NPN transistor and MOSFET as they seem to operate very similarly...)

I assume this is a power consumption issue, and perhaps the motor causes a spike in current that upsets the ATTiny? Is there any way to resolve this or any advice on the design of my circuit?

I hope this is is all understandable. I am new to electronics at this level so any tips or lessons would be much appreciated :)

Thank you!
 

Attachments

AlbertHall

Joined Jun 4, 2014
11,587
Do you have decoupling capacitors across the supply? An electrolytic, perhaps 470uF, and a ceramic 100nF. It would also be a good idea ro put a ceramic 100nF as close as possible across the motor terminals.
 

crutschow

Joined Mar 14, 2008
28,152
If what Albert suggested doesn't work, then put a small resistor (say 100Ω) in series with the power to the Attiny and then connect a 470μF capacitor from the Attiny power pin to ground.
 

Thread Starter

awwwt

Joined Aug 24, 2015
60
Do you have decoupling capacitors across the supply? An electrolytic, perhaps 470uF, and a ceramic 100nF. It would also be a good idea ro put a ceramic 100nF as close as possible across the motor terminals.
Thanks so much for this! I will buy these components tomorrow and have a try. Cheers!
 

Thread Starter

awwwt

Joined Aug 24, 2015
60
Do you have decoupling capacitors across the supply? An electrolytic, perhaps 470uF, and a ceramic 100nF. It would also be a good idea ro put a ceramic 100nF as close as possible across the motor terminals.
Hi Albert, just to update - the circuit seems to work perfectly with two 100nF ceramic capacitors, one across the power supply and one across the motor terminals.

I was wondering if you or anyone could explain why the capacitors are needed and what they are doing? I would be really interested to learn.

Thank you !
 

dl324

Joined Mar 30, 2015
13,489
I was wondering if you or anyone could explain why the capacitors are needed and what they are doing? I would be really interested to learn.
100nF caps would provide high frequency decoupling, but not much relief from power sag; that's what the larger cap would have provided.
 

AlbertHall

Joined Jun 4, 2014
11,587
Hi Albert, just to update - the circuit seems to work perfectly with two 100nF ceramic capacitors, one across the power supply and one across the motor terminals.

I was wondering if you or anyone could explain why the capacitors are needed and what they are doing? I would be really interested to learn.

Thank you !
Brushed motors generate lots of electrical noise and the capacitors reduce that and stop it interfering with the rest of the circuit.
 

crutschow

Joined Mar 14, 2008
28,152
There is a small amount of arcing at the contact point between the brushes and commutator when the motor is running.
That's what generates a large amount of electrical noise and EMI.
You have a small spark-gap transmitter. ;)
 

Nidhi Shah

Joined Aug 11, 2019
1
Tried using crutschow's solution. The capacitor ran for 5 sec according to our attiny84 program and then completely stopped working . What could have gone wrong
 

djsfantasi

Joined Apr 11, 2010
7,911
The fritzing circuit posted can’t work. That’s why I hate fritzing. What is actually going on is hard to see. I recommend you learn how to use schematics.

For example, the 10K resistor isn’t connected to anything. And the MOSFET Source also isn’t connected to anything!

Can you show how it really is wired? ...With the added capacitors, too.
 

danadak

Joined Mar 10, 2018
4,057
Battery capacity -

http://www.jmargolin.com/furnace/Ultra-Power_AA_MX1500.pdf

I think the AA cells lite for supplying the motor and holding up adequate
buss V.


Bypassing, not all cap technologies have good ESR -



From datasheet -

• Keep analog signal paths as short as possible.
• Make sure analog tracks run over the analog ground plane.
• Keep analog tracks well away from high-speed switching digital tracks.
• If any port pin is used as a digital output, it mustn’t switch while a conversion is in progress.
• Place bypass capacitors as close to VCC and GND pins as possible
Yes, a couple near the ATtiny85 between Vcc and GND pins. The TMP36 datasheet does recommend a 100nF bypass (decoupling) capacitor across those pins to reduce radio frequency interference.
You would of course also use a bulk cap on Vdd pin, polymer tant
or MLCC best....



If you have a DSO look at power rails, setting trigger one diode
drop above Vdd, one diode below Vss, and see if you get any triggers.

Put scope on infinite persistence looking at Vdd rail to see what pk-pk noise is.

MOSFET gate to ATTINY should have 50 - 200 ohms to help suppress inductive
transients. Use your DSO again to look at the pin feeding R to gate. Even with
split supply transient feedthru Cgd could affect the ATTINY. And if the diode
you are using to clamp transients not very fast thats a recipe for dumping charge
into processor substrate and crazy stuff will happen.


Regards, Dana.
 
Last edited:
Top