Problem spinning motor


I am using this mosfet

I want to use it power a small brushed motor 3.7V. I am using caps and protection diode, dont worry.

I know how to use this mosfet, I am not making any stupid problem. My question is this: I am using 5v in the gate pin of the MOSFET (cause my arduino is 5V) but on the drain/source I am using an external battery with 3.7 V. I connected the GND of the battery to the arduino together, so no stupid thing here.

I want to know this: can I contol this MOSFET using a higher voltage on the GATE? I ask this cause when I apply digitalWrite(3,10) or digitalWrite(3,255) the motor is spinning in the same very fast speed. It should spin much lower at 10 than 255 PWM.

Try analogWrite(pinX, speed); instead using one of the PWM pins 3,5,6,9,10,11 and a speed from 0 to 255. digitalWrite only supports 0 and 1, LOW and HIGH, true and false. 10 and 255 are >0 so they are treated as 1.

Absolutely - the gate is completely isolated from the source and drain circuit, so long as
you don’t reach/exceed the maximum gate-source voltage. You can control a 0.1V output circuit if you want!

MOSFETs are voltage controlled switches - when on the channel between source and drain acts
basically like a resistor (here one of about 0.006 ohms).

Your problem with the same speed at 10 or 255 is because you are using the wrong decay mode.

For much better proportional speed control you need two switching devices driven in antiphase -
known as synchronous rectification sometimes, not slow-delay mode that you are currently using.

You could add a power zener in series with the free-wheel diode to get fast-decay mode which would
help, but wastes power in the zener.

You’ll find the with the motor under load you’ll get more reasonable speed-control than with it unloaded.

Ha, didn't spot the digitalWrite there! Though I suspect this is a typo - as always posting your code verbatim is the way to go, not regurgitate snippets.

I said I was not doing anything stupid... but I did, indeed. I should have used analogWrite!!! Thank you so much for pointing my error, indeed a vveeeery stupid error.

I just have a question: do you think I should use diode and caps with the motor and the mosfet? As @MarkT pointed, the GATE is isolated from DRAIN/SOURCE. So there should be no problem the high voltage produced by the brushed motor when it is spinning without power being applied to it, I mean, arduino should not get destroied by that. I removed the caps and the motor looks spinning smooth, do you think this mosfet has already diode and caps?

I don't know about caps on most motors, generally not needed. What are they supposed to be doing?

I would keep a diode across the motor tho to dissipate any motor generated current when it is free spinning so as not to destroy the MOSFET.

Thanks man! Usually I put caps to make the motor spin smoothier. Some motors that I have spin muuuch better when using caps across + and - welded directly to the motor. If I remove those caps the motor spins very irregularly

You don't put more than 100nF ceramic across the terminals, more than that and you strain the MOSFET and the cap with large current spikes.

Small cap across the terminals to suppress RFI, large cap across the supply to decouple it.

If its running irregularly the PWM frequency is probably too low, note that the default Arduino PWM frequency is probably too low for most small motors. With slow decay mode the PWM frequency affects the response to duty cycle too.