I'm trying to build out an optocoupler circuit to connect a new proximity sensor to my 3D printer and want to understand how it behaves before implementing.

It's a Printrbot Simple Metal, Printrboard R5, and the stock Z-probe is a 4mm inductive sensor, LJ12A3-4-Z/BY - PNP N.O, and this plugs directly into the input on the board. It's a 12V system, and this particular board is fine with 12 V on the Z input.

The old probe gives me 0 V from Black to Gnd when not activated, and when activated gives the full 12V. Makes sense, normally open (no current flow), and when triggered, closes and gives a 12 V signal.

I have the circuit outlined below and it works the way I want - when the proximity sensor picks up metal nearby, the 817 is triggered and my output works (Led turns on). The new probe - LJ18A3-8-Z/BX is NPN NO with an 8mm sensing distance. When not triggered it gives me 12 V from black to ground, and when triggered gives me 0.7V black to ground. So basically a gives a low signal when triggered.

With the optocoupler, I think what's happening is this:
black is 12V when not triggered, high on input, PIN 1, basically both at 12V, no current flowing from black to GND. And when the sensor is triggered, the black line goes low (12v - 0.7 for the transistor in the sensor), so I get a positive potential diff from black to ground, triggering the 817.

Does this sound right?

Also, I can't for the life of me figure out a configuration that would use the old sensor (high signal) with the same 817. Any thoughts? I gather I can't easily have a simple (same) circuit that works for both and probably need a jumperred gate to invert the signal for the old sensor and bypass that gate when using the new one.

enter image description here


They don't really give a internal diagram (which is problematic) in their datasheet: enter image description here
Source: https://cdn.awsli.com.br/945/945993/arquivos/14_PROXIMITY_INDUCTIVE_18BY.pdf

I'll bet it looks like this (from similar designs):


simulate this circuit – Schematic created using CircuitLab

First off, you need a pull up on the output with the NPN, (they may have an internal one). You could put the opto in series with the external pull up. If you want inverted logic then use another NPN stage to invert it.

enter image description here Source: http://sullystationtechnologies.com/npninverter.html

  • \$\begingroup\$ Wow. That's great, but I think I might be a bit simple, do I have it right in non-triggered stage on the input of the PC817 we have two highs, and when the sensor is triggered the output goes low ? \$\endgroup\$ – SammerV Aug 26 '20 at 20:52
  • \$\begingroup\$ Thanks for details on the second inverter stage - I figured something like that was needed. I'm assuming this would go on output from the sensor so I still get a high to trigger the PC187? appreciate the help! \$\endgroup\$ – SammerV Aug 26 '20 at 20:59
  • \$\begingroup\$ If you like the help, make sure you vote and mark the correct question as answered. meta.stackexchange.com/questions/126180/… \$\endgroup\$ – Voltage Spike Aug 26 '20 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.