Home › Forums › TinyG › TinyG Support › Wiring an NPN NC inductive proximity switch
- This topic has 17 replies, 2 voices, and was last updated 7 years, 9 months ago by pfelecan.
-
AuthorPosts
-
January 30, 2017 at 9:58 am #10201pfelecanMember
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 flashesNote 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
January 30, 2017 at 9:14 pm #10202cmcgrath5035ModeratorI 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 .
January 31, 2017 at 3:27 am #10203pfelecanMemberThank 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.htmlFrom 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
February 1, 2017 at 6:19 am #10204cmcgrath5035ModeratorI 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
February 1, 2017 at 4:46 pm #10205pfelecanMemberThank 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.
February 1, 2017 at 8:38 pm #10206cmcgrath5035ModeratorSSRs 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.February 2, 2017 at 5:04 am #10207pfelecanMemberYeah, 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?
February 2, 2017 at 6:47 am #10210cmcgrath5035ModeratorProbably, 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 backendsFebruary 2, 2017 at 8:36 am #10211pfelecanMemberThe 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 LoadThe 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 PDIPFebruary 2, 2017 at 9:45 pm #10213cmcgrath5035ModeratorEither of those opto isolators should work fine, as long as you have reasonable soldering skills.
February 8, 2017 at 10:44 am #10224pfelecanMemberHere 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?February 9, 2017 at 10:17 am #10225pfelecanMemberWhat 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.February 9, 2017 at 10:17 pm #10226cmcgrath5035ModeratorI 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?February 11, 2017 at 8:36 am #10227pfelecanMemberWhen 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.
February 11, 2017 at 8:39 am #10228pfelecanMemberJust 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.
-
AuthorPosts
- You must be logged in to reply to this topic.