MOSFET wigs out program

Hello, I have a servo routine/code that works as anticipated when the servo is powered directly from the uno. it's fabulous. However if I use ANY pin (analog or digital) to the gate of a Buz11 enhanced mode N channel MOSFET as a switch, the thing just wigs out. I mean it shakes and shutters. I can see the pattern I have coded but it vibrates/shutters/shakes/rattles/flutters WHEN I attach a digital or an analog pin to the gate of the MOSFET as a switch so I can go directly to my power source..It just doesn't make any sense. I can do the same switch thing with an Adafruit sound board and it works fine. Same MOSFET. And there is no problem. Any one have any idea what is going on? CODE attached. the sound board has been commented out. It isn't an issue. Thanks in advance

Servo servo1;
int servoPin = 9;
//const byte soundBoardPower = 11;
int pwrServo = 11;

void setup(){
  //soundBoardPower, (OUTPUT);
  pwrServo, (OUTPUT);
  servo1.attach(servoPin);
}

void loop(){
  analogWrite (pwrServo, 255);
  //analogWrite (soundBoardPower, 255);
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(50);
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(50);
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(50);
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(50);
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(50 );
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(50);
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(50);
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(50);
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(50);
  servo1.write(0);
  delay(50);
  servo1.write(10);
  delay(1000);
  servo1.write(0);
  delay(1000);
  servo1.write(10);
  delay(2000);
  servo1.write(20);
  delay(1000);
  servo1.write(30);
  delay(250);
  servo1.write(40);
  delay(250);
  servo1.write(30);
  delay(100);
  servo1.write(40);
  delay(250);
  servo1.write(30);
  delay(1000);
  servo1.write(20);
  delay(4000);
  servo1.write(10);
  delay(1000);
  //analogWrite (soundBoardPower, 0);
  analogWrite (pwrServo, 0);
  delay (10000);
}
type or paste code here

The Uno is not a power supply, and while it make work for a little while, you stand a pretty good chance of destroying the Uno, when attempting to use the 5V pin to power servos or motors. At the very least, overloading the 5V output will cause program malfunctions or resets.

Use a separate power supply, and don't forget to connect the grounds. 4xAA works well for 1 or 2 small servos, like SG-90, but plan on 2.5 Amperes per servo for larger ones, like the MG996R.

For help with other circuits, post a pic of a hand-drawn wiring diagram, with pins, parts and connections clearly identified and labeled.

Hi, @Fredric58

What are you driving with the MOSFET?

As @jremington has asked for.
Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

ATMEL328P with a 16 MHz crystal powered with 5 volts

D9 sends signal to gate of a Buz11 enhanced mode N channel MOSFET

Servo powered from seperate supply ( SG 90 micro servo)

MOSFET SCHEMATIC.pdf (580.5 KB)

Hi, thanks for dropping in. I am using a separate power supply. The 328P simply sends a signal to the MOSFET gate.to turn on / or power up the servo (micro servo SG-90.) a schematic is attached as requested. It is a "bare bones" ATMEL 328P with a 16MHz crystal, caps, etc......The MOSFET is a Buz11 enhanced mode N channel and should work fine??????? It has in the past for other projects that are similar. But now.........the servo just freaks out. It jitters. Still goes to all the angles I tell it to, but it is like it drank a gallon of Red Bull. The Buz11 is supposed to be able to handle either 20 or 50 volts. The gate requires around 2+ volts for saturation. (on) and then OFF with 0 volts to the gate. (off). But it ain't working like that. And I don't know why. My first thought was left over capacitance, But that didn't make sense, it does, turn off when the 328P signal goes low. It's a strange anomaly.

An N-channel MOSFET will not work as a high side switch. I suggest to use a Pololu Power Switch instead.

Schematic posted properly, in line:

When using an N-MOSFET as a low side switch, you should protect the digital pin with a current limiting resistor between the gate and pin (typ. 150 Ohms). Also, choose a logic level MOSFET, which the BUZ11 is not.

Typical low side switch, for motors, solenoids, etc.

Hi,
Thanks for the circuit diagram.
A jpg is preferred as some platforms find it difficult to display pdfs.

Is that your complete schematic?
How are you controlling the servo?
Why do you want to control the power to the servo?
What other devices do you have connected?

A complete diagram would be appreciated.

Because that is 2V between source and gate, you are supplying gate voltage with respect to gnd.
You have the 5V servo between gnd and source, so the gate will never see the the required potential, even if a logic type MOSFET.

Tom.. :smiley: :+1: :coffee: :australia:

The MOSFET is simply a "switch? and has usually worked. I will present a JPG next time. How I control the servo is I send a signal to the gate from the 328 or arduino connected to the drain, that connects the drain to the source and should "energize the servo" POWER IT UP. source to the servo then to GND. It's a high side switch from what I have been told. Someone else told me that was WRONG. I didn't argue, I'm not that sophisticated. All I want to do is POWER the servo. And let the servo "signal Pin" tell it what to do.

