Proximity switches



  • How do we connect proximity switches to the inputs? These switches detect the proximity of ferro-metal objects. Normally they need a supply of 12-30VDC and have an idle power consumption of 10 mA. The UniPi internal power supply can easily support 5 of those. Now this power supply is a problem: +12VDC is available (2 outputs marked '12V'), but where do we get the GND (0V ground) from. Can the jumpers J2-J5 set in such a way that outputs marked 'P01' and 'P02' are connected to ground?
    Thanks, Japerik



  • How do we connect proximity switches to the inputs? These switches detect the proximity of ferro-metal objects. Normally they need a supply of 12-30VDC and have an idle power consumption of 10 mA. The UniPi internal power supply can easily support 5 of those. Now this power supply is a problem: +12VDC is available (2 outputs marked '12V'), but where do we get the GND (0V ground) from. Can the jumpers J2-J5 set in such a way that outputs marked 'P01' and 'P02' are connected to ground?
    Thanks, Japerik



  • Hello,

    the GND is the same as GND of your power supply, alternatively it is also on AI- connectors.



  • Took me some time to answer but: Thanks!

    Photo shows wiring of the proximity switch:

    • = brown to '12V'
    • = blue to AI1-
      S = black to input

    Hex key is activating the switch, thus the yellow LED at the back of the proximity switch
    and red LED of Input 1 are ON.



  • Back with another issue on proximity switches.
    As the photo shows in my previous post, the LED on the UniPi circuit board lights up nicely when the proximity switch is activated.
    For some reason however the signal is not detected by the program.

    I can see two causes for this:
    -> A pull-up or pull-down resistor is still necessary.
    -> My program is faulty.
    You can feel the questions coming:
    -> If a PU- or PD-resistor or -bridge is necessary, how to connect it?
    -> If that is not the problem, please post me a crude snippet on how to read input1.

    In general it is useful to know: Does a lit LED mean by definition the input signal should be HIGH?
    Or can it be that the LED lights up but the port value is still LOW?

    Thanks, Jaap

    P.S.
    As far as the code goes, I found the below snippet on this forum (thanks!) for setting and reading the status of relays.
    I don't understand where people find addresses and numbers like the i2cbus = 1, address = 0x20, ….data(handle, 9, 0).
    Am I missing something? Is there some manual on the web?
    What to alter to make the code below for inputs?

    import pigpio
    import time
    
    def main():
        i2cbus = 1
        address = 0x20
        pi = pigpio.pi()
        handle = pi.i2c_open(i2cbus, address, 0)
    
        pi.i2c_write_byte_data(handle, 9, 0)
        print('status: ' + str(pi.i2c_read_byte_data(handle, 9)))
    
        ...
    
        pi.i2c_close(handle)
        pi.stop()
    
    if __name__ == '__main__':
        main()
    
    


  • The pull-up resistors are included in the Raspberry Pi, you just have to activate them. The UniPi manual clearly states this fact:
    When using the GPIOs make sure to set a software pull-up resistor on each GPIO to make it work properly otherwise state of the GPIO cannot be read properly.

    Once you activate the pull-ups, the input LEDs will correlate with input readings.



  • Thanks Jaroslav, will do!