Arduino Nano V3 PWM will not run at 100%.

I've been building a project that flashes a high intensity 50w RGB LED. I'm using three MOSFETs connected to PWM pins 9, 10 and 11.

I've got the circuit hooked up to my bench power supply so I can see the current draw when the LEDs are on. I noticed that whey driving the LED's directly and not going through the MOSFET the current draw was three times higher.

I've managed to do a lot of testing and everything pointed to the PWM signal not being set to 100% even though I'm doing an analogWrite(pinnumber,255).

My final test was to use the pins connected to the MOSFET as digital pins by doing a digitalWrite(pinno, HIGH). That maxed out the brightness and the current draw.

To summarize, if I connect the gate of the MOSFET to pin 9, 10 or 11 and do an analogWrite with a value of 255 to get a 100% duty cycle I'm getting a lot less current through the MOSFET than if I raise the pin with a digtalWrite HIGH.

Does anyone have any idea why? All the documentation says that analogWrite with 255 turns the pin on all the time. Is this a bug in the Nano?

Which MOSFETs are you using? Which LEDs?

Please provide a schematic; a photo/scan of a hand drawn one will do.

Doing analogWrite(pin,255) actually does digitalWrite(pin,HIGH)

See https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_analog.c

void analogWrite(uint8_t pin, int val)
{
 // We need to make sure the PWM output is enabled for those pins
 // that support it, as we turn it off when digitally reading or
 // writing with them.  Also, make sure the pin is in output mode
 // for consistenty with Wiring, which doesn't require a pinMode
 // call for the analog output pins.
 pinMode(pin, OUTPUT);
 if (val == 0)
 {
 digitalWrite(pin, LOW);
 }
 else if (val == 255)
 {
 digitalWrite(pin, HIGH);
 }
 else
 { //PWM stuff starts here

I cannot fathom how you could get different results with analogWrite(pin,255) and digitalWrite(pin,HIGH)

Sorry guys. I got it working. I'm just really really stupid. The function that was doing the analogWrite was assuming a color value from zero to 1024. Since I was calling it with 255 it was mapping it down to 127 or there abouts.

Like I said, stupid mistake. A software mistake no less. I'm a newb when it comes to the electronics but I've been programming for a living for 30+ years. I should have figured that one out quicker.

Sorry for wasting peoples time but I really do appreciate the help. I'm impressed that you guys responded so quickly! I was going to try and quietly delete the post to save the embarrassment but you guys were too quick!

jgold:
Sorry for wasting peoples time but I really do appreciate the help. I'm impressed that you guys responded so quickly! I was going to try and quietly delete the post to save the embarrassment but you guys were too quick!

Always nice to see that I'm not the only one that makes stupid mistakes 8)