Electrical – Mosfet current control with PWM

arduinomosfetpwm

I am using a mosfet and an Arduino and I want to control the Source-Drain current of the mosfet by adjusting PWM to the Gate.

If I apply zero value to the PWM, the current doesn't stop (I checked the PWM output with voltmeter and it's zero volts). When I manually connect the gate to the ground with a wire, the current stops.

How can I stop the current with PWM output that connected to the gate?

Here's my circuit. I common all the grounds with wire and put mosfet and hall effect sensor on two separate breadboard.

Also, I'm powering the Arduino with a printer cable that's connected to my laptop.

Schematic

Best Answer

the source of your MOS-FET needs to be connected to the reference of the 5V supply of the arduino, your schematic does not show this connection.

without it the gate voltage is floating so it will be very unlikely to ensure turn off while floating.

You always apply voltage as a differential so a single connection, the gate needs the output, but also the source needs to be connected to the 5V reference.

Sadly, this is not a good design you do not want the reference of the Arduino to have an inductor leading to ground right after and not be connected to ground.

I have a couple ideas from the top of my head.

Re-design the circuit so the source goes to ground and you can connect the Arduino reference to source also

use a DC-DC converter to isolate the arduino from your 5V power line then there is no issue with connecting the source to the 5V reference.