1
\$\begingroup\$

I have a blue LED which I want to dim using an Arduino, an optocoupler and an N-MOSFET.

For achieving this I assembled the circuit on a breadboard as shown in the pictures, using a YwRobot breadboard power supply to provide power to the optocoupler's transistor, and the MOSFET. I used the Fading example sketch from the Arduino IDE.

When I try to dim the LED in this basic configuration: \$(PWM_{out} → Resistor → LED → Ground)\$
The LED slowly lights up, reaches its maximum, then slowly dims, then the cycle repeats as it should in this case.

But in the circuit it behaves weirdly.
It doesn't dim, it's on full brightness, but when the cycle reaches again zero voltage, it's turned off. No sign of any change in the brightness.
I tried modifying the delay of the cycle and I used a multimeter to measure the LED's voltage. As soon as the cycle moved from turned off state \$(0V)\$ to a slightly higher voltage (I used 1 unit increments in analogWrite and 4 second delay) the LED was on full brightness \$(2,8V)\$.

I don't know what's going on. Maybe I don't need one of the resistors on the optocoupler's BJT side? I tried taking the \$R_3\$ resistor out but then the LED was always on, didn't even bother to turn off so I put it back.

Questions:

  • What should I change in the circuit to make the LED dim like in the basic configuration?
  • Do I need current limiting resistors for the BJT both on the emitter and the collector side \$(R_2, R_4)\$ in this case? I know that in the case of FETS, the \$I_D=I_S\$, so one resistor \$(R_6)\$ is enough.


Here are the schematic and the Fritzing project: Arduino_YwRobot_Optocoupler_MOSFET_LED_EAGLE Arduino_YwRobot_Optocoupler_MOSFET_LED_FRITZING
Datasheets:
4N35M optocoupler datasheet
IRLZ34N n-mosfet datasheet

\$\endgroup\$
7
  • 1
    \$\begingroup\$ This is a wild guess, but r4 seems unnecessary, and r3 seems way to small for a proper bleed resistor. Depending on the fets capacitance, it's simply not shutting off fast enough? \$\endgroup\$
    – Passerby
    Jan 31, 2016 at 4:34
  • 2
    \$\begingroup\$ @passerby - don't you mean R3 is way to big? \$\endgroup\$
    – brhans
    Jan 31, 2016 at 4:41
  • 1
    \$\begingroup\$ Can you try measurimg the voltage @ OK1, pin4 please? My theory is that you're overdriving either the optocoupler or the MOSFET, which is causing all used signal levels to simply "max out" the led. (That, or try running it without OK1, just using the MOSFET in voltage-follower configuration). \$\endgroup\$ Jan 31, 2016 at 4:48
  • \$\begingroup\$ @brhans, large resistance, to small current, yes, my mistake. \$\endgroup\$
    – Passerby
    Jan 31, 2016 at 5:03
  • 1
    \$\begingroup\$ @domenix 4,575V is definitely looking like the optocoupler is being overdriven. Either you're going to want to reduce the power being fed to the optocoupler (bleed resistor between PWM and ground in your diagram), or fimd another way to isolate/protect your 'duino without losing linearity (if OK1 won't function reliably at any reasonable input level). FYI: Being an incredibly high-impedance device, a power MOSFET (in my opinion) should provide a pretty huge degree of protection for your arduino on its own (check the Drain-Gate and Gate-Source leakage/isolation in the datasheet). \$\endgroup\$ Jan 31, 2016 at 5:11

1 Answer 1

3
\$\begingroup\$

power mosfets have significant gate capacitance and your gate drive is significantly unbalanced.500 ohms to charge and 600K to discharge that's about 100:1 no wonder the PWM osn't showing results.

replace R3 with 1K replace R2 with a wire, that will give a stronger disharge drive and should work better.

\$\endgroup\$
8
  • 1
    \$\begingroup\$ When I replaced R2 with wire and R3 with a 1k resistor, it didn't work but when I kept the R2 and changed R3 with a 2k resistor, it worked perfectly. Now it works as it should be. Thank you and @Passerby very much! \$\endgroup\$
    – domenix
    Jan 31, 2016 at 6:01
  • \$\begingroup\$ @Passerby I don't really get what you are suggesting. What should I change? By the way I removed the R4, and it works so it was indeed unnecessary. \$\endgroup\$
    – domenix
    Jan 31, 2016 at 6:34
  • \$\begingroup\$ I'd also suggest moving to a low side setup. A npn optó is better suited to pulling the collector instead of the emitter high. It would require inverting the arduino pwm logic, but that's simple. \$\endgroup\$
    – Passerby
    Jan 31, 2016 at 6:35
  • \$\begingroup\$ R2 and r4 served the same purpose. But the optó is a npn based transistor. It works better as a low/ground side switch than it does a high/vcc side switch. As is, the emitter is pulled to the base voltage drop of 0.7V or so. I'll link to the relevant information tomorrow when I'm at home. You can Google common emitter for more info. \$\endgroup\$
    – Passerby
    Jan 31, 2016 at 6:38
  • 1
    \$\begingroup\$ @passerby, because it's isolated it doesn't make any difference with an optotransistor whether it's used high-side or low side. If it were an ordinary transistor being drived by a voltage signal into the base though, common collector would be the way to go. \$\endgroup\$ Jan 31, 2016 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.