Arduino Forum

General Category => General Discussion => Topic started by: yudopplyr on Apr 13, 2014, 12:17 am

Title: Can't figure out how to use pwm with an optocoupler and a MOSFET
Post by: yudopplyr on Apr 13, 2014, 12:17 am
Hi guys, I'm trying to use the pwm signal from my arduino to control a motor with 12v, I'm following this diagram, with the exception I'm using an IRF540:

(http://i.imgur.com/CmcYGAE.png)

Is there anything wrong on the diagram above? The only way I was able to use the pwm signal was with this other diagram but this one doesn't use an optocoupler:

(http://engenhocas4you.files.wordpress.com/2012/04/trsw07.jpg)

I'd like to know how can I work out the other diagram too.
Title: Re: Can't figure out how to use pwm with an optocoupler and a MOSFET
Post by: CrossRoads on Apr 13, 2014, 01:46 am
Top one looks fine.
When Arduino output is  high, LED will light, will turn on NPN to pull MOSFET gate low & turn off the motor. Otherwise MOSFET is on.

I see IRF530 shown as both N-channel and P-channel
http://www.digikey.com/product-search/en?x=0&y=0&lang=en&site=us&KeyWords=irf530
Do you have a complete part #?
Title: Re: Can't figure out how to use pwm with an optocoupler and a MOSFET
Post by: yudopplyr on Apr 13, 2014, 02:10 am
Not really, in the diagram it didn't specify that. What would you recommend me to check out if I'm connecting wrong the circuit?
Title: Re: Can't figure out how to use pwm with an optocoupler and a MOSFET
Post by: CrossRoads on Apr 13, 2014, 04:08 am
The circuit is correct, if you don't have parts yet make sure you get an n-channel part.
Title: Re: Can't figure out how to use pwm with an optocoupler and a MOSFET
Post by: Paul__B on Apr 13, 2014, 05:43 am

I see IRF530 shown as both N-channel and P-channel
http://www.digikey.com/product-search/en?x=0&y=0&lang=en&site=us&KeyWords=irf530


Now that is a bizarre arrangement, bound to cause big trouble!
Title: Re: Can't figure out how to use pwm with an optocoupler and a MOSFET
Post by: yudopplyr on Apr 13, 2014, 09:14 pm
At the end my IRF540 didn't work, so I bought a IRF530 N Channel, the circuit is working now using the first diagram as I linked, thanks for the help.

Note: I added a 10k resistor to ground connected to the Gate, is it ok, or should I remove it?
Title: Re: Can't figure out how to use pwm with an optocoupler and a MOSFET
Post by: Paul__B on Apr 14, 2014, 12:35 am

Note: I added a 10k resistor to ground connected to the Gate, is it ok, or should I remove it?


It's not necessary - either the optocoupler is off, in which case the FET is turned on, or when the optocoupler is on, it is pulling the gate to ground.  The resistor is only necessary when you are driving the gate directly from a microcontroller pin which may be neither "on" or "off" as the program is starting up.
Title: Re: Can't figure out how to use pwm with an optocoupler and a MOSFET
Post by: tempo1218 on Apr 22, 2014, 07:39 am
How are resistors (R2 and R3 ) chosen for mosfets? How are they calculated?
Title: Re: Can't figure out how to use pwm with an optocoupler and a MOSFET
Post by: Paul__B on Apr 22, 2014, 10:14 am

How are resistors (R2 and R3 ) chosen for mosfets? How are they calculated?


Sheer necromancy!

R2 and R3 relate to the fact that the gate of the FET is highly capacitive and its switching speed is limited by how fast you can charge and discharge the gate.  R2 in particular needs to be fairly low - you can calculate just how fast you need it to switch and work on that and the gate capacitance to derive the value.

R3 is a curious matter - I am not quite sure what it does.  The opto-coupler has a transfer factor, so the actual current it can draw is constrained, but if it is commutating rapidly, it may be preferable to have it saturate in order to pull the gate down, so that its power dissipation is minimised.