Mosfet Help


I am doing a project that involves using a coin vibration motor and a pressure sensor. Simple concept, the harder the pressure sensor is pushed the more the motor vibrates.

I previously asked what would be a good method to control the motor and it was suggested to use a mosfet, specifically an N-channel mosfet. I have attached a fritzing diagram of my current set-up.

I'm running into an issue where there is a delay between the motor turning on and the pressure sensor being pushed hard enough to start the motor. Reading into how mosfets work, I'm guessing it has to do with the time it takes for the mosfet to drain, making it so the motor doesn't start immediately.

I was hoping for some confirmation on my guess and some suggestions on how to get around this issue. After some research it seems that I may need a logic level mosfet instead, but I'm really not sure.

I don't think it's a coding issue, as the values update in the console and I can see the voltage being applied changing there.

here is the code, thank you for letting me know. I used MatLab for this project

clear all;

a= arduino();
%make "a" object of arduino

ButtonHandle = uicontrol('Style', 'PushButton', ...
                         'String', 'Stop', ...
                         'Callback', 'delete(gcbf)');

%creating the stop button
%i = 0;

S = zeros(1,5);
%storage matrix
%set(gca, 'ydir', 'reverse');
%hold on;
%grid ON

while true
  %i = i + 1;
  b=readVoltage(a,'A0') * (1024/5);
    %reading voltages from pin A0 , reads voltages not adc value ,
    %voltages = (ADC*5)/1024
  S = [b S(1:end-1)];
  y = mean(S);
  %filter matrix S and store average in y
    NormX = 3.5 - ((1024-y)/90)*3.5;
    % set NormX to a % of 3.5, adjusted for the motor feel on skin
    if NormX >= 0 && NormX < 3.5
        writePWMVoltage(a, 'D3', NormX);
        writePWMVoltage(a, 'D3', 5);

    if ~ishandle(ButtonHandle)
        disp('Reading Stopped');
    %ending loop conditions

%hold off;
writeDigitalPin(a, 'D3', 1);

Many thanks.

Any delay in the operation of a MOSFET is on the scale of nanoseconds, many orders of magnitude below what a human can notice.

Please post your code in code tags </> as per the forum instructions.

Thank you

"I don't think it's a coding issue, as the values update in the console and I can see the voltage being applied changing there."

Well then it must be hardware ;).

What is the part number for your MOSFET ?

BTW, do not use delay()s in your your sketches as it stops program execution for that amount of time.

Never power a motor from an Arduino power pin !

Always place a kickback diode and a .1nF capacitor across the pins of a non reversing DC motor.

Are you using PWM to control the MOSFET ?

The part number is 30N06l.

In my code there is a short pause. But the delay is a few seconds, not 0.01 seconds like the pause is. Even with the pause removed from the code the delay remains.

Yeah I was wondering about powering the motor directly. I consulted a friend about it who is much more well-versed in arduino than I am and they said it didn’t matter. I will disregard their advice next time.

When you say across the pins, what exactly does that mean? I have encountered a similar instruction before but without a visual it’s hard for me to understand how to implement it.

Are there suggested resources so I can better understand what the kickback diode and capacitor combination would do?

Yes I am using PWM to control the motor.

The pause is in the code to allow the UI button to work. It isn’t an integral part so I could remove it, I just had to stop the program through MatLab instead

Thank you for the help larryd. I did some googling and came across this:

I probably didn't encounter it before because I wasn't aware of the usage of diodes and capacitors in conjunction with motors.

I think I can go from here. The explanations are very good.

I'm concerned about having possibly damaged my arduino from my previous set-up. Will it be noticeable or just a decrease in functionality? I checked the pins I'm using and they seem to still work.

I'm concerned about having possibly damaged my arduino from my previous set-up. Will it be noticeable or just a decrease in functionality?

99% of the time the chip will die completely. Rarely, you'll get a "dead" I/O pin on a chip.

If the part number is FQP30N06L this will work with a 5v Arduino.

The pinout for the part is GDS so you ‘do not’ have it properly wired in the image !

The output pin should go to a 220Ω resistor then to the Gate (left side).

The Gate should also go to a 10k resistor to GND.

The Drain (middle pin) goes to the motor.

The Source (right side) goes to GND.

So I tried the set-up you mentioned and also did some more research.

It wasn't working when I tried the set-up you outlined, but it may be that I did something incorrect. When you mention the drain is attached to the motor, is the motor then attached to GND? My coin vibration motor has two leads.

I found this website that uses a different type of mosfet with a 12V DC motor.

It mentions that at least with their set-up the output pin can be connected directly to the drain. What about my set-up requires the resistors, especially such a high one from the gain to GND? And from gain to ground needing resistance? I've attempted to watch videos on mosfets but none of the examples utilize resistors in this way.

My best guess is their set-up utilizes a DC power source whereas I'm using a 5V pin from the arduino.

My basic understanding of how mosfets work is that as long as the gain is higher than the source voltage, the switch flips. So it makes sense that the source is connected to ground so that any voltage applied flips the switch. However the extra parts added around the gain pin confuse me a bit. Why are the resistors necessary?

You need to show us a good image of your ‘actual’ wiring and the ‘complete sketch’ you are using.

It mentions that at least with their set-up the output pin can be connected directly to the drain.

It says no such thing! :astonished:

Oh I see. I misread this sentence, thank you for catching that:

“The I/O pin is connected directly to the gate.”

I attached a sketch of what I have set-up. I removed the sensor and am just applying voltage to the pin to make things easier to troubleshoot.

We need to see a good image of the ACTUAL wiring.

You must connect the motor between the + terminal of your external power supply and the MOSFET Drain.

We need to see your complete sketch too.

Oh I see. I misunderstood what you meant by sketch (I haven’t used the Arduino IDE before).

% TactorTest2
% Categorization of pressure categories as relayed by the tactor. Has 5
% distinct stages.

clear all;

a = arduino;

writePWMVoltage(a, 'D2', 3.5);
disp("Stage 0");

writePWMVoltage(a, 'D2', 3);
disp("Stage 1");

writePWMVoltage(a, 'D2', 2.5);
disp("Stage 2");

writePWMVoltage(a, 'D2', 2);
disp("Stage 3");

writePWMVoltage(a, 'D2', 1.5);
disp("Stage 4");

writePWMVoltage(a, 'D2', 1);
disp("Stage 5");

writeDigitalPin(a, 'D2', 0);

I have attached a picture of the set up I have right now. I have not run it yet, as I don’t have an external power supply. I instead connected the Arduino’s 5V pin between the motor and drain instead.

Never mind. I misread things again. The motor works smoothly now.

(The motor is soldered underneath the electrical wire).

Thanks for the help and patience.

20200914_165637-converted-compressed.pdf (87.8 KB)

A "PDF" is not an image format, PDFs are to represent documents but are chiefly used to obscure content and prevent its re-use.

They can not be embedded in HTML pages (or are very impractical to do so). Please use a proper image format (.gif, .jpg, .png).


A common mistake here, not critical and some here love to criticise my comments, but the 10k pull-down resistor is on the wrong side of the series resistor. Its purpose is only to hold the Arduino output down while the Arduino boots and the output is not under control, therefore it should go from the Arduino output to ground so then the series resistor goes to the FET gate.

While this effect is relatively minor, putting it on the FET gate makes it into a voltage divider which reduces the drive voltage to the FET. It is best to always avoid this in case at some time it may become more significant. :astonished:

I see. That makes sense.

So does this essentially mean the 10k ohm resistor is parallel with the 220 ohm resistor from the arduino output (I attached a picture of the set-up; thank you for letting me know about pdfs).

I'm also curious why these particular resistor values. Reading through this previous thread makes the 10k ohm resistor's role make sense to me. However how does someone know that the 220 ohm resistor is necessary and at that resistance?

The exact values of the resistors is unimportant. The 10k resistor needs to just hold the gate off while the Arduino starts up and setup gets the outputs correctly configured. Too low and it will draw significant current from the output during normal operation, too high and it won't hold the output low. 10k is a nice middle value that does this, and also it's a nice round number. Probably anything from 5k to 100k would do.

The 220R resistor limits the current from the output pin into the capacitance of the gate. MOSFET gates are small capacitors, which need charging and discharging. Output pins change state very quickly so the instantaneous current into the gate will be quite high. 220R limits the current to 5V/220 = 22mA, which is in line with that maximum current rating for a pin.