Dealing with PNP vs NPN sensors- a guide for mechanical engineers

I once had a 70-year old sack-making machine grind to a halt. After some troubleshooting, the electrician came to me with a problem. He suspected the photoelectric comp mark sensor had failed but there was no marking to identify it as NPN or PNP. The machine documentation didn’t have this information either and the wiring diagram was woefully out of date. This was one of those machines that didn’t really make any money so capital expenditure could never be justified. It didn’t matter (until it broke down).

How the comp system on this machine worked was the machine’s knife position was tracked by three mechanical switches. The first switch would fire, then the second and a third would reset the system. If the eye mark sensor triggered before the first sensor, it would compensate to delay the paper. If the eye mark triggered after the second sensor, it would compensate to advance the paper. If it triggered between the two sensors, it was in the “dead zone” and it did nothing. This behaviour was controlled by a PCB and the sensor was directly wired to it- No PLC, input module, no label or any other way of knowing what the PCB was expecting.

Since we had plenty of PNP sensors available and no NPN, we swapped it out and the system seemed to start working again… sort of. It appeared to be working correctly but now the machine, rather than compensating back and forth to sync to the comp mark, it constantly adjusted in one direction. That was strange behaviour- but the sensor was working and appeared to be passing the signal to the controller correctly. At this point I was unsure if we had a NPN/PNP issue or if there was a problem elsewhere so I ordered an NPN sensor and while it was underway, I called in an electrical specialist who gave us an PNP to NPN converter. Using this, the photo eye continued to appear to work but the machine continued to misbehave.

After more unsuccessful troubleshooting, I called in another electrical expert to start again from scratch. He replaced the PNP to NPN converter with one of his own and the machine immediately came into line. The problem, he said, was the original converter needed a slightly higher value resistor in order to work properly.

Initially, what I figured I should learn from this experience was a comprehensive “ground-up” understanding of the intricacies of PNP and NPN transistors is so I can use that to sort these problems out faster. On reflection, though, the key thing to take away is that climbing this far down the ladder of abstraction doesn’t really help that much. Don’t get me wrong, I’ve done my homework on it- but trying to visualise “electron holes” while figuring out how to resolve a breakdown as a mechanical engineer is just not the most effective thing to be doing. Instead, I added two tools to my electrician’s toolkit.

First of all, you need to know for sure what type of sensor you are dealing with. Having experienced all kinds of handwaving and failed mnemonics and outright guessing via multimeter in real time next to a broken machine, I like simple foolproof things. So here’s a link to a sensor tester from RS components. You wire in the sensor and either the PNP light comes on or the NPN one does.

https://nz.rs-online.com/web/p/sensor-accessories/8399875

Now if you’ve discovered that you don’t have what you need, you may be tempted to think that you can convert one to the other using some kind of system of relays (you can’t). You can potentially rewire a PLC input (assuming your machine uses them, mine didn’t) however you typically have to do the whole bank so that’s not a useful option. The easy way is to have a couple of these converters handy. Here’s one from phoenix contact, also available from RS.

https://nz.rs-online.com/web/p/solid-state-interface-relays/5329980

Of course, this won’t help you much if you found this page by googling on your phone alongside a breakdown. Hopefully you came here under different circumstances, in which case, you should act now and buy a tester and converter before you need them. The cost of preparedness in this case is extremely low.

As you might expect in an article aimed at mechanical engineers, I haven’t spent any time trying to explain what the difference between NPN and PNP sensors actually is. As far as we need to care, it can be spooky black magic, just make sure you prepared ahead of time and bought your wizard hat and magic wand so you can make the black magic do what you want.

Leave a Reply

Your email address will not be published. Required fields are marked *