top of page

Using PNP Proximity sensors with the PicoCNC and Teensy boards.

Readers of my blog probably know that I recommend NPN proximity sensors for limit switches with my CNC breakout boards. However, some customers have asked how to use PNP sensors. The breakout boards were designed for NPN sensors but with an inexpensive adaptor board, it is possible to use PNP ones. I go over using proximity sensors in this blog.

A dive into the various circuits.

Feel free to skip ahead if you just want to know what to use. The incompatibility comes about from how the opto isolators on the breakout board receive the sensor's signal. An NPN sensor is designed to pull positive voltage through the input circuit (load) to ground (sinking) while an PNP sensor is designed to provide voltage for the input circuit (load) to pull to ground (sourcing). As such, one type's input circuitry is incompatible with the other type. So, the trick is to convert a PNP sensor's circuitry to NPN and the typical opto-isolator happens have NPN output circuitry. You can think of the transistors here as simple switches - when they get a signal from the sensor, they turn on. Otherwise, they stay off. I have shown a resistor, these are needed to limit the current that the LED will see but are not critical understanding the basic concepts.

An opto-isolator uses an LED to shine light onto a phototransistor, typically an NPN device. The PNP circuit on the sensor controls the opto's LED - when it detects metal, it sources current and the LED will light up. When the light from the LED shines on the transistor, it conducts current. Now, the opto's phototransistor, being an NPN device, will work with the opto-isolator inputs of the Teensy and Pico CNC boards.

So, what do I buy and how do I hook it up?

This part is simple. Almost any opto-isolator board will work. The one you can see below cost less than $7 from Amazon in the US. It has 4 pins per channel - 2 inputs and 2 outputs. You connect the outputs to the Teensy or Pico board's limit inputs. Ground to Ground and the other to signal.

The proximity sensor has 3 wires. Signal and Gnd connect to the opto's inputs. Note that when the color scheme shown here is fairly common, it is not guaranteed to be universal so consult your vendors documentation. You will have to run additional wire for V+ and ground. The PSU can be anything that the proximity sensor is rated for will be fine. 12V is fairly common. Study the following diagram for the connections. On the Teensy or Pico CNC board, the Signal terminal will be labeled for the associated axis (ie, X, Y, Z, ...).

Here is a photo of the board I tested. It is sold under a number of different names but usually has the numbers 817 in the name. I bought it on Amazon for $6.99 plus tax. You can find 1, 2, 4 and 8 channel versions. This messy photo shows a sensor connected to the opto board and the opto board connected to the Teensy board (T41U5XBB). Moving a piece of metal near the tip of the sensor causes it to trigger which, in turns triggers the grblHAL board. Running ioSender shows the sensor being triggered.

What about all those resistors and extra opto? Won't they cause problems?

The short answer is no. The extra opto-isolator does add some additional latency, typically 40 to 50 microseconds based on the datasheet for the PC817, the opto-isolator used for those boards. A machine axis moving at 5000 mm/Min will travel an extra .004 mm in that time. The proximity switch is actually quite a bit slower than that so a few extra microseconds won't matter.

The resistors on the Opto-isolator board can be surprisingly large so I was concerned that it could be a problem for the opto-isolators on the Teensy/Pico boards. The board I purchased uses 3K ohms but working through the calculations, that will still leave enough current to operate reliably. And, my testing showed that to be the case.

Using the opto-isolator board with the Teensy breakout board.

Some of my customers are concerned about 12V proximity sensors and the 5V inputs of the Teensy breakout board. This is a good way to be 100% certain that no harm will come to their board. These opto-isolators board will work with PNP and NPN sensors.

As an EMI solution for unprotected Arduino Grbl shields.

One sad reality of most Arduino Grbl shields is that they have no protection against EMI. This is a good solution. For less than $10, yo can protect your Grbl classic system from those insidious EMI gremlins. Even if you use mechanical switches. Wiring is is simple, just connect the outputs to gnd and the appropriate limit input.

About Me.

I'm Phil Barrett, a long time CNC enthusiast. I run a small company, Brookwood Design, that makes several breakout boards for grblHAL and love to help people get the most out of their CNC machines.


Featured Posts
Recent Posts
Search By Tags
No tags yet.
Follow Us
  • Facebook Classic
  • Twitter Classic
  • Google Classic
bottom of page