Hello I can make a circuit where the 2n2222 can drive the leds and the arduino can pwm them and it works great. I also can make a circuit with just a irf530 driving some leds on 12v and it also works great. My main goal is to power some resistance wire for a heat bender. I would like to use the 2n222 to push 12v to the irf50 so it fully turns on and off.
I cant get this to work. any tutorials on how to make a mosfet driver with all the talk of non ttl mosfets on here you would think it wouldnt be too hard to find but I cant find anything.
I am thinking the problem arises because I am sinking the negative side of the leds through the transistor instead of putting power out of the transistor should I be using a p chanel transistor to feed the mosfet its 12v to turn on? Or is this just not working because I am using the same 12v supply for both mosfet and transistor.
Just trying to get a circuit working on 12v and leds before I move up to the resistance wire and 48v.
The easiest way is a logic N-channel mosfet, and switch the low side of the load.
Like this one.
60volt/30A on a 5volt Arduino might be enough for your heater.
Just use a 220ohm resistor between Arduino port and gate, and 100kohm from gate to ground.
High side switching with a P-channel mosfet is another option, but more complicated.
More parts and slower switching.
Can post a schematic if you want.
Leo..
It's not optimized for (yeah, you know, well) every damn thing, so it offends snarky ol' Mr. Drive-by.
What you're attempting should correspond.
The 22k could/should be a lower value.
"HV" should be the 12V, too.
Tom is NOT "snarky ol' Mr. Drive-by" (that's somebody else)
Thanks Pancake plus karma I got it to work I think I confused gain drain and source on the mosfet like a newb. I did order some ttl level mosfets from sparkfun they had the lowest price by far even accounting ebay unless you buy a 10 pack from china and wait.
FQP30N06L
My last question before I try this on higher voltages with resistance wire, I have copper forged mosfet heatsinks Do i have to insulate the back of the mosfet and the heatsink from electrical charge aka use a an insulating thermal tape or can it touch the bare back. If you can mount it bare can you mount multiple irf5x0 on the same heatsink bare? Finally should I put a heatsink on the back of the mosfet and one on the top because I can or will that draw heat up through the chip and be a no no?
Well I looked at the data sheet and basically it doesn't say anything about the tab or hell i didnt know to call it a tab because it doesn't label it as that etc etc. so yeah I am asking. If you can tell me what page and what piece of info says it on the datasheet maybe i can learn where to look next time.
You realise the logic mosfet you're getting does not need a driver transistor.
And that the posted circuit inverts (change your code).
And is "on" when the Arduino is off, and could be "on" during bootup.
And that 22k needs to be 1k to lower switching losses.
And that a single logic fet switches faster (lower dimming/less heat).
Leo..
Wawa:
You realise the logic mosfet you're getting does not need a driver transistor.
And that the posted circuit inverts (change your code).
And is "on" when the Arduino is off, and could be "on" during bootup.
And that 22k needs to be 1k to lower switching losses.
And that a single logic fet switches faster (lower dimming/less heat).
Leo..
Hello I do realize the one I am getting does not need a driver, but after a year or so of reading all the irf5x0 and arduino threads and I have several irf series mosfets on hand I figured I would learn how to do it before my mosfet comes.
the posted circuit I do realize now does all that stuff Ideally I would like the HIGH to turn on the mosfet. If I had to use the circuit and parts I have today I would have to put a switch on the 12v so I can hard turn it off untill the arduino is up and running. Thank you for the resistor suggestion I will try a 1K.
as far as single logic fet switches faster I assume that is the TTL mosfet I have ordered. Is a single logic fet the correct name for those? Thanks you.
ghost2501:
Is a single logic fet the correct name for those?
It's generally called a "Logic FET".
I added "single", because you only need one.
The single FET circuit is potentially faster because of the lower gate drive resistor (220ohm).
I quickly drew up a crude diagram (from memory) for high-side switching with a P-channel FET.
The zener (400mW) is needed to keep the gate voltage within specs.
Driver is a small transistor that can withstand 60volt (2N2222 is 40volt), or a 2N7000 without gate resistor.
2x10k resistors can be lowered to 2k2/1watt for faster switching.
If you are only going to use a 12volt supply, the zener can be omitted, and the collector resistor can be a link.
The top (gate) resistor stays, but can be 1Kohm.
Leo..
ghost2501:
Ideally I would like the HIGH to turn on the mosfet. If I had to use the circuit and parts I have today I would have to put a switch on the 12v so I can hard turn it off untill the arduino is up and running. Thank you for the resistor suggestion I will try a 1K.
.
You could add an inverter before the NPN, we'll just get all bipolar crazy, man. If you need that circuit, let me know. I know that you know that I know that you know that I was just helping you work with what you've got. That did turn out right, didn't it?
And, with this package (TO-220), the middle lead and the tab are the same. If you wanted to run some of these MOSFETs in parallel to share lots of current (more than either could deal with on its own), then they could be mounted to the same heatsink without insulation.
I edited the schematic, showing a lower value resistor.
Thanks a ton I learned more about arduino today than in the last 2 years. While I was looking into this I wrote my first code to manually change duty cycle and pwm. I changed the pin to led 13 to test it and it works~! it takes the 0-1023 sensor value and maps it to 0-1000 for ease of milliseconds use the 1000 means its 1Hz if i wanted 2hZ i change it to 500. I then reverse map the value for the off delay and it always equals to a 1HZ duty cycle 30 on 70 off etc. I am so happy right now I have to celebrate.
the guy who was helping me came up with an easier solution like delay 1000-sensorvalue so it comes up the same basically but I figured mine out by myself so I am proud.
int ledPin = 13; // LED connected to digital pin 9
int analogPin = A0; // potentiometer connected to analog pin A0
int val = 0; // variable to store the read value
int valA = 0; //I put this 0 here because I saw everyone else doing it
int valB = 0; // I did it again here I am not even sure if I need valA and valB up here
void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(analogPin); // read the input pin
valA = map(val, 0, 1023, 0, 1000); // maps the values from 0-1023 to 0-1000 for use as milliseconds on time
valB =map(valA, 0, 1000, 1000, 0); //reverses the number range for use as milliseconds off time
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(valA); // stop the program for <val> milliseconds:
digitalWrite(ledPin, LOW); // turn the ledPin off:
delay(valB); // stop the program for for reverse of <valA> milliseconds:
}
The analogRead time and the mapping time are part of each pass, too.
The map conversion can go from Max to Min, too. (e.g. 1000-0, 800-50)
byte ledPin = 13; // LED connected to digital pin 9
int analogPin = A0; // pot connected to analog pin A0
int sensorVal; // variable to store the read value
int valA;
void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
sensorVal = analogRead(analogPin); // read the input pin
valA = map(sensorVal, 0, 1023, 0, 999); // maps the values from 0-1023 to 0-999 for use as milliseconds on time
digitalWrite(ledPin, LOW); // turn the ledPin on
delay(valA); // stop the program for <val> milliseconds:
digitalWrite(ledPin, HIGH); // turn the ledPin off:
delay(1000 - valA); // stop the program for for reverse of <valA> milliseconds:
}
byte ledPin = 13; // LED connected to digital pin 9
int analogPin = A0; // pot connected to analog pin A0
int sensorVal; // variable to store the read value
int valA;
void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
sensorVal = analogRead(analogPin); // read the input pin
valA = map(sensorVal, 0, 1023, 999, 0); // maps the values from 0-1023 to 1000-0 for use as millisecs
digitalWrite(ledPin, LOW);
delay(valA);
digitalWrite(ledPin, HIGH);
delay(1000 - valA);
}
I see what you did on the two codes one is just the inverted cycle of the other I am guessing in case the potentiometer is wired backwards I can make it work either way etc.
Why did you change the 1000 to 999 may I ask? the reason i put 1000 is so it makes a exact 1 second. I think that makes it 1001 points of data but does it create a problem? Because then the math goes funny if I try to turn it to 500 or 250 or even 2000 to change the frequency.
also not sure exactly what you mean about max min and the example you gave (e.g. 1000-0, 800-50) and how to implement it but i am reading up on it.
Without making any changes to your circuit/ry, just upload one version and see how it works and then upload the other version and see how it works.
Sticking to "1000" isn't really working out the way you think because you're not taking into account the time that it spends on the analogRead and the rest each pass through the loop - a fine point but still.
1 ON and (1000-1) OFF = 1000
999 ON and (1000-999) OFF = 1000