optoisolator instead of an npn to switch a p-channel mosfet

Discussion in 'The Projects Forum' started by Simy, Aug 22, 2013.

Thread Status:
Not open for further replies.
  1. Simy

    Thread Starter New Member

    Aug 8, 2013
    7
    0
    I found the schematic here: http://electronics-diy.com/electronic_schematic.php?id=1012
    I plan to use a microcontroller to control several things, mostly changing lights. In order to get around the problem of current draw I figured I would use a p-channel mosfet.

    Later I learn that optoisolators are a good idea, though I'm not really sure why so I order some and try to use them. The specific ones I got were Sharp PC900V's Looking at the schematic it looks just like an NPN transistor. I try to use it and it works. Great. I put another one on, and the first one will no longer turn off, and in fact nor will the second one.

    Through trial and error I've narrowed it down to some sort of interaction between the two. I'm not quite sure what the problem is, how to avoid or what I need to research. I learn best by doing, and so I'm doing, and I think I'm doing this wrong. If I've missed something basic, please feel free to point out what I should try to reread.

    I can rework the circuit to go from the optoisolator to an npn to the p channel mosfet, but to me that just seems silly, unless that is the only way to do it.

    Some things I've noticed
    If I remove the second LED, the first light will go out, unless its on using the optoisolator.
    If its on by itself (without the optoisolator) then it is notably brighter.
    Removing the vcc or ground from the optoisolator will turn that LED off, but leave the other one on. I suspect its an interaction from mosfet to mosfet somehow.
    If the second one is removed from the board, I can touch the positive side and it will turn the light, I can turn it off by turning it on using the optoisolator, and then off again. When I do this it will go dim when its turned on, then go off, unless I touch the lead in doing so.
    [​IMG]

    Thank you in advance for helping me out with this, I've been pulling my hair out for a couple weeks just trying to figure out how to get the optoisolators to do anything...
     
  2. wayneh

    Expert

    Sep 9, 2010
    12,115
    3,039
    How about a sketch of your schematic?
     
  3. tindel

    Active Member

    Sep 16, 2012
    568
    193
    A schematic will be helpful... However, opto isolators are used to isolate two points - there are times that you need physical isolation between two things, but need communication between the two... a opto communicates between two things using light, but are physically isolated because they don't physically touch. The most common example is in a switch-mode power supply, an opto is used to provide feedback to the primary side while providing physical isolation between the primary and secondary.
     
  4. Simy

    Thread Starter New Member

    Aug 8, 2013
    7
    0
    I'm not very good at drawing some things, I did it kinda quick on a whiteboard but its what I should have had and not what I actually had so I took everything apart and built it back up from scratch being very picky on what components I used, and this time I did three of each. I had very strange symptoms as before.

    Instead of powering the mosfet from the 3v3 rail, I thew some resistors on the LED's and fed them the power supply voltage (ranges between 11.9-12.1 or so depending on what lights I have on, and if I'm cooking something on a breadboard or not.


    Just to see if I understand what happened here I would like to take a guess. The mosfet was never fully turned off being fed 3.3v, and was literally right at its threshold, and I'm assuming acting more like a diode then a transistor. Does this sound about right?


    [​IMG]

    And this is what is currently working...
    [​IMG]
     
  5. Simy

    Thread Starter New Member

    Aug 8, 2013
    7
    0
    Would I be correct in assuming that protecting a sensitive microcontroller from RF, motor spikes, and other hazards is one of those situations, or does this not really apply?

    While we are at it, should this be done to inputs as well, I was going to but I'm not sure if I need to in most instances and I think it may just complicate things.

    The end goal will be an RV automation system. I have a bus I'm converting to an RV but the electrical system is hosed, so I figure instead of running all new wires I would try my hand at this and just expand as I go. I have a rough idea on how I want to do it, I'm just filling in the details as I more or less learn that it is something I need to fill in.
     
  6. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
Loading...
Thread Status:
Not open for further replies.