1. OCAU Merchandise now available! Check out our 20th Anniversary Mugs, Classic Logo Shirts and much more! Discussion here.
    Dismiss Notice

NPN proximity sensor sanity check

Discussion in 'Electronics & Electrics' started by kjparker, Jul 19, 2018.

  1. kjparker

    kjparker Member

    Joined:
    Jun 28, 2001
    Messages:
    1,417
    Location:
    Sydney
    I have one of these : https://www.ebay.com.au/itm/232217305235 that I am wanting to use on my 3d printer for auto bed levelling.

    I need to run it at 12v, as it does not appear to work properly at 5v. My understanding is that when triggered ground the signal pin, and that it should not be outputing the input voltage on the signal at any time.

    What I have found however, is that when the sensor is not triggered, I get 12v as measured between the ground pin and signal, and when triggered, I get ~0.1v.

    Is this normal? Am I doing something wrong in my testing? Ami I completely wrong in how I expect this to work?

    Alternatively, is it possible this sensor is faulty?
     
  2. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,548
    Location:
    Kalgoorlie, WA
    I agree, normally with an open collector transistor output you'd never see the supply voltage on the signal pin.

    Normally you would use an external pull-up to bring the output pin to logic levels. The supply could be 12V but the pull-up on the open collector output could be 5V.

    Looking at the picture it may have an internal pull-up that is linked to supply. If you connect it to a microcontroller you'd need a zener clamp or voltage divider to protect the input.
     
  3. RussellK

    RussellK Member

    Joined:
    Jun 11, 2003
    Messages:
    511
    I've got a bag of these that I bought for my router - if you measure the resistance between the collector connection and positive, you'll see almost exactly 10k, suggesting there's an internal pullup resistor.
     
  4. OP
    OP
    kjparker

    kjparker Member

    Joined:
    Jun 28, 2001
    Messages:
    1,417
    Location:
    Sydney
    Makes sense, and I didnt get that far last night. Will need to look at a voltage divider to do what I need then.... Shame, on paper, it should have been an incredibly simple solution!
     
  5. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,548
    Location:
    Kalgoorlie, WA
    A 4V - 4.5V zener across the microcontroller input would be pretty easy too.
     
  6. OP
    OP
    kjparker

    kjparker Member

    Joined:
    Jun 28, 2001
    Messages:
    1,417
    Location:
    Sydney
    Got a diagram of how that would look?
     
  7. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,548
    Location:
    Kalgoorlie, WA
    Like this image here: https://goo.gl/images/QTkwBv

    Note that in your case the resistor is already built into the sensor, so you just need the zener diode. It's reverse biased from the microcontroller pin to ground.
     
  8. OP
    OP
    kjparker

    kjparker Member

    Joined:
    Jun 28, 2001
    Messages:
    1,417
    Location:
    Sydney
  9. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,548
    Location:
    Kalgoorlie, WA
    Yep, that looks good. A 4.7V zener will work fine.

    If you can, turn off the internal pull-up in your microcontroller too as it will form a voltage divider with the sensor output resistance when the sensor output goes low.
     
  10. bradleyk

    bradleyk Member

    Joined:
    Nov 22, 2009
    Messages:
    247
    Location:
    Brisbane
    I would just use an 6.8k resistor to gnd instead of the zenner, creating a voltage divider. Just depends on the stock you have.

    Zenner will work fine.

    Really you probably don't even need one. the 10k resistor will limit the current to 0.7mA, safe for the built in rail clamp diodes. (Not recommended)
     

Share This Page

Advertisement: