ATtiny85 controlled MOSFET circuit guidance

After some (read; MANY of pages and videos) research, I’ve learned most of the basics.

In the attachment, is the schematic I have managed to make.

How it should work:

A 12v battery supply is used for the motor, and the ATtiny85 is powered via a LM7805 5v regulator.
The MOSFET for switching the motor is IRF1324IBF, but it needs minimum 10v(not 5v logic) for the gate. The ATtiny85 controls the MOSFET via a transistor.
The motor is NOT going to be PMW controlled for now.

To protect the regulator and MOSFET from the EMF spike the motor creates when “turned off”, a (schottky) flyback diode is set in parallel, reversed-biased.

The reason for using an ATtiny85, is so I can detect the Voltage-drop when the motor start, and thus counting the amounts the motor has started. A simple voltage-divider is used to get the voltage from 12v to a readable ~5v signal. The accuracy is irrelevant, because only the sudden drop of voltage is important for me to detect.
Why not using the switch for controlling the MOSFET to count? I hear you say! Well, in most cases the switch(and my MOSFET here) will not turn the motor ON and OFF, but a completely different MOSFET will do the job for me. My MOSFET will mostly be used only to stop the motor after X amounts of startups.

So, my questions:

  • Does this look like somthing that wont blow up in a moment? my main concern is the spike from a collapsing magnetic field, and the MOSFET operation.

  • How to find a appropriate transistor for driving the MOSFET. the MOSFET datasheet said: Gate-to-Source Forward Leakage = 200nA, Is the current draw for the gate realy that low?

Current-draw is not realy that important now, as the operating-time only will be 2-4 hours at a time, and it will be close to nothing compared to the motor current-draw.

As I think have all the components to make a ArduinoUNO “prototype”, but only have a limited amount of the diode and MOSFETs, and don’t want to destroy my UNO, I hope to not blow things up yet :stuck_out_tongue_closed_eyes:

And as this was my first schematic in over 2 years (and then, only super-basic ohms-law circuits), don’t hesitate to criticize bad habits.

The voltage divider you are using to detect the motor startup will only work if the power supply is inadequate. Drop the divider to the other side of the motor, and when the fet starts to conduct the divider voltage will drop. Remember the input/output capacitors on the regulator.

The NPN transistor is used an emitter follower. The emitter of an NPN transistor is always ~0.7volt lower than the base. With 5volt from the ATtiny at the base, there is ~4.3volt left for the gate. Not enough to turn this non-logic level mosfets properly on. It will be partially on, and could get very hot and blow it's top.

You need a PNP level shifter between the NPN transistor and the mosfet. Or, better, a proper mosfet driver chip. Leo..

tinman13kup: The voltage divider you are using to detect the motor startup will only work if the power supply is inadequate.

The battery (11,1v LIPO) is good for delivering 100A, but because no battery is perfect (internal resistance) a voltage-drop is unavoidable, even if the battery can deliver the current.

I'v testet with only a simple multimeter, and even when the motor not is under load, the voltage-drop is visible for a moment (drops from 12,4v to 10,8 or something like that) . Have yet to test with an arduino/or ATtiny, but I am rather confident it will work.

Didn't think of the capacitors, will update the schematic tomorrow. Kinda late here in Norway now, 04:17 at night :o 8)

Wawa: You need a PNP level shifter between the NPN transistor and the mosfet. Or, better, a proper mosfet driver chip. Leo..

Have yet to touch a MOSFET driver myself, so yea. Looks like a much better, easier and more practical solution to just go for a MOSFET driver...

Looks like I have to do some research to find a suitable driver for my FETs, ty for the input.

jallafish:
The ATtiny85 controls the MOSFET via a transistor.
The motor is NOT going to be PMW controlled for now.

This is a better way of driving the MOSFET

Note that a HIGH on the pin turns the motor OFF, the R2 pullup ensures the motor stays off while the processor is booting up.

Yours,
TonyWilk

P.S. This circuit is probably too slow for use with PWM. When you get around to that you should look at a mosfet driver.

MOSFET_drive.png

TonyWilk: This is a better way of driving the MOSFET |500x313

Note that a HIGH on the pin turns the motor OFF, the R2 pullup ensures the motor stays off while the processor is booting up.

Yours, TonyWilk

P.S. This circuit is probably too slow for use with PWM. When you get around to that you should look at a mosfet driver.

I have a hard time figuring out how that works. I assume the 10k between +12 and Gate still will keep the gate "turn on"?

And does the pins go HIGH when Arduino boots up? Because I can't risk the mosfet turning on while booting up, so really appreciate that tip.

jallafish:
I have a hard time figuring out how that works. I assume the 10k between +12 and Gate still will keep the gate “turn on”?

Yes, the 10k (R1) pulls up the gate to turn on the MOSFET.
The transistor Q1 turns off the gate when the voltage at the R3 is high.
When the Arduino pin is driven LOW, the Q1 turns off and the 10k (R1) turns the MOSFET on.

And does the pins go HIGH when Arduino boots up? Because I can’t risk the mosfet turning on while booting up, so really appreciate that tip.

Yes, the Arduino pin will be high impedance (an input) when it boots up, so the R2 pull-up keeps Q1 turned on which keeps the MOSFET off.

BE AWARE: If you have separate supplies and you turn off the 5v supply, the MOSFET will turn on. !!!

If that is going to be a problem, you can solve it and provide some isolation with this type of circuit:
Diagram:

Yours,
TonyWilk

P.S. For 12V operation, R3 in the opto circuit should be 10k instead of 2k2

Thanks for clearing that up, makes sense in my brain now::slight_smile::

TonyWilk:
BE AWARE: If you have separate supplies and you turn off the 5v supply, the MOSFET will turn on. !!!

That may cause problems if my 5v circuit will fail in the future. Looked at the opto-isolator and how it works. I have no clue on how to work out the charging time for the capacitors and how fast it can switch the MOSFET, but as a human not can click faster than apron. 100ms intervals, I would be surprised if it mattered.

I dont see why the mosfet will be off when AVR is starting up. Is it because the diode in the opto-isolator have some forward voltage that keeps it from triggering with a floating AVR uotput?

Here ismy updated circuit with opto-insulator used to trigger the MOSFET:

jallafish: That may cause problems if my 5v circuit will fail in the future. Looked at the opto-isolator and how it works. I have no clue on how to work out the charging time for the capacitors and how fast it can switch the MOSFET, but as a human not can click faster than apron. 100ms intervals, I would be surprised if it mattered.

The capacitors C3,C4 in your diagram are there to guard against spikes on the 12V rail (from turning the motor on and off) from affecting the MOSFET drive. They do not affect the speed at which the MOSFET can switch.

The turn-on and turn-off time of the MOSFET is mostly affected by the response of the opto-isolator.

I dont see why the mosfet will be off when AVR is starting up. Is it because the diode in the opto-isolator have some forward voltage that keeps it from triggering with a floating AVR uotput?

The LED in the optoisolator needs several milliamps to turn on the output transistor. When the AVR starts up, the pin will not be able to 'float up' and provide enough current to turn it on. The pin will have to be set as an output and driven HIGH to do that.

Here ismy updated circuit with opto-insulator used to trigger the MOSFET:

Looks good. (the diagram does say 4N24A instead of 4N25A, do you really mean that?)

Yours, TonyWilk

TonyWilk: Looks good. (the diagram does say 4N24A instead of 4N25A, do you really mean that?)

Hehe, no, just a typo.

Gonna order som parts that I need to assamble this, hopefully they will come within the first days of the next week. I will do some "prototyping" with my UNO, and hopefully have a working code ready when my parts arrive. Will update here then.

For now, realy thankful for the help TonyWilk, learned a lot the past two days