Wiring an NPN NC inductive proximity switch

Home Forums TinyG TinyG Support Wiring an NPN NC inductive proximity switch

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #10201
    pfelecan
    Member

    I’m a real beginner in electronics: I learn as needed and
    the curve is quite steep.

    Using a TinyG v8 I wish to use homing and limit switches.

    I think that I understand how to use a mechanical spring
    micro-switch and testing it gives good results. Here is my
    test protocol:

    1. wire the switch as shown in the attached schema
    2. $st=1 ; set the switches type to NC
    3. $ysn=2 ; set the minimum Y axis switch as a limit
    4. activate the switch
    5. observe that the SpDir LED flashes

    Note that I’m using a limit because is the only way to
    observe the effect of activating the switch.

    However, for an inductive proximity switch I have some
    doubts concerning the connection to the TinyG.

    The one that I wish to use is an NPN NC powered from a 12V
    PSU. In normal state, the tension between the – and s pins
    is 12V and when a detection is made the circuit is open
    and consequently the tension is 0V.

    As the TinyG input is 3.3V I’m using a set of resistors to
    pull down the tension between the – and s pins and thus
    I’m measuring 3.3V between these pins.

    I think that the switch should be connected as shown in
    the attached schema; I put in the schema a voltmeter just
    for reference.

    Is this correct?

    The simplified schema can be found here https://drive.google.com/file/d/0B5X2WpozISvuRmp4T0pTSER2OGs/view?usp=sharing

    #10202
    cmcgrath5035
    Moderator

    I think I know what you want to do, but your description has me a bit confused.

    Specifically – if you have an “NPN” proximity switch, I would expect the the output lead to be near zero, the closed state (“NC”)when not operated, and I would expect the output to rise to 12V when the proximity switch is activated.

    It might be helpful if you post a URL or PDF of the specific device you are considering.

    Looking at your schematic , you are using a 4170 ohm resistor (270+3.9K) to pull down on the internal pullup in the proximity switch. There is some risk that the effective pull up resistance of the prox switch might vary and could result in more than 3.3v input to tinyG .

    #10203
    pfelecan
    Member

    Thank you for your answer.

    The issue with these cheap inductive proximity switches is the difficulty to find reliable, i.e. non contradictory documentation. I bought them as NPN NC and, in my foggy understanding, the behavior is NC, i.e the circuit is closed (conducting) when not detecting. This is why I use an empirical method to determine what should be done.

    The only data-sheet that I found on the LJ12A3-4-ZBX is:
    https://www.alibaba.com/product-detail/M12-Cylinder-inductive-proximity-switch-LJ12A3_60380094925.html

    From what you’re writing I understand that you are worrying about a variability of the device’s resistance which will make a variation in the overall characteristics of the circuit and the value of my resistors will have a different effect, i.e. the voltage can be higher or lower than what’s expected.

    Still, I have 2 questions:

    1. is the circuit diagram correct?
    2. what’s the most reliable solution when using these devices to reliably pull-down the tension toward the TinyG?

    TIA

    #10204
    cmcgrath5035
    Moderator

    I scraped this from the URL you provided:

    M12 Cylinder inductive proximity switch LJ12A3-4-Z/EX sensing range 4mm non-flush 2wires system NO 6-36VDC

    Here is a URL for a typical NPN prox sensor

    From my quick look at your URL, you purchased a “NO” (normal open) switch.

    If your switch was a “NC”, the circuit diagram would possibly work with the issue I raised, and you correctly understand, that the 4170 ohm pulldown load may not be adequate to ensure that the Vin is a maximum of 3.3v under all conditions.

    The tinyG ports have a pull-up resistor on the PCB, for tinyGV8h that pullup is 2.7Kohms

    So when no switch is connected to a port pin, the port voltage is held high state.

    There are many solutions folks have implemented.

    IF you did have a NC prox switch, connecting a diode between the port pin and the output of the prox switch would work. Anode of the diode to the port pin, Cathode of the diode to prox switch. Diode would allow a low state prox switch to pull the port down to 0.7V (assume silicon diode) but would block 12V from the port pin, assuming you chose a diode with adequate Vreverse, like 20V.

    IF you want to use your NO switch, you need to invert the signal. Here are some ways

    The Opto-Isolator method is by far the safest, the opto isolates the 3.3V logic world from the 12V world. NOTE that the diagram above is for an Arduino UNO, which is 5V logic, you would reduce the “Arduino +5” to 3.3V for tinyGV8.

    Hope that helps

    #10205
    pfelecan
    Member

    Thank you for the pointers and for the additional information.

    I must confess that there is confusion on what really means NO and NC. I found at least 2 contradictory definitions. But maybe it is my understanding which is deficient.

    The 2 next exploration paths will be to use an optocoupler or a SSR to ensure isolation. The first one seems to be a lot cheaper and compact but the second one is easiest to implement as everything is supported without additional components.

    For completeness and validation I’ll come back in a few days with the results of my experiments and eventual schema.

    #10206
    cmcgrath5035
    Moderator

    SSRs are typically for Power switching – e.g. turning off 110V or 220V mains with logic.
    Would be overkill for limit switch interface.
    They can be useful for on/off control of small routers when used as spindles.

    #10207
    pfelecan
    Member

    Yeah, I know, using an SSR is a desperate mean and a perfect illustration of the syndrome of knowing how to use a hammer so that everything seems to be a nail. However, functionally it’s a valid solution even though a little bit over-engineered, isn’t it?

    #10210
    cmcgrath5035
    Moderator

    Probably, but depends on the SSR you are looking at.
    Some SSRs are only engineered to switch AC loads, you need DC.
    Most SSRs are optoisolator Front-ends with high power control backends

    #10211
    pfelecan
    Member

    The SSRs that I’m using for that part of the experiment are:

    – Schneider Electric 3 A SPNO Solid State Relay, DC, PCB Mount MOSFET, 60 V dc Maximum Load
    – Schneider Electric 5 A SPNO Solid State Relay, DC, Panel Mount MOSFET, 60 V dc Maximum Load

    The one that I used for the spindler start/stop (Spin) is “Carlo Gavazzi 25 A SPNO Solid State Relay, Zero, Panel Mount, 265 V ac Maximum Load”

    For the pure opto-coupler par I’m discovering the following OKs:

    – Sharp PC817X2NSZ0F DC Input Transistor Output Optocoupler, Through Hole, 4-Pin PDIP
    – Fairchild H11F3M DC Input Transistor Output Optocoupler, Through Hole, 6-Pin PDIP

    #10213
    cmcgrath5035
    Moderator

    Either of those opto isolators should work fine, as long as you have reasonable soldering skills.

    #10224
    pfelecan
    Member

    Here is a follow-up:

    I’m using an opto-coupler to isolate the inductive
    proximity switch and the input to the X min of the
    TinyG. Unfortunately it doesn’t work as expected.

    The schema of the circuit is https://drive.google.com/file/d/0B5X2WpozISvuV2pjY004eEZESlU/view?usp=sharing

    The inductive proximity switch LJ12A3-4-ZBX is connected
    to a 12V PSU as follows: the brown wire to the positive,
    the blue wire to the negative. When the IPS does not
    detect the tension on the black wire (the signal) is 12V;
    when the IPS detects the tension drops to 0V.

    In order to use an opto-coupler, the Sharp PC817, I connect
    the signal to a resistor of 808 Ohm which is connected to
    the anode of the opto-coupler; the cathode is connected to
    the ground of the PSU. The collector is connected to the
    Xmin on the J7 of the TinyG and the emitter to the ground
    on the same bank.

    In this configuration, the tension measured between the
    collector and the emitter is of 3.3V when the IPS is not
    detecting and, as expected, the tension drops to 0V when
    the IPS is detecting.

    I’ve set the switches type to NC with $st=1.

    The Xmin type is set to limit with $xsn=2.

    However, the board is not reset and the SpDir LED
    doesn’t flash when the IPS detects.

    Just for completeness I tried with the $st=0 but to no
    avail. Also tried the Zmax because it works with a
    micro-switch. Finally, I tried also to reverse the
    connection on the collector/emitter side to Gnd/Xmin.

    I saved the board’s configuration https://drive.google.com/file/d/0B5X2WpozISvub21aek90eUExQWs/view?usp=sharing

    My two questions are:

    1. Is the circuit correct?

    2. If the circuit is correct, why the limit tripping is
    not detected?

    #10225
    pfelecan
    Member

    What follows will show how ingenuous I am in electronics.

    In short, the circuit that I’ve shown in my previous
    message works.

    What I ignored in the experiment’s presentation is that I
    put a voltmeter between the emitter of the optical-coupler
    and the ground of the TinyG, serial. Thus, in this
    configuration I measure 3.3V when the proximity switch
    doesn’t detect and 0V when it detects.

    When I put the voltmeter in parallel, i.e. between the
    emitter and the collector of the optical-coupler I measure
    1.04V when the proximity switch does not detect and 3.41V
    when it detects and of course the limit is tripped as
    expected.

    If I follow an empirical instinct I would say that if it
    works it satisfies my needs and I let it be. But, my
    mathematics education is aggravated and I would like to
    understand.

    So, if there is somebody who can shed light on what I’m
    observing and help me understand I would be eternally
    thankful.

    #10226
    cmcgrath5035
    Moderator

    I am not sure what part you don’t understand

    An “ideal” voltmeter has infinite impedance, practical voltmeters have ‘really high’ impedance.
    Ideal ammeters have zero impedance, practical ammeters have very low impedance.

    Voltmeter “in series” is seldom the right way to do/measure something.
    I am very confused, however, as to how you can measure 3.41V in a 3.3V system.
    What does that same voltmeter read when measuring the 3.3V supply?

    #10227
    pfelecan
    Member

    When I’m measuring the 3.3V supply, i.e. between Gnd and 3.3V sockets on the J7 terminal block I get 3.415V; the same on J8.

    By the way, I was quite surprised to see that when you activate the Spin with M03 the voltage is varying between 3.1V and 3.3V measured between the Spin and Gnd on J6, but that it’s another story.

    #10228
    pfelecan
    Member

    Just a note on the previous message, I’m measuring 3.3V on the output of a laboratory power supply when its output is on 3.3V. Consequently I don’t think that the meter is in question.

Viewing 15 posts - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.