586,556 active members*
3,410 visitors online*
Register for free
Login
IndustryArena Forum > CNC Electronics > CNC Machine Related Electronics > Invert the output from an opto switch
Results 1 to 16 of 16
  1. #1
    Join Date
    Sep 2010
    Posts
    76

    Invert the output from an opto switch

    Howdy all

    The router build is coming along well, cold weather means I am indoors doing fiddly things instead of the shed so the opto home switches are on the agenda.

    I am using the circuit as per http://www.cnczone.com/forums/genera..._switches.html and many other threads and have the LED flicking off and on just fine.

    My issue is, how do I get this to work as ON when the opto is clear, i.e. not blocked. I want to use the switches as NC so that a power failure or cable fault on the opto circuit will cause an alert on Mach3.

    Thanks for any suggestions

    David

  2. #2
    Join Date
    Jan 2010
    Posts
    2141
    Can't you reverse the 'sense' of the input by switching the Mach3 input signal definition from Active Low to Active High (or vice versa)?

  3. #3
    Join Date
    Sep 2010
    Posts
    76
    Quote Originally Posted by doorknob View Post
    Can't you reverse the 'sense' of the input by switching the Mach3 input signal definition from Active Low to Active High (or vice versa)?
    Yeah I can but if the power fails on that circuit or some other fault occurs, Mach3 wont see it.

  4. #4
    Join Date
    Jan 2010
    Posts
    2141
    There are several variations on the circuit described in that thread - do you have a diagram of how you actually have it wired?

  5. #5
    Join Date
    Dec 2003
    Posts
    24223
    You must have the 'Operate on Dark' version instead of the normal 'Operate on Light' type.
    The latter is the fail safe version you are looking for, which are normally ON when un-blocked.
    You could use a 2N7000 with pull up resistor on the gate to invert the output, use the same power source as the opto.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

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

  6. #6
    Join Date
    Sep 2010
    Posts
    76
    Thanks Al

    The opto is the ZD1901 from Jaycar here on Oz, http://www.jaycar.com.au/products_uploaded/ZD1901.pdf

    Wiring is like the pic attached.

    Could I trouble you to expand on the wiring for the FET, my electronics sort of stops about "First, turn on the soldering iron....."

    I have a few solid state relays I could use instead but it seems silly to use an $8.00 component when a $0.60 one would do the same job.
    Attached Thumbnails Attached Thumbnails Opto.jpg  

  7. #7
    Join Date
    Dec 2003
    Posts
    24223
    Looks to me like you have it connected wrong? No1 the device is already operate on light so you don't really need the inversion for safety reasons?
    If you put the LED in series with the collector instead of parallel it will switch but indicate when non-triggered, i.e. switch off when blocked.
    If this is an issue, and you want the inversion, the 2n7000 source pin connects to the emitter, the collector to the gate, and the drain pin would be the output, if you want to invert the LED indication then put it in series with the 2n7000 drain pin and whatever you are switching into if this is a BOB, if going into a P.P. then also use a 1k resistor on the drain to +5v and replace the gate 1k with a 10k.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

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

  8. #8
    Join Date
    Sep 2010
    Posts
    76
    Hi

    By "wrong" do you mean Collector and Emitter reversed ? I thought so too based on the other CNC Zone post but when i looked at figNoggle Designs: Photodarlington Optical Interrupter Switch Wiring How-To I wired mine the same way and got the result of blocked=LED On.

    Any chance you sketch what you think the wiring should be, I can test it this afternoon and report back. This particular opto is the one of choice for many of us in Oz as it is pretty much all you can get in the market at the retail level.

    Cheers

  9. #9
    Join Date
    Dec 2003
    Posts
    24223
    By wrong, I meant you could have wired the LED in series with the collector, just that it will light on non. shuttered (off), I can whip up a dwg to include the 2n7000
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

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

  10. #10
    Join Date
    Sep 2010
    Posts
    76
    Quote Originally Posted by Al_The_Man View Post
    I can whip up a dwg to include the 2n7000
    Al.
    That would be very generous of you, thanks

  11. #11
    Join Date
    Dec 2003
    Posts
    24223
    Something like this maybe, but I don't see why you need the inversion?
    Al.
    Attached Files Attached Files
    CNC, Mechatronics Integration and Custom Machine Design

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

  12. #12
    Join Date
    Sep 2010
    Posts
    76
    Thanks Al, I will drop by the local parts store and grab some trannies tonight.
    My opto must be the operate on dark type, as measured with the multimeter I get 0v at normal state and 4.99v against a Vi of 5.00 when I block the slot.

    Weired

    Thanks again for the schematics

  13. #13
    Join Date
    Sep 2010
    Posts
    76
    Got it working

    I think the issue is that the schematic for the ZD1901 as posted on Jaycar's site is wrong compared to the physical package; the collector and emitter are reversed on the output side.

    See the pictures attached, I get a nice steady five volts and the LED is lit as long as the slot is clear. As soon as I block the slot, the indicator LED goes out and the voltage drops to (almost) zero.

    Exactly what I wanted, thanks Al for the assist.
    Attached Thumbnails Attached Thumbnails Overview1.jpg   Overview2.jpg   Endstop Final.jpg  

  14. #14
    Join Date
    Dec 2003
    Posts
    24223
    Something looks wrong there, on a NPN transistor the emitter should go to common, not 5v+ as shown?
    Also the LED will be lit constantly the way it is shown?
    Actually checking the Jacar link, they do not show whether the transistor is NPN or PNP?
    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
    Join Date
    Sep 2010
    Posts
    76
    I cannot tell NPN or PNP, all I know is it works exactly as I wanted it to.
    Yes the LED is lit when the slot it open but goes out when I block it.

    Cheers

  16. #16
    Join Date
    Dec 2003
    Posts
    24223
    Unless there is a unexplained power connection, the diagram in post #13 the LED is shown across the supply and not switched?
    Where you have the 5v+ shown is that power or an input?
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

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

Similar Threads

  1. Opto switch
    By sivtek in forum Norwegian
    Replies: 3
    Last Post: 03-12-2010, 07:19 PM
  2. How to invert the output bit with Motenc lite
    By jatchan in forum LinuxCNC (formerly EMC2)
    Replies: 0
    Last Post: 04-23-2009, 08:26 PM
  3. Need Help with Picstep opto output board
    By ve3sjk in forum CNC Machine Related Electronics
    Replies: 1
    Last Post: 04-26-2007, 04:04 AM
  4. Need Help with Opto Switch
    By bcromwell in forum CNC Machine Related Electronics
    Replies: 3
    Last Post: 05-03-2006, 03:57 AM
  5. How to sense a switch with both opto-isolator and logic?
    By arvidb in forum CNC Machine Related Electronics
    Replies: 8
    Last Post: 09-01-2004, 04:04 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
  •