Go Down

Topic: Urgent: MOSFET only working with analogWrite(255) (Read 449 times) previous topic - next topic

PerryBebbington

Misunderstanding over grounds is such a common problem I wrote a tutorial about it.
https://forum.arduino.cc/index.php?topic=653831.0

slipstick

Does this mean that if my source is 18V and my gate input is 5V, the MOSFET won't turn on? My understanding was that the advantage of a MOSFET is that you can control sources with large voltages using a small voltage input.
"Source" in this context means one of the pins of the MOSFET (Gate, Source, Drain). For your N-channel MOSFET circuit the source pin should be connected to GND. If your source PIN is at 18V you've connected the MOSFET the wrong way round.

Steve

6v6gt

Just to update the OP's schematic with the accumulated wisdom gained from this thread:


Smajdalf

You should show your minimal (non)working sketch: remove from your sketch everything nonessential for demonstrating the issue and if the problem persists post the sketch here. If creating such example also solves the problem there is a bug in the removed parts of your code.

ARDUINO_GEEK


Just to update the OP's schematic with the accumulated wisdom gained from this thread:

Thanks so much 6v6gt, I've made all those changes however it's still not working (that is with any value under 255 in analogWrite)

Misunderstanding over grounds is such a common problem I wrote a tutorial about it.
https://forum.arduino.cc/index.php?topic=653831.0
Thanks also PerryBebbington, I've read your tutorial and now understand common ground pretty well, and I'm almost certain I have a common ground in my circuit.
I'll post a simple testing sketch next.

Blackfin

Can you show your physical connections? Are you sure you have the source, gate and drain pins correctly identified on the device package?

aarg

Your symptom sounds exactly like what would happen if you used a non-PWM capable output pin. But you could also just have a software bug, so please post a test sketch as requested in reply #18. Have you tried a simple test of the output, for example connecting an LED instead of the MOSFET circuit?
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Blackfin

It's also possible that the microcontroller pin is unable to supply enough current to the MOSFET gate -- worsened by the series resistor -- during PWM switching.

Unlike bipolar devices, MOSFETs don't rely on gate "current" to turn on and off. However, to establish the fields necessary for operation a transfer of charge is necessary, so upon each switching event, charge must move into or out of the various capacitances inherent to the MOSFET. These capacitances include input capacitance Ciss, output capacitance Coss and reverse transfer capacitance Crss.

If a MOSFET is to be switched, these capacitances must be charged and discharged each time the gate input switches. It's not uncommon to insert a MOSFET "gate driver" between the lowly microcontroller pin and a large power MOSFET that is to be PWMd; these devices act like current amplifiers, able to source/sink amps of current for short duration to drive the MOSFET gate properly for PWM operation.

The Microchip MIC4422AYN is one example of such a driver:

https://ww1.microchip.com/downloads/en/DeviceDoc/MIC4421A.pdf

If your sketch it good, your FET is healthy and the circuit is wired properly and you're still not getting any joy it may be time to consider the gate drive.

Do you have an oscilloscope? Can you see what the voltage at the gate pin looks like with respect to the source/GND?

aarg

It's also time to consider posting images of your actual hardware.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Smajdalf

Your symptom sounds exactly like what would happen if you used a non-PWM capable output pin.
AFAIK analogWrite 128 and more is digitalWrite HIGH for non-PWM pins. But OP gets HIGH for 255 only according to the description.

slipstick

There's something wrong with the code used. For some reason the OP refuses to show us the code. So we're not going to be able to help.

Steve

Go Up