 need help on driving irlr2905

Hi Guys,

i finally got my hands on arduino leonardo and micro and i am thinking of trying 12V 50Khz pwm with them on a car light just to get started. i plan to use irlr2905 as i have a few around and have low resistance"cheap less than 1 euro". i was wondering can the pin of arduino charge the gate of the irlr2905 fast enough "i am without any cooler around :P for long turn on times"??

i had found someplace on my old PC the formula to get the required current to open the mosfet near datasheet speed in this case if i remember it was like 20-50ns.

Timi

The arduino can charge the port but will take some time...

HI,

i found a pdf on internet from Microchip that has the following formula and example to calculate it:

and IG = QG/t(transition) where: QG is the total gate charge, as defined above CEI is the equivalent gate capacitance VGS is the gate-to-source voltage IG is the gate current required to turn the MOSFET on in time period t(transition) t(transition) is the desired transition time For example: Given: N-Channel MOSFET VGS = 10V t (transistion) = 25nsec Find: Gate drive current, IG. From the MOSFET manufacturer’s specifications, QG = 50nC at VGS = 10V. Using IG = QG/t(transition): IG = QG/t(transition) = 50 x 10-9/25 x 10-9 = 2.0A in mycase it almost the same as in Vgs5 Volt its 48nC and for a rise time of 84ns it should be:

Ig=Qg/T(rise)=48/84=0.5 to 0.6A ideally.

so it does not wok :P.

what transistor can i use to open the irlr2905? any ideas?

Timi

i check again,

can i use the 2n2222a with a Hfe min of 30 for IC 500mA that responds to approx 16mA of Ib as from the formula ib = Ic / hFE(min) or 23mA for IC 700mA. So Rb is 186~260 ohms. Right? i am rusty right now :). does a 220 Ohm make the job here as Rb.

Timi

Hi Guys,

i found to my disappointment that the leonardo has no pwm higher than 500hz or so. When i bought it, i thought that as it had pwm pins it would have some docs “libs” to handle them but as far as i search there is no one.

Guys my question is how can i make the pwm with the timers and register without screwing up the usb connection. i tried the code bellow. It compiles fine but after uploading, i lost usb connection and leonardo is not recognized. i pressed upload and just after compiling finished i pressed reset on board to get the new empty sketch uploaded and have the Leonardo recognized again:

#define TIMER4_RESOLUTION 1023UL
#define PLL_FREQ 48000000UL

unsigned long pwmPeriod = 0;
ISR(TIMER4_OVF_vect) {}

void enable_intr(){
TIMSK4 = _BV(TOIE4);
}

void disable_intr(){
TIMSK4 = 0;
}

void initialize(unsigned long freq) {

/* Init the internal PLL */
PLLFRQ = _BV(PDIV2);
PLLCSR = _BV(PLLE);
while(!(PLLCSR & _BV(PLOCK)));
PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */

TCCR4A = (1<<PWM4A);
TCCR4E = (1<<ENHC4);
TCCR4D = (1<<WGM40); //set it to phase and frequency correct mode
TCCR4C = 0;
setPeriod(freq);
}
void setPwmDuty(unsigned int duty) {
unsigned long dutyCycle = pwmPeriod;
dutyCycle *= duty;
dutyCycle >>= 9;
TC4H = (dutyCycle) >> 8;
OCR4A = (dutyCycle) & 255;
}

void start() {
TCCR4A |= _BV(COM4A1);
}
void stop()  {
TCCR4A &= ~(_BV(COM4A1));
}

void setPeriod(unsigned long freq)  {
unsigned long cycles = PLL_FREQ / 2 / freq;
unsigned char clockSelectBits = 0;

if (cycles < TIMER4_RESOLUTION) {
clockSelectBits = _BV(CS40);
pwmPeriod = cycles;
} else
if (cycles < TIMER4_RESOLUTION * 2) {
clockSelectBits = _BV(CS41);
pwmPeriod = cycles / 2;
} else
if (cycles < TIMER4_RESOLUTION * 4) {
clockSelectBits = _BV(CS41) | _BV(CS40);
pwmPeriod = cycles / 4;
} else
if (cycles < TIMER4_RESOLUTION * 8) {
clockSelectBits = _BV(CS42);
pwmPeriod = cycles / 8;
} else
if (cycles < TIMER4_RESOLUTION * 16) {
clockSelectBits = _BV(CS42) | _BV(CS40);
pwmPeriod = cycles / 16;
} else
if (cycles < TIMER4_RESOLUTION * 32) {
clockSelectBits = _BV(CS42) | _BV(CS41);
pwmPeriod = cycles / 32;
} else
if (cycles < TIMER4_RESOLUTION * 64) {
clockSelectBits = _BV(CS42) | _BV(CS41) | _BV(CS40);
pwmPeriod = cycles / 64;
} else
if (cycles < TIMER4_RESOLUTION * 128) {
clockSelectBits = _BV(CS43);
pwmPeriod = cycles / 128;
} else
if (cycles < TIMER4_RESOLUTION * 256) {
clockSelectBits = _BV(CS43) | _BV(CS40);
pwmPeriod = cycles / 256;
} else
if (cycles < TIMER4_RESOLUTION * 512) {
clockSelectBits = _BV(CS43) | _BV(CS41);
pwmPeriod = cycles / 512;
} else
if (cycles < TIMER4_RESOLUTION * 1024) {
clockSelectBits = _BV(CS43) | _BV(CS41) | _BV(CS40);
pwmPeriod = cycles / 1024;
} else
if (cycles < TIMER4_RESOLUTION * 2048) {
clockSelectBits = _BV(CS43) | _BV(CS42);
pwmPeriod = cycles / 2048;
} else
if (cycles < TIMER4_RESOLUTION * 4096) {
clockSelectBits = _BV(CS43) | _BV(CS42) | _BV(CS40);
pwmPeriod = cycles / 4096;
} else
if (cycles < TIMER4_RESOLUTION * 8192) {
clockSelectBits = _BV(CS43) | _BV(CS42) | _BV(CS41);
pwmPeriod = cycles / 8192;
} else
if (cycles < TIMER4_RESOLUTION * 16384) {        clockSelectBits = _BV(CS43) | _BV(CS42) | _BV(CS41) | _BV(CS40);        pwmPeriod = cycles / 16384;     }  /*else           clockSelectBits = _BV(CS43) | _BV(CS42) | _BV(CS41) | _BV(CS40);        pwmPeriod = TIMER4_RESOLUTION - 1; */            TCCR4B = clockSelectBits;             TC4H = pwmPeriod >> 8;
OCR4C = pwmPeriod;

}

void setup() {

pinMode(13, OUTPUT);
digitalWrite(13,LOW);
initialize(123456);  // Frequency to generate in Hz
setPwmDuty(512);     // Duty cycle 0-1024, 1024 is 100%, 512 is 50%
start();

}
void loop(){
}

any help is appreciated. i just started with Arduino so be gentle with me ;).

Timi

Aliaj00: what transistor can i use to open the irlr2905? any ideas?

Simple, use a MOSFET driver chip. I like MIC4422 and MIC4420's but that might be overkill. Certainly would charge the gate fast enough. Simpler than fiddling with transistors - just remember to use enough decoupling.