Is that your complete schematic? NO
How are you controlling the servo? WITH THE CODE PROVIDED FROM ORIGINAL POST, CODE INCLUDED
Why do you want to control the power to the servo? TO CONTROL BATTERY CONSUMPTION
What other devices do you have connected? AN ADAFRUIT SOUND BOARD The 328 P Sleeps all day, when the hystrisis reaches a
level "X" it wakes up, the 328 powers a a PIR all night. When the PIR activates. it turns on the servo and runs through its script AND turns on a sound board that make noises. When the PIR goes low, everything shuts down till the next time the PIR goes off. And when the sun comes up the 328P goes right back to sleep. I received my patent on this project 2 1/2 years ago then shortly after discovered I had stage 4 Pancreatic cancer. Which has taken up the last 2 1/2 years of my life. HOWEVER! I can't mention names, (TOS) but, "HE" definitely has different plans for me and I am still here, better than I was before. Unfortunately, I can't tell you about it or my post will be deleted.

No Tom, it's 2 volts to the gate, allowing the 5 volts through the drain and source to the servo then to GND

No Tom, it's 2 volts to the gate, allowing the 5 volts through the drain

You have a fundamental misunderstanding of how the MOSFET is switched on.

There are some useful MOSFET tutorials on the web, so if you want to understand how they work, take some time to look up and study one or more of those tutorials.

The BUZ11 is not fully turned on until the gate to source voltage is 10V. Here is the transfer curve from the data sheet:

It's 2 volts to the gate, "allowing" the CURRENT through the drain and source to the servo then to GND

The current you provide goes through the SERVO which will try and produce 5V across itself to work.
So if the positive of the servo tries to go to 5V.
Hence the source of the MOSFET goes to 5V.
You have 5V on the gate, the MOSFET will turn itself OFF.
Then the gate will have 5V with respect the source, the MOSFET will try and turn ON.
The servo will conduct and the MOSFET will turn itself OFF.
This means your servo is being turned ON and OFF cyclically.

It does..

Tom... :smiley: :+1: :coffee: :australia:

That would appear to be what is happening. I got my info from a tutorial online. It appears I didn't understand it, or it may have been incorrect. My impression was it takes a lesser current to the gate to pass a higher current through the drain to the source. which is backwards ? And that sometimes a pull down resistor is required on the gate because of phantom (for lack of a better word) capacitance, that sometimes they will stay on even of the gate goes to zero. I will heed your advice and revisit how MOSFETs work. Bound to learn something today. Thanks for all ya'lls comments. Fred

So while it's on my mind, let me ask a couple questions please just to see if I am headed in the right direction
.

  1. Both MOSFETs and BJTs can both be used as switches?
  2. Would one or the other be more applicable in my situation? ( only dealing with 5 volts here)
  3. I should be looking for one or the other that has a Vgs that requires less than 5 volts to reach
    full saturation?
  4. And it needs to handle at least 5 volts from the drain to the source with the least amount of
    loss due to their physical properties. As I understand it there is a resistance factor between the
    drain and source. Though it's usually quite minimal.

Am I correct on any of these, THANKS.

  1. True

  2. In this case either would work.

  3. No, you need to find one that has a guaranteed Rds(on) at 5V or less.

  4. The Vds should be at least 20% higher than the voltage you want to switch

A MOSFET is a voltage controlled device. You seem to be confusing it with a bipolar transistor.

you are correct, i used the wrong term. they are used to switch a higher voltage using a lower voltage. or in my case to switch on a different power source. I'm working on it.

is there a way to do a search, based on the parameters required to find a suitable MOSFET for an application? There must be a million of them.

So I have been reading for 5 hours, complex it is. however you're confusing me or I am simply REALLY confused. On the DATA sheet for this MOSFET it says the gate threshold voltage is typically 3V, with a max of 4V. In another article it states "if the Vgs is at least as high as threshold voltage the MOSFET turns on". Since my power supply I'm switching is 6 volts - losses, and my arduino output is 5 volts to the gate. And being they are very close/similar, could that be causing the cyclical issue? could it be as simple as putting a current limiting resistor on the gate? There's a lot of stuff out there. One tutorial will states X and another will contradict it or imply it is obsolete. Seriously, I'm just trying to learn. Thanks

Here is a YouTube video that I found helpful.

The important thing I have learned is the order of transistor and load is crucial. With the N-channel the source must be connected to the common ground and the load connected between its positive supply and the drain.

Yes, over 40 years of electronic hobby and employment and now I find it necessary to really learn about MOSFET’s.

‘Ralph S. Bacon”and “Dronebot Workshop” are two YouTube suggestions to use while learning Arduino.

“Paul Mcworter” has a beginner series also, although he sometimes gets way off in the technical weeds. Still can learn much from him.

good video, seen some of his other stuff. I came up with this for my application, thoughts?