I have 3 inductive proximity sensors with NPN-NO open collector:

enter image description here

The sensors are interfaced with PIC16F690 using pin RA0, RA1, and RA2, here is the circuit for Pin RA0, it is the same for Pin RA1 and RA2:

enter image description here

When the sensor is activated, the 10K pull-up resistor is grounded to read the required logic.


This interface works well for the sensors in Pin RA1 and RA2, however, when one of the sensors is interfaced with the Pin RA0 and when i switch the power ON the PIC won't start until i push an external MCLR push button. Even after that, if i switch the power OFF then ON again, the problem reappears again and it doesn't disappear until i make another external MCLR.

Notice that when the sensor in pin RA0 is removed from the circuitry, everything is normal, the PIC starts normally, no need for a MCLR, and the remaining sensors in pin RA1 and RA2 work also as expected.

What i tried so far:

  • I suspected a problem in my PIC16F690 program, so, i substituted the sensor on RA0 with a pushbutton, everything worked as expected, additionally, i suspected a problem in my PCB circuit, so i removed all the sensors and changed them with pushbutton switch to lighten 3 LEDs to be sure everything is okay with the program and the PCB. No problem here.

  • Before pushing the MCLR button, to know if the PIC is partially blocked or fully blocked, i changed the program to lighten up an LED when the sensors in RA0 is activated, so, i approached a metal plate from the concerned sensor, the LED get ON and when i remove the metal plate from the sensor (sensor not activated) the LED stay ON.

It seems the problem is specific only to the pin RA0 of the PIC16F690 and only when it is interfaced to an inductive proximity sensor, it works well when using a pushbutton.


XT is a Crystal Quartz 4Mhz with 22pF capacitors.

I disabled ADC,CCP, SPI, and Comparator.

From the datasheet of the PIC16F690, RA0 can be a:

general purpose I/O, ADC, analog comparator, ICSP data signal, ULPW analog input.

I need your help, please.


  • \$\begingroup\$ Which proximity sensors are you using? There can be subtle differences between different npn-output types. \$\endgroup\$
    – bitsmack
    Nov 6, 2015 at 7:27
  • \$\begingroup\$ This one: opencircuit.nl/Product/10878/… .And it works on the other pins,it just with the RA0 Pin, that really surprised me. \$\endgroup\$
    – Vander_kw
    Nov 6, 2015 at 10:44
  • \$\begingroup\$ The only thing I see different about RA0 (vs RA1 or RA2) is the "Ultra Low-Power Wake-Up" (ULPWU) feature. The ULPWU is disabled by default, but perhaps it is worth explicitly clearing the PCON.ULPWUE bit upon initialization. AN897 says "RA0 cannot be read as a digital pin when ULPWU is enabled." Maybe there's something else weird with that functionality? \$\endgroup\$
    – bitsmack
    Nov 6, 2015 at 18:51
  • \$\begingroup\$ I tried that today, i disabled the ULPWU bit by explicitly changing the ULPWU bit in the PCON register, i got the same results unfortunately. \$\endgroup\$
    – Vander_kw
    Nov 7, 2015 at 22:27
  • \$\begingroup\$ is a sensor problem(A lot of sensor generate pwm signal inside, first step activate sensor output but later maybe trigerred without any conditions). you will be see more noise or invalid signal on output. Change sensor(buy from global manufacturer). Some pins got low level triger voltage(or damaged). \$\endgroup\$
    – dsgdfg
    Dec 2, 2015 at 12:04

1 Answer 1


I get nervous when I see 5 V logic mixed up with 24 V supply but you seem to have got away without smoke. Putting together your bits of circuitry I think you might have this:


simulate this circuit – Schematic created using CircuitLab

It's possible that the collector base junction is forward biased and has a low enough resistance to ground to pull RA0 low while the prox switch driver circuit powers up. You could test this fairly easily by disconnecting the 24 V, powering up and measuring the voltage on the black wire (with the pull-up connected).

The danger with your setup is that

  1. the switch could have an internal pull-up which, when Q1 is off, would pull RA0 to +24 V. (It didn't, so it doesn't.)
  2. If the blue wire is disconnected you could get enough current leaking from the 24 V through the electronics and through the base-collector junction. This would pull RA0 above +5 V.

Either of the above scenarios would smoke your PIC. Better to use an opto-isolator. Kimliv asked a question about the same switch a year ago. You may find some help there.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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