Driving IR LED with a MOSFET

Hello Forum Experts

I am having a problem while driving an IR LED @38kHz with a MOSFET.

A bit of background info: I am trying to create a beam detection system for 49 IR LED sensors pairs hence needing to drive the LEDs with a MOSFET. Now when I drive the LED directly from the Arduino pin everything works correctly and the beam detection functions as excepted. But as soon as I connect the MOSFET circuit the receiver gives me erratic feedback, it pulses the output. Even when I disconnected the LED the receiver output still toggles erratically so this tells me that I am getting interferance from the MOSFET ? I tried adding a 220Ohm resister between the arduino output and the MOSFET gate and it seemed to reduce the noise but it is still persistent.

Any Ideas on what I am doing wrong or how to fix the erratic feedback ?

I am using the IRLB8721 MOSFET and VS1838B IR Reciever.

I have attached the schematic that I am using for testing.

And here is the code I am using to Test:

const byte IR_LEDpin = 3; // IR transmitter LED with 100ohm (minimum) CL resistor
const byte Inpin = 2;
const byte LED = 7;

boolean State;

void setup() {
  pinMode (IR_LEDpin, OUTPUT);
  pinMode (Inpin, INPUT);
  pinMode (LED, OUTPUT);
  //TCCR2A = _BV (COM2A0) | _BV(WGM21);
  //TCCR2B = _BV (CS20);
  //OCR2A =  209; // ~209 = ~38kHz | ~219 = ~36kHz
  Serial.begin(9600);
}

void loop()
{
  //State = digitalRead(Inpin);
  
  delay(500);
  tone(IR_LEDpin, 38000);
  delayMicroseconds(300);
  digitalWrite(LED,!digitalRead(Inpin));
  State = digitalRead(Inpin);
  Serial.println(State);
  delayMicroseconds(300);
  noTone(IR_LEDpin);
  delayMicroseconds(900);
}

That MOSFET is not logic level and will not turn on fully with 5V to the gate. Misread the data sheet.

A 2.2K gate resistor will not improve things. The gate resistor, if present, should be as low a value as possible to charge the gate capacitance quickly but large enough value to limit the inrush current to the gate capacitance to protect the Arduino output.

The LED current limit resistor value in the schematic reads 10K to me. Is it 100 or 10K?

The resistor is 10K, the sensor pair are in very close proximity so anything less and the receiver would pick up unwanted reflections. Without the MOSFET the beam detection works very well. But as soon as the MOSFET is connected things go haywire. Even with the LED completely disconnected the output of the receiver is pulled low.

Have you tried any other MOSFET? The IRLB8721 is a relatively high power device, which means significant gate capacitance, which means a limitation on its frequency response. A 60A device to drive an LED seems like overkill, to say the least.
S.

I had them lying around from a previous project so I thought Id use them. I need to drive 49 LEDs though.

49 LEDs is still on the order of an amp or less, unless they're high power units. Using what you have on hand makes perfect sense ... as long as it's appropriate to the need.

Try using a smaller MOSFET... OR driving the existing one at only a few hertz, to see if gate capacitance is causing problems at higher frequencies.
S.

The LEDs current is up to 100ma each so 4.9 Amp max, but I wont be running that high. I will look for something smaller around 5 amp or less.

Wessel0203:
Hello Forum Experts

I am having a problem while driving an IR LED @38kHz with a MOSFET.

Any Ideas on what I am doing wrong or how to fix the erratic feedback ?

Look at the datasheet for the VS1838B: VS1838B Receiver Datasheet pdf - Infrared Receiver. Equivalent, Catalog

Its has a suggested circuit - you are not using it. In particular you have no supply decoupling
and no pull-up on the output. The latter you could fix with INPUT_PULLUP for inPin, but the
former is fundamental - they recommend 100nF ceramic in parallel with 100µF electrolytic,
and a 100 ohms series resistor in the supply - that's all there to prevent interference like you
are seeing.

Thank you Sir, I did not even see the circuit. I will try that.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.