PWM to MOSFET

Hey everyone

Im new and this is my first post, I am just getting started in the World of Arduino.

I want to control and dim a light 12v lamp through a MOSFET, I have followed instructions on this website and everything works fine if I try it with 5V and LED.

http://bildr.org/2012/03/rfp30n06le-arduino/

The programming works and is managing to dim the LED but when I try with the 12V power source and the lamp, the lamp just turns on and doesnt do turn off or DIM.
Im using a n-channel UTC UF630L
my circuit is as shown on the website Link

Any ideas
Marius

One problem that I can see right off the bat is that the mosfet that you're using is meant to be switched on/off with 10v. What you want for controlling devices via the arduino directly is a logic level mosfet like this one:

An easy way to tell which type you're looking at is to check the datasheet and find rDS(on). They generally tell you what voltage they used to get those numbers, and it's a good indication of what voltage you should be using to switch it on/off.

That being said, what type of lamp are you trying to dim? Not all types are meant to be dimmed using PWM.

Hey, thanks for the quick reply

I thought about the logic level mosfet too (I couldnt find the specific datasheet for my mosfet, but a similiar one indicates what you said with the 10v).

But why is it working with the LED then? Nevertheless I will buy myself a new correct mosfet.

The lamp is a normal 12V halogen lamp 20W gu5.3
like in this link

http://www.conrad.de/ce/de/product/570807/Halogen-Kaltlichtspiegellampe-Halogen-GU53-20-W-Transparent-Reflektor-4000-h

I don't much care for the 10k resistor to ground on the gate. That seems awfully small for a pull-down that shouldn't really need to be there at all. I'd try it without that resistor and then, if you really need it, change it to 100K.

motomoto2:
Hey, thanks for the quick reply

I thought about the logic level mosfet too (I couldnt find the specific datasheet for my mosfet, but a similiar one indicates what you said with the 10v).

But why is it working with the LED then? Nevertheless I will buy myself a new correct mosfet.

Its working with the LED because that's a low current load - the MOSFET only has to be less than a few 1000 ohms to
light up an LED convincingly. To turn on a 12V bulb (which might take an amp) requires it to drop to a fraction of an
ohm (its rated as 0.4 ohms with 10V gate drive, which would work, but its not very good).

High voltage MOSFETs have much higher on-resistances than low-voltage ones, for instance this one is 200V and 0.4 ohm, whereas a
beefy 30V MOSFET might be anywhere from 0.02 to 0.002 ohms these days. If you want to switch 12V, use a MOSFET with
a rating in the 30 to 50V range, logic level and expect the on-resistance to be somewhere around 0.02 ohms.

In fact work out the current you need to switch and use I-squared-R to calculate how much power a possible MOSFET
will dissipate - this will help you choose the right device and decide if a heat-sink is needed.

Allright,

with the new MOSFET I do notice a change when I set the PWM pin to 0 and 255, but as it turns of the LED it doesn not do so with the 12v halogen lamp, it just dimms it a little, what do I have to change to have the full effect of the halogen lamp ranging from turned off sate at PWM 0 and fully on at 255. The new MOSFET fits the discription from MARKT its a 55V MOSFET with logic level. Rds on is 0.035ohms. What am I not understanding right?

http://www.conrad.de/ce/de/product/162873/MOSFET-International-Rectifier-IRLZ34NPBF-HEXFET-Gehaeuseart-TO-220-ID-27-A-UDS-55-V

Under "Datenblatt" you can download the specifications.

Are you sure your Arduino ground is connected to the ground (-) side of the light's power supply?

yes, just like in the link i posted with the schematic

Well, it should work then.

Do you mind showing a picture of your circuit and your code?

Edit: BTW, the written description at that first link is misleading. It says "Ground is connected to the transistor’s drain." Which might lead you to think the drain of the MOFET is connected to ground. This is not true. The source of the MOSFET needs to be connected to ground and the load between 12V and the drain of the MOSFET.

heres the image in the attachment, as i said, the 12v halogen lamp shows a little difference in brightness but doesnt go near turning off

Image didn't up load.

Is it just the funny angle, or do you have the breadboard's gnd connected to the arduino's aref?

Counting up on that header it seems to be connected to ground. The angle is a bit funny.

Well, I'm at a loss. That should be working.

What about your code? Maybe a typo there?

here is the code, with the LED 5v it works, and like I said I achieve a little difference, but the lamp is supposed to turn off completly which it doesnt do

/

int halogen = 9;
int brightness = 0;

void setup() {

pinMode(halogen, OUTPUT);
}

void loop() {

int brightness = 0;
analogWrite(halogen, brightness);
delay(1000);
brightness = 255;
analogWrite(halogen, brightness);
delay(1000);
}

This might be a silly question, but are you sure the 12V is DC?

Do you have access to a scope or a DVM? You could check the signal going into the gate to see if the it is actually 0v when you execute analogWrite(0).

Looks like it should work unless something weird is happening.

Hy

Im 100% sure it is DC, unfortunatly I have no Scope or DVM. Looks like I will need to get a voltmeter though, but remember with 5V the circuit works :frowning:

Grasping at straws here but:

void loop()  {
 
  int brightness = 0;

Should just be

void loop()  {
 
  brightness = 0;

Can't see it making a real difference, unless it does! :slight_smile:

Nope that didnt do it,

Allright, I thought that something weird might be with the Halogen lamo so I put in an LED light instead.

Funny,

the LED light will not turn on with the 12V, the LED takes 20mA
the HALOGEN lamp will not turn off with the 12V, the Halogen takes 1.66A

Is there any PRO with MOSFETs here?

motomoto2:
Hy

Im 100% sure it is DC, unfortunatly I have no Scope or DVM. Looks like I will need to get a voltmeter though, but remember with 5V the circuit works :frowning:

Troubleshooting problems like this without proper test equipment like a DVM is silly in my opinion. An arduino user before buying his/her first electronic component for any kind of connection to an arduino needs to already have obtained and know how to use a dvm. They can be had for dirt cheap these days for basic ones.

Lefty

Try commenting the line...
// pinMode(halogen, OUTPUT);

I'm driving 10W 1A LEDs fine with PWM through a MOSFET and I don't have pinMode defined for the PWM pins. Did need it for a digital pin though. I know this doesn't explain why PWM works with an LED for you.