0
\$\begingroup\$

I just added the ICSP port on this schematic here

enter image description here

however, when the programmer powers the circuit from the ICSP (pin1 +5V, pin6 GND) it also polarizes the relay and the bs170. If for some reason the BS170 triggers the relay will start to draw a lot of current straight from the programmer (pickit2, 3 or whatever). Is it a concern? I'd like to avoid a physical switch to isolate the relay from the circuit when in programming mode.

\$\endgroup\$
1
\$\begingroup\$

If you try to pull more current from the ICSP than it's rated to supply, you could damage the ICSP, or trip the breaker in the USB hub (if you have a decent hub with proper breakers).

It's reasonable to assume that an NPN transistor will not turn on spontaneously. It can turn on from the I/O pin. If you wish to be extra safe, you can add a fuse to the +5V line in the ICSP cable.

Few more comments on your schematic.

  • Did you deliberately not add a 47kΩ pull-up between MCLR# and +5V ?
  • Schottky would be a better diode for back EMF protection of the relay.
\$\endgroup\$
2
  • \$\begingroup\$ I deliberately not added the pullup as I'm going to use the internal MCLR pullup. I also use the internal OSC. The 1N4148 is a typo, it's actually a 1N4007 which should be ok as a flywheel diode. So how can I prevent such event? I could use a jumper to connect the +5V either to the relay or to the pin1 of the ICMP bus \$\endgroup\$ – Gianluca Ghettini Jun 6 '15 at 23:18
  • \$\begingroup\$ You might want to completely avoid powering the circuit from the ICSP programmer, and use the "normal" power supply for the circuit. In that case, you'd have to uncheck the relevant checkbox in the programmer software (so that it does not try to power the circuit), and also, it might be wise not to disable the MCLR pin as that could make connecting to the PIC a little bit difficult. \$\endgroup\$ – Laszlo Valko Jun 7 '15 at 4:54
1
\$\begingroup\$

The +5v pin on the ICSP pin can be used to power an associated MCU, but it is not necessary. If it is not being used to power the device, the programmer uses this lead to sense when the programming cable is connected to the MCU. So it still needs to be connected to +5.

To avoid the pin being used for power, you can insert a diode with the anode connected to +5 and the cathode (+ or the end with the bar) connected to the +5v of the ICSP header. In this case, you will need to connect the +5v rail to an external supply.

\$\endgroup\$
2
  • \$\begingroup\$ Ok, now I can program the micro successfully. I made I simple test code in which I simply set the RA0 pin to 1 (and it stays at login high 1). However, the relay starts to oscillate rapidly instead of being steadily up. I'm using a 5V power supply rated at 1A. The relay pulls a maximum of 150mA so I should be ok. I can't understand why it oscillates. I suspect the micro keeps resetting itself for some reason. GIE is disabled so no interrupt are triggered. \$\endgroup\$ – Gianluca Ghettini Jun 7 '15 at 12:50
  • \$\begingroup\$ I found the problem: I left the PGM pin floating (!) so it was picking noise and forced the micro to enter programming mode! Disabling LVP or grounding the PGM pin solved the problem. \$\endgroup\$ – Gianluca Ghettini Jun 7 '15 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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