588,246 active members*
5,677 visitors online*
Register for free
Login
IndustryArena Forum > CNC Electronics > CNC Machine Related Electronics > Switching Relay From Optocoupler Output
Page 1 of 2 12
Results 1 to 20 of 24
  1. #1
    Join Date
    Aug 2009
    Posts
    17

    Switching Relay From Optocoupler Output

    Hi Guys,

    If you look at the attached schematic the blue box represents the driver board...

    The rest of the circuit is what i've come up with, please could someone with a better electronics knowledge tell me if it'll work?

    D.
    Attached Thumbnails Attached Thumbnails schematic2.jpg  

  2. #2
    Join Date
    Dec 2003
    Posts
    24220
    It looks like that would work, I notice you have not used the isolation the Opto brings, but if you are using the PC 5v and 12v then it does not really matter.
    I tend to use the 2N7000 for most interfacing, it does not require any current to operate like the 2N3906, et.al
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  3. #3
    Join Date
    Aug 2009
    Posts
    17
    Hi Al,

    The 5v source is regulated from the 24v used to power the controller and the 12v source will be the same...

    There is no electronic link between the parallel port and the controller...

  4. #4
    Join Date
    Dec 2003
    Posts
    24220
    If you have 24vdc, I would have tended to use that throughout, 24vdc relay etc.
    Also I would suspect you can eliminate R3 completely and it should still work OK.
    You did not say what control system you are using.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  5. #5
    Join Date
    Aug 2009
    Posts
    17
    Hi Al,

    R3 is inside my controller, the controller was included with my desktop cnc machine, controlled by Mach3, I need to operate some existing relays / solenoid valves and they are all 12v...

    Please could you describe how i would connect the 2N7000?

    D.

  6. #6
    Join Date
    Dec 2003
    Posts
    24220
    You could connect pin 4 of the opto to 5v+, pin 3 of the Opto to a 1k resistor, the other end of which is connected to common.
    Opto pin 3 also to the gate of the 2n7000.
    2N7000 source pin to common. Drain pin to the 12v or 24v relay.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  7. #7
    Join Date
    Aug 2009
    Posts
    17
    Hi Al,

    The reason i put the blue box around the original schematic was to show the components i have no control over..

    Most of the parts are SMD and i don't really want to start altering the board, If the opto had been wired to source rather than sink i would've connected it to a ULN2003, it has the protection diodes built in and can sink 500ma..

    Can the 2N7000 be driven from a sink?

    D.

  8. #8
    Join Date
    Dec 2003
    Posts
    24220
    Yes, the sink configuration you have would also work with a 2N7000, it is just the logic would be opposite, you could change that with the relay contacts if necessary (N.C or N.O).
    That was the reason I changed the Opto to a source device.
    Th 2N7000 is a voltage operated device rather than current, 0 to 5v, with I believe a switching voltage of around 3.5v on.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  9. #9
    Your circuit cannot work because the opto collector load 1K goes to +5VDC while the emitter of your PNP goes to 12VDC. When the opto is off, current flows from the PNP base, through the 10K and to your 5VDC supply through the 1K. The 3906 can never turn off.

    How to fix it:

    1) Change the opto collector 1K to 10K and take it to 12VDC instead of 5VDC.

    2) Use an NPN (3904). Emitter to GND, Base to opto collector and 3904 Collector to relay coil connected as a pull-up load to 12VDC.

    Option (2) uses the fewest parts: 1K pull-up and an NPN transistor. Option (1) requires a resistor change (10K instead of 1K) and moving the resistor end to 12VDC instead of 5VDC.

    If you use option (1), the 100K resistor does nothing useful because it's too large. Change it to 10K.

    Mariss

  10. #10
    Join Date
    Aug 2009
    Posts
    17
    Option 2 it is:

    Like that?

    I don't see how that can work, I thought NPN's we positively switched?

    Or is this pulled high by the 1K all the time until pulled low? (which is fine, and i would never have thought to do..)

    It would actually make sense because there is a NOT gate before the opto...

    D.
    Attached Thumbnails Attached Thumbnails schematic3.jpg  

  11. #11
    Lose the superfluous 1K to 5VDC and you have it. How it works:

    No opto LED current means no opto collector current. All the current flowing through the 10K goes into the base of the 3904 and turns it on.

    Opto LED current causes the opto collector to shunt the 10K current to GND. The opto collector drops below 0.7V which turns the 3904 off.

    ---------------------------

    If you want the relay coil off when there is no opto LED current:

    Take the opto collector to 12V. Place a 10K from opto emitter to 3904 base. Use another 10K from 3904 base to GND. Keep the rest of the circuit as is.

    Mariss

  12. #12
    Join Date
    Aug 2009
    Posts
    17
    Is there no other way around getting rid of the 1K?

    It is a 0805 on the controller board, and i need this circuit 3 times which means removing 3 resistors from a brand new controller thus invalidating the warranty..

    Thanks to everyone for all the help btw!

    D.

  13. #13
    OK, in that case:

    Keep the 1K. Take the base of the 3904 to the opto collector, the 3904 emitter to GND and the 3904 collector to the relay coil as you drew it in message #10.

    I had assumed the 1K and 5V was something you were planning to add.

    Mariss

  14. #14
    Join Date
    Dec 2003
    Posts
    24220
    This is why you need the 2n7000, this is designed to interface to 0 to 5v levels.
    You do not need any other component except the relay and diode.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  15. #15
    Al,

    Actually it's a toss-up. The opto collector 1K pull-up to 5V is needed either way for the NPN or the n-channel MOSFET. Both devices will perform the same out to about 200mA.

    Mariss

  16. #16
    Join Date
    Dec 2003
    Posts
    24220
    As the 1k to 5v is evidentally built in there is not much can be done there, in fact I am surprised at some of these interface boards that do not leave the Opto open for flexibility.
    I have been using the 2N7000 extensively for many years in designs and these types of cases, especially where TTL is involved, it has proven a very handy little device.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  17. #17
    Join Date
    Aug 2009
    Posts
    17
    Firstly i'd like to thank everyone who replied..

    I've sorted it, i've attached the schematic i used..

    It means that there is another level of protection to the controller board and it doesn't matter how its supplied, source or sink...

    Thanks again, i'll post a picture of the finished board once i get it milled, my Kress 1050 FME arrived today , spent half the day finding a company who could cut me a piece of 3mm steel 120mm x 70mm to make a bracket...

    Thanks again!

    D.
    Attached Thumbnails Attached Thumbnails schematic4.jpg  

  18. #18
    Join Date
    Dec 2003
    Posts
    24220
    That makes sense, I figured it was strange if they had fitted an Opto then made it essentially non-isolated by taking it to 5v without choice.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  19. #19
    D,

    I don't mean to belabor the point but you have to do something about the value for R6.

    The purpose of R6 is to keep your NPN from turning on when there are very tiny opto transistor currents. If R6 is 100K as you have it, the NPN will begin to turn on when the opto emitter current reaches 6 microamps (I = Vbe / R or 0.6V / 100K). 6 microamps is getting into the region of possible leakage currents in your circuit and your relay may falsely operate.

    If you make R6 a 10K resistor, the opto emitter current must be at least 60 microamps before the NPN can begin to turn on. This makes the circuit safe against uncommanded relay operation.

    Mariss

  20. #20
    Join Date
    Feb 2009
    Posts
    1290
    I found a web site with some circuits that might fit the bill.
    http://www.epanorama.net/circuits/parallel_output.html
    I reproduced one of the ASCII schematic here.
    I substituted transistor values for ones I have in my spares bin. I always go over what is needed therefore my transistor values might be a little ... overboard.
    Al if you wouldn't mind would you look over the circuit for errors?

    Thanks
    Brent
    Attached Thumbnails Attached Thumbnails Spindle_pwr.jpg  

Page 1 of 2 12

Similar Threads

  1. VFD switching a relay and kickback voltage
    By z28tt in forum Phase Converters
    Replies: 5
    Last Post: 12-06-2008, 01:26 AM
  2. Any plans for optocoupler circuit for parallel port?
    By mbwittig in forum CNC Wood Router Project Log
    Replies: 3
    Last Post: 01-31-2007, 01:09 PM
  3. Pwm switching
    By miro in forum Gecko Drives
    Replies: 0
    Last Post: 01-23-2007, 10:22 PM
  4. Need Datasheet NEC PS2510-4 Optocoupler
    By CJL5585 in forum CNC Machine Related Electronics
    Replies: 6
    Last Post: 12-08-2006, 12:55 AM
  5. optocoupler; opto-isolater
    By dhprc2 in forum CNC Machine Related Electronics
    Replies: 1
    Last Post: 06-02-2003, 06:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